ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/webresources/JarWarResource.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/webresources/JarWarResource.java
Status
scanned
Type
file
Name
JarWarResource.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3495 (3.4 KB)
MD5
09f446c1a567e7bfc2cff427902c3d37
SHA1
6e7458e1cbb8426e89dc264f95d29c77a4cf9415
SHA256
43084a4e1f91142d10a33579dd304e0ccaa0705454addcef265298e16e7dfaeb
SHA512

      
    
SHA1_git
8ec0fff5aefafc80233945e5d8fa5fcc727dda64
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
JarWarResource.java | 3.4 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina.webresources; import java.io.IOException; import java.io.InputStream; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarInputStream; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.buf.UriUtil; /** * Represents a single resource (file or directory) that is located within a JAR that in turn is located in a WAR file. */ public class JarWarResource extends AbstractArchiveResource { private static final Log log = LogFactory.getLog(JarWarResource.class); private final String archivePath; public JarWarResource(AbstractArchiveResourceSet archiveResourceSet, String webAppPath, String baseUrl, JarEntry jarEntry, String archivePath) { super(archiveResourceSet, webAppPath, "jar:war:" + baseUrl + UriUtil.getWarSeparator() + archivePath + "!/", jarEntry, "war:" + baseUrl + UriUtil.getWarSeparator() + archivePath); this.archivePath = archivePath; } @Override protected JarInputStreamWrapper getJarInputStreamWrapper() { JarFile warFile = null; JarInputStream jarIs = null; JarEntry entry = null; try { warFile = getArchiveResourceSet().openJarFile(); JarEntry jarFileInWar = warFile.getJarEntry(archivePath); InputStream isInWar = warFile.getInputStream(jarFileInWar); jarIs = new JarInputStream(isInWar); do { entry = jarIs.getNextJarEntry(); } while (entry != null && !entry.getName().equals(getResource().getName())); if (entry == null) { return null; } return new JarInputStreamWrapper(entry, jarIs); } catch (IOException ioe) { if (log.isDebugEnabled()) { log.debug(sm.getString("jarResource.getInputStreamFail", getResource().getName(), getBaseUrl()), ioe); } // Ensure jarIs is closed if there is an exception entry = null; return null; } finally { if (entry == null) { if (jarIs != null) { try { jarIs.close(); } catch (IOException ioe) { // Ignore } } if (warFile != null) { getArchiveResourceSet().closeJarFile(); } } } } @Override protected Log getLog() { return log; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
35.21
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9