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

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

      
    
Rootfs path

      
    
Size
3856 (3.8 KB)
MD5
c622d50a772366adc3431e02ab28070c
SHA1
85361456f5cee04cb186cbb3bec7e7e7f32eceb6
SHA256
b05c135d0bc978ea9b328436d7d7efb51efa91ffa51e6e8800428b6a8f5ab039
SHA512

      
    
SHA1_git
e5f70e14fe21659eb5758e75bbacd5da6c8c5736
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ExtractingRoot.java | 3.8 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.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import jakarta.servlet.ServletContext; import org.apache.catalina.LifecycleException; import org.apache.catalina.WebResource; import org.apache.catalina.startup.ExpandWar; import org.apache.catalina.util.IOTools; import org.apache.tomcat.util.res.StringManager; /** * If the main resources are packaged as a WAR file then any JARs will be extracted to the work directory and used from * there. */ public class ExtractingRoot extends StandardRoot { private static final StringManager sm = StringManager.getManager(ExtractingRoot.class); private static final String APPLICATION_JARS_DIR = "application-jars"; @Override protected void processWebInfLib() throws LifecycleException { // Don't extract JAR files unless the application is deployed as a // packed WAR file. if (!super.isPackedWarFile()) { super.processWebInfLib(); return; } File expansionTarget = getExpansionTarget(); if (!expansionTarget.isDirectory()) { if (!expansionTarget.mkdirs()) { throw new LifecycleException(sm.getString("extractingRoot.targetFailed", expansionTarget)); } } WebResource[] possibleJars = listResources("/WEB-INF/lib", false); for (WebResource possibleJar : possibleJars) { if (possibleJar.isFile() && possibleJar.getName().endsWith(".jar")) { try { File dest = new File(expansionTarget, possibleJar.getName()); dest = dest.getCanonicalFile(); try (InputStream sourceStream = possibleJar.getInputStream(); OutputStream destStream = new FileOutputStream(dest)) { IOTools.flow(sourceStream, destStream); } createWebResourceSet(ResourceSetType.CLASSES_JAR, "/WEB-INF/classes", dest.toURI().toURL(), "/"); } catch (IOException ioe) { throw new LifecycleException(sm.getString("extractingRoot.jarFailed", possibleJar.getName()), ioe); } } } } private File getExpansionTarget() { File tmpDir = (File) getContext().getServletContext().getAttribute(ServletContext.TEMPDIR); return new File(tmpDir, APPLICATION_JARS_DIR); } @Override protected boolean isPackedWarFile() { return false; } @Override protected void stopInternal() throws LifecycleException { super.stopInternal(); if (super.isPackedWarFile()) { // Remove the extracted JARs from the work directory File expansionTarget = getExpansionTarget(); ExpandWar.delete(expansionTarget); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
31.4
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