org.apache.juli.logging.Log Java Examples

The following examples show how to use org.apache.juli.logging.Log. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultInstanceManager.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
private static void loadProperties(Set<String> classNames, String resourceName,
        String messageKey, Log log) {
    Properties properties = new Properties();
    ClassLoader cl = DefaultInstanceManager.class.getClassLoader();
    try (InputStream is = cl.getResourceAsStream(resourceName)) {
        if (is == null) {
            log.error(sm.getString(messageKey, resourceName));
        } else {
            properties.load(is);
        }
    } catch (IOException ioe) {
        log.error(sm.getString(messageKey, resourceName), ioe);
    }
    if (properties.isEmpty()) {
        return;
    }
    for (Map.Entry<Object, Object> e : properties.entrySet()) {
        if ("restricted".equals(e.getValue())) {
            classNames.add(e.getKey().toString());
        } else {
            log.warn(sm.getString(
                    "defaultInstanceManager.restrictedWrongValue",
                    resourceName, e.getKey(), e.getValue()));
        }
    }
}
 
Example #2
Source File: Digester.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
public static void replaceSystemProperties() {
    Log log = LogFactory.getLog(Digester.class);
    if (propertySource != null) {
        IntrospectionUtils.PropertySource[] propertySources =
                new IntrospectionUtils.PropertySource[] { propertySource };
        Properties properties = System.getProperties();
        Set<String> names = properties.stringPropertyNames();
        for (String name : names) {
            String value = System.getProperty(name);
            if (value != null) {
                try {
                    String newValue = IntrospectionUtils.replaceProperties(value, null, propertySources, null);
                    if (!value.equals(newValue)) {
                        System.setProperty(name, newValue);
                    }
                } catch (Exception e) {
                    log.warn(sm.getString("digester.failedToUpdateSystemProperty", name, value), e);
                }
            }
        }
    }
}
 
Example #3
Source File: ContainerBase.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Return the Logger for this Container.
 */
@Override
public Log getLogger() {
    if (logger != null)
        return logger;
    logger = LogFactory.getLog(getLogName());
    return logger;
}
 
Example #4
Source File: CallbackHandlerImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

    String name = null;
    Principal principal = null;
    Subject subject = null;
    String[] groups = null;

    if (callbacks != null) {
        // Need to combine data from multiple callbacks so use this to hold
        // the data
        // Process the callbacks
        for (Callback callback : callbacks) {
            if (callback instanceof CallerPrincipalCallback) {
                CallerPrincipalCallback cpc = (CallerPrincipalCallback) callback;
                name = cpc.getName();
                principal = cpc.getPrincipal();
                subject = cpc.getSubject();
            } else if (callback instanceof GroupPrincipalCallback) {
                GroupPrincipalCallback gpc = (GroupPrincipalCallback) callback;
                groups = gpc.getGroups();
            } else {
                // This is a singleton so need to get correct Logger for
                // current TCCL
                Log log = LogFactory.getLog(CallbackHandlerImpl.class);
                log.error(sm.getString("callbackHandlerImpl.jaspicCallbackMissing",
                        callback.getClass().getName()));
            }
        }

        // Create the GenericPrincipal
        Principal gp = getPrincipal(principal, name, groups);
        if (subject != null && gp != null) {
            subject.getPrivateCredentials().add(gp);
        }
    }
}
 
Example #5
Source File: FileStore.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Load and return the Session associated with the specified session
 * identifier from this Store, without removing it.  If there is no
 * such stored Session, return <code>null</code>.
 *
 * @param id Session identifier of the session to load
 *
 * @exception ClassNotFoundException if a deserialization error occurs
 * @exception IOException if an input/output error occurs
 */
@Override
public Session load(String id) throws ClassNotFoundException, IOException {
    // Open an input stream to the specified pathname, if any
    File file = file(id);
    if (file == null) {
        return null;
    }

    if (!file.exists()) {
        return null;
    }

    Context context = getManager().getContext();
    Log contextLog = context.getLogger();

    if (contextLog.isDebugEnabled()) {
        contextLog.debug(sm.getString(getStoreName()+".loading", id, file.getAbsolutePath()));
    }

    ClassLoader oldThreadContextCL = context.bind(Globals.IS_SECURITY_ENABLED, null);

    try (FileInputStream fis = new FileInputStream(file.getAbsolutePath());
            ObjectInputStream ois = getObjectInputStream(fis)) {

        StandardSession session = (StandardSession) manager.createEmptySession();
        session.readObjectData(ois);
        session.setManager(manager);
        return session;
    } catch (FileNotFoundException e) {
        if (contextLog.isDebugEnabled()) {
            contextLog.debug("No persisted data file found");
        }
        return null;
    } finally {
        context.unbind(Globals.IS_SECURITY_ENABLED, oldThreadContextCL);
    }
}
 
Example #6
Source File: SecurityClassLoad.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static void securityClassLoad(ClassLoader loader) {

        if (System.getSecurityManager() == null) {
            return;
        }

        final String basePackage = "org.apache.jasper.";
        try {
            // Ensure XMLInputFactory is loaded with Tomcat's class loader
            loader.loadClass(basePackage + "compiler.EncodingDetector");

            loader.loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedGetPageContext");
            loader.loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedReleasePageContext");

            loader.loadClass(basePackage + "runtime.JspRuntimeLibrary");

            loader.loadClass(basePackage + "runtime.ServletResponseWrapperInclude");
            loader.loadClass(basePackage + "runtime.TagHandlerPool");
            loader.loadClass(basePackage + "runtime.JspFragmentHelper");

            loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper");

            loader.loadClass(basePackage + "runtime.PageContextImpl");
            loadAnonymousInnerClasses(loader, basePackage + "runtime.PageContextImpl");

            loader.loadClass(basePackage + "runtime.JspContextWrapper");

            // Trigger loading of class and reading of property
            SecurityUtil.isPackageProtectionEnabled();

            loader.loadClass(basePackage + "servlet.JspServletWrapper");

            loadAnonymousInnerClasses(loader, "runtime.JspWriterImpl");
        } catch (ClassNotFoundException ex) {
            Log log = LogFactory.getLog(SecurityClassLoad.class);
            log.error("SecurityClassLoad", ex);
        }
    }
 
Example #7
Source File: DigesterFactory.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private static String locationFor(String name) {
    URL location = CLASS_SERVLET_CONTEXT.getResource("resources/" + name);
    if (location == null && CLASS_JSP_CONTEXT != null) {
        location = CLASS_JSP_CONTEXT.getResource("resources/" + name);
    }
    if (location == null) {
        Log log = LogFactory.getLog(DigesterFactory.class);
        log.warn(sm.getString("digesterFactory.missingSchema", name));
        return null;
    }
    return location.toExternalForm();
}
 
Example #8
Source File: ContainerBase.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Return the Logger for this Container.
 */
@Override
public Log getLogger() {

    if (logger != null)
        return (logger);
    logger = LogFactory.getLog(logName());
    return (logger);

}
 
Example #9
Source File: LazyReplicatedMap.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private Log getLog() {
    if (log == null) {
        synchronized (this) {
            if (log == null) {
                log = LogFactory.getLog(LazyReplicatedMap.class);
            }
        }
    }
    return log;
}
 
Example #10
Source File: ReplicatedMap.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private Log getLog() {
    if (log == null) {
        synchronized (this) {
            if (log == null) {
                log = LogFactory.getLog(ReplicatedMap.class);
            }
        }
    }
    return log;
}
 
Example #11
Source File: UserDataHelper.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public UserDataHelper(Log log) {
    this.log = log;

    Config tempConfig;
    String configString = System.getProperty(
            "org.apache.juli.logging.UserDataHelper.CONFIG");
    if (configString == null) {
        tempConfig = Config.INFO_THEN_DEBUG;
    } else {
        try {
            tempConfig = Config.valueOf(configString);
        } catch (IllegalArgumentException iae) {
            // Ignore - use default
            tempConfig = Config.INFO_THEN_DEBUG;
        }
    }

    // Default suppression time of 1 day.
    suppressionTime = Integer.getInteger(
            "org.apache.juli.logging.UserDataHelper.SUPPRESSION_TIME",
            60 * 60 * 24).intValue() * 1000L;

    if (suppressionTime == 0) {
        tempConfig = Config.INFO_ALL;
    }

    config = tempConfig;
}
 
Example #12
Source File: OpenSSLUtil.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #13
Source File: TesterHost.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public Log getLogger() {
    return null;
}
 
Example #14
Source File: Http11AprProcessor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #15
Source File: NioEndpoint.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #16
Source File: WsFrameClient.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #17
Source File: TesterContext.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public Log getLogger() {
    return log;
}
 
Example #18
Source File: SSLUtilBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
static <T> List<T> getEnabled(String name, Log log, boolean warnOnSkip, Collection<T> configured,
        Collection<T> implemented) {

    List<T> enabled = new ArrayList<>();

    if (implemented.size() == 0) {
        // Unable to determine the list of available protocols. This will
        // have been logged previously.
        // Use the configuredProtocols and hope they work. If not, an error
        // will be generated when the list is used. Not ideal but no more
        // can be done at this point.
        enabled.addAll(configured);
    } else {
        enabled.addAll(configured);
        enabled.retainAll(implemented);

        if (enabled.isEmpty()) {
            // Don't use the defaults in this case. They may be less secure
            // than the configuration the user intended.
            // Force the failure of the connector
            throw new IllegalArgumentException(
                    sm.getString("sslUtilBase.noneSupported", name, configured));
        }
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("sslUtilBase.active", name, enabled));
        }
        if (log.isDebugEnabled() || warnOnSkip) {
            if (enabled.size() != configured.size()) {
                List<T> skipped = new ArrayList<>();
                skipped.addAll(configured);
                skipped.removeAll(enabled);
                String msg = sm.getString("sslUtilBase.skipped", name, skipped);
                if (warnOnSkip) {
                    log.warn(msg);
                } else {
                    log.debug(msg);
                }
            }
        }
    }

    return enabled;
}
 
Example #19
Source File: AprProcessor.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() {return log;}
 
Example #20
Source File: RemoteAddrFilter.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLogger() {
    return log;
}
 
Example #21
Source File: AprEndpoint.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #22
Source File: NioEndpoint.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #23
Source File: Http11Nio2Protocol.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected Log getLog() { return log; }
 
Example #24
Source File: AjpNioProtocol.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() { return log; }
 
Example #25
Source File: HttpHeaderSecurityFilter.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLogger() {
    return log;
}
 
Example #26
Source File: FailedRequestFilter.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLogger() {
    return log;
}
 
Example #27
Source File: UpgradeProcessorInternal.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}
 
Example #28
Source File: AprProcessor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() {return log;}
 
Example #29
Source File: AjpAprProtocol.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected Log getLog() { return log; }
 
Example #30
Source File: AjpProcessor.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
protected Log getLog() {
    return log;
}