This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new a0d5ba947e Code clean-up - no functional change a0d5ba947e is described below commit a0d5ba947ee47f11ebb03720f4aeceac4736f280 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Oct 2 09:19:15 2023 +0100 Code clean-up - no functional change --- .../catalina/security/DeployXmlPermission.java | 7 +- .../catalina/security/SecurityClassLoad.java | 3 +- .../apache/catalina/security/SecurityConfig.java | 49 ++-- .../apache/catalina/security/SecurityListener.java | 51 ++-- .../org/apache/catalina/security/SecurityUtil.java | 299 ++++++++------------- 5 files changed, 165 insertions(+), 244 deletions(-) diff --git a/java/org/apache/catalina/security/DeployXmlPermission.java b/java/org/apache/catalina/security/DeployXmlPermission.java index bf8ca273c5..7509be5fc1 100644 --- a/java/org/apache/catalina/security/DeployXmlPermission.java +++ b/java/org/apache/catalina/security/DeployXmlPermission.java @@ -19,10 +19,9 @@ package org.apache.catalina.security; import java.security.BasicPermission; /** - * Grant this permission to a docBase to permit the web application to use any - * <code>META-INF/context.xml</code> that might be present with in the - * application when <code>deployXML</code> has been disabled at the Host level. - * The name of the permission should be the base name for the web application. + * Grant this permission to a docBase to permit the web application to use any <code>META-INF/context.xml</code> that + * might be present with in the application when <code>deployXML</code> has been disabled at the Host level. The name of + * the permission should be the base name for the web application. */ public class DeployXmlPermission extends BasicPermission { diff --git a/java/org/apache/catalina/security/SecurityClassLoad.java b/java/org/apache/catalina/security/SecurityClassLoad.java index b79c75abde..7f1a6d9c95 100644 --- a/java/org/apache/catalina/security/SecurityClassLoad.java +++ b/java/org/apache/catalina/security/SecurityClassLoad.java @@ -17,8 +17,7 @@ package org.apache.catalina.security; /** - * Static class used to preload java classes when using the - * Java SecurityManager so that the defineClassInPackage + * Static class used to preload java classes when using the Java SecurityManager so that the defineClassInPackage * RuntimePermission does not trigger an AccessControlException. * * @author Glenn L. Nielsen diff --git a/java/org/apache/catalina/security/SecurityConfig.java b/java/org/apache/catalina/security/SecurityConfig.java index 3b16e4b2c0..89d3d1b4f1 100644 --- a/java/org/apache/catalina/security/SecurityConfig.java +++ b/java/org/apache/catalina/security/SecurityConfig.java @@ -23,11 +23,11 @@ import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; /** - * Util class to protect Catalina against package access and insertion. - * The code are been moved from Catalina.java + * Util class to protect Catalina against package access and insertion. The code are been moved from Catalina.java + * * @author the Catalina.java authors */ -public final class SecurityConfig{ +public final class SecurityConfig { private static final Object singletonLock = new Object(); private static volatile SecurityConfig singleton = null; @@ -35,19 +35,13 @@ public final class SecurityConfig{ private static final Log log = LogFactory.getLog(SecurityConfig.class); - private static final String PACKAGE_ACCESS = "sun.," - + "org.apache.catalina." - + ",org.apache.jasper." - + ",org.apache.coyote." - + ",org.apache.tomcat."; + private static final String PACKAGE_ACCESS = + "sun.," + "org.apache.catalina." + ",org.apache.jasper." + ",org.apache.coyote." + ",org.apache.tomcat."; // FIX ME package "javax." was removed to prevent HotSpot // fatal internal errors - private static final String PACKAGE_DEFINITION= "java.,sun." - + ",org.apache.catalina." - + ",org.apache.coyote." - + ",org.apache.tomcat." - + ",org.apache.jasper."; + private static final String PACKAGE_DEFINITION = "java.,sun." + ",org.apache.catalina." + ",org.apache.coyote." + + ",org.apache.tomcat." + ",org.apache.jasper."; /** * List of protected package from conf/catalina.properties */ @@ -66,11 +60,11 @@ public final class SecurityConfig{ private SecurityConfig() { String definition = null; String access = null; - try{ + try { definition = CatalinaProperties.getProperty("package.definition"); access = CatalinaProperties.getProperty("package.access"); - } catch (java.lang.Exception ex){ - if (log.isDebugEnabled()){ + } catch (java.lang.Exception ex) { + if (log.isDebugEnabled()) { log.debug("Unable to load properties using CatalinaProperties", ex); } } finally { @@ -82,9 +76,10 @@ public final class SecurityConfig{ /** * Returns the singleton instance of that class. + * * @return an instance of that class. */ - public static SecurityConfig newInstance(){ + public static SecurityConfig newInstance() { if (singleton == null) { synchronized (singletonLock) { if (singleton == null) { @@ -99,9 +94,9 @@ public final class SecurityConfig{ /** * Set the security package.access value. */ - public void setPackageAccess(){ + public void setPackageAccess() { // If catalina.properties is missing, protect all by default. - if (packageAccess == null){ + if (packageAccess == null) { setSecurityProperty("package.access", PACKAGE_ACCESS); } else { setSecurityProperty("package.access", packageAccess); @@ -112,24 +107,25 @@ public final class SecurityConfig{ /** * Set the security package.definition value. */ - public void setPackageDefinition(){ + public void setPackageDefinition() { // If catalina.properties is missing, protect all by default. - if (packageDefinition == null){ + if (packageDefinition == null) { setSecurityProperty("package.definition", PACKAGE_DEFINITION); - } else { + } else { setSecurityProperty("package.definition", packageDefinition); - } + } } /** * Set the proper security property + * * @param properties the package.* property. */ - private void setSecurityProperty(String properties, String packageList){ - if (System.getSecurityManager() != null){ + private void setSecurityProperty(String properties, String packageList) { + if (System.getSecurityManager() != null) { String definition = Security.getProperty(properties); - if( definition != null && definition.length() > 0 ){ + if (definition != null && definition.length() > 0) { if (packageList.length() > 0) { definition = definition + ',' + packageList; } @@ -144,4 +140,3 @@ public final class SecurityConfig{ } - diff --git a/java/org/apache/catalina/security/SecurityListener.java b/java/org/apache/catalina/security/SecurityListener.java index 6df8412935..2371e30f7d 100644 --- a/java/org/apache/catalina/security/SecurityListener.java +++ b/java/org/apache/catalina/security/SecurityListener.java @@ -36,11 +36,9 @@ public class SecurityListener implements LifecycleListener { private static final Log log = LogFactory.getLog(SecurityListener.class); - private static final StringManager sm = - StringManager.getManager(Constants.PACKAGE); + private static final StringManager sm = StringManager.getManager(Constants.PACKAGE); - private static final String UMASK_PROPERTY_NAME = - Constants.PACKAGE + ".SecurityListener.UMASK"; + private static final String UMASK_PROPERTY_NAME = Constants.PACKAGE + ".SecurityListener.UMASK"; private static final String UMASK_FORMAT = "%04o"; @@ -50,8 +48,8 @@ public class SecurityListener implements LifecycleListener { private final Set<String> checkedOsUsers = new HashSet<>(); /** - * The minimum umask that must be configured for the operating system user - * running Tomcat. The umask is handled as an octal. + * The minimum umask that must be configured for the operating system user running Tomcat. The umask is handled as + * an octal. */ private Integer minimumUmask = Integer.valueOf(7); @@ -66,8 +64,7 @@ public class SecurityListener implements LifecycleListener { // This is the earliest event in Lifecycle if (event.getType().equals(Lifecycle.BEFORE_INIT_EVENT)) { if (!(event.getLifecycle() instanceof Server)) { - log.warn(sm.getString("listener.notServer", - event.getLifecycle().getClass().getSimpleName())); + log.warn(sm.getString("listener.notServer", event.getLifecycle().getClass().getSimpleName())); } doChecks(); } @@ -75,14 +72,12 @@ public class SecurityListener implements LifecycleListener { /** - * Set the list of operating system users not permitted to run Tomcat. By - * default, only root is prevented from running Tomcat. Calling this method - * with null or the empty string will clear the list of users and - * effectively disables this check. User names will always be checked in a - * case insensitive manner using the system default Locale. + * Set the list of operating system users not permitted to run Tomcat. By default, only root is prevented from + * running Tomcat. Calling this method with null or the empty string will clear the list of users and effectively + * disables this check. User names will always be checked in a case insensitive manner using the system default + * Locale. * - * @param userNameList A comma separated list of operating system users not - * permitted to run Tomcat + * @param userNameList A comma separated list of operating system users not permitted to run Tomcat */ public void setCheckedOsUsers(String userNameList) { if (userNameList == null || userNameList.length() == 0) { @@ -99,10 +94,9 @@ public class SecurityListener implements LifecycleListener { /** - * Returns the current list of operating system users not permitted to run - * Tomcat. + * Returns the current list of operating system users not permitted to run Tomcat. * - * @return A comma separated list of operating system user names. + * @return A comma separated list of operating system user names. */ public String getCheckedOsUsers() { return StringUtils.join(checkedOsUsers); @@ -126,7 +120,7 @@ public class SecurityListener implements LifecycleListener { /** * Get the minimum umask that must be configured before Tomcat will start. * - * @return The 4-digit umask as used by the OS command <i>umask</i> + * @return The 4-digit umask as used by the OS command <i>umask</i> */ public String getMinimumUmask() { return String.format(UMASK_FORMAT, minimumUmask); @@ -149,8 +143,7 @@ public class SecurityListener implements LifecycleListener { if (checkedOsUsers.contains(userNameLC)) { // Have to throw Error to force start process to be aborted - throw new Error(sm.getString( - "SecurityListener.checkUserWarning", userName)); + throw new Error(sm.getString("SecurityListener.checkUserWarning", userName)); } } } @@ -161,10 +154,9 @@ public class SecurityListener implements LifecycleListener { Integer umask = null; if (prop != null) { try { - umask = Integer.valueOf(prop, 8); + umask = Integer.valueOf(prop, 8); } catch (NumberFormatException nfe) { - log.warn(sm.getString("SecurityListener.checkUmaskParseFail", - prop)); + log.warn(sm.getString("SecurityListener.checkUmaskParseFail", prop)); } } if (umask == null) { @@ -176,18 +168,15 @@ public class SecurityListener implements LifecycleListener { return; } else { if (minimumUmask.intValue() > 0) { - log.warn(sm.getString( - "SecurityListener.checkUmaskNone", - UMASK_PROPERTY_NAME, getMinimumUmask())); + log.warn(sm.getString("SecurityListener.checkUmaskNone", UMASK_PROPERTY_NAME, getMinimumUmask())); } return; } } - if ((umask.intValue() & minimumUmask.intValue()) != - minimumUmask.intValue()) { - throw new Error(sm.getString("SecurityListener.checkUmaskFail", - String.format(UMASK_FORMAT, umask), getMinimumUmask())); + if ((umask.intValue() & minimumUmask.intValue()) != minimumUmask.intValue()) { + throw new Error(sm.getString("SecurityListener.checkUmaskFail", String.format(UMASK_FORMAT, umask), + getMinimumUmask())); } } } diff --git a/java/org/apache/catalina/security/SecurityUtil.java b/java/org/apache/catalina/security/SecurityUtil.java index 0f11480de0..69ed36b769 100644 --- a/java/org/apache/catalina/security/SecurityUtil.java +++ b/java/org/apache/catalina/security/SecurityUtil.java @@ -39,22 +39,20 @@ import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.res.StringManager; + /** - * This utility class associates a <code>Subject</code> to the current - * <code>AccessControlContext</code>. When a <code>SecurityManager</code> is - * used, the container will always associate the called thread with an - * AccessControlContext containing only the principal of the requested - * Servlet/Filter. - * - * This class uses reflection to invoke the methods. + * This utility class associates a <code>Subject</code> to the current <code>AccessControlContext</code>. When a + * <code>SecurityManager</code> is used, the container will always associate the called thread with an + * AccessControlContext containing only the principal of the requested Servlet/Filter. This class uses reflection to + * invoke the methods. */ -public final class SecurityUtil{ +public final class SecurityUtil { // Note that indexes overlap. // A Servlet uses "init", "service", "event", "destroy". // A Filter uses "doFilter", "doFilterEvent", "destroy". - private static final int INIT= 0; + private static final int INIT = 0; private static final int SERVICE = 1; private static final int DOFILTER = 1; private static final int EVENT = 2; @@ -76,94 +74,68 @@ public final class SecurityUtil{ private static final Log log = LogFactory.getLog(SecurityUtil.class); private static final boolean packageDefinitionEnabled = - (System.getProperty("package.definition") == null && - System.getProperty("package.access") == null) ? false : true; + (System.getProperty("package.definition") == null && System.getProperty("package.access") == null) ? false : + true; /** * The string resources for this package. */ - private static final StringManager sm = - StringManager.getManager(Constants.PACKAGE); + private static final StringManager sm = StringManager.getManager(Constants.PACKAGE); /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the <code>Servlet</code> on which the method will be called. * - * @param methodName the method to apply the security restriction - * @param targetObject the <code>Servlet</code> on which the method will - * be called. * @throws Exception an execution error occurred */ - public static void doAsPrivilege(final String methodName, - final Servlet targetObject) throws Exception { - doAsPrivilege(methodName, targetObject, null, null, null); + public static void doAsPrivilege(final String methodName, final Servlet targetObject) throws Exception { + doAsPrivilege(methodName, targetObject, null, null, null); } /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the <code>Servlet</code> on which the method will be called. + * @param targetType <code>Class</code> array used to instantiate a <code>Method</code> object. + * @param targetArguments <code>Object</code> array contains the runtime parameters instance. * - * @param methodName the method to apply the security restriction - * @param targetObject the <code>Servlet</code> on which the method will - * be called. - * @param targetType <code>Class</code> array used to instantiate a - * <code>Method</code> object. - * @param targetArguments <code>Object</code> array contains the runtime - * parameters instance. * @throws Exception an execution error occurred */ - public static void doAsPrivilege(final String methodName, - final Servlet targetObject, - final Class<?>[] targetType, - final Object[] targetArguments) - throws Exception { - - doAsPrivilege(methodName, - targetObject, - targetType, - targetArguments, - null); + public static void doAsPrivilege(final String methodName, final Servlet targetObject, final Class<?>[] targetType, + final Object[] targetArguments) throws Exception { + + doAsPrivilege(methodName, targetObject, targetType, targetArguments, null); } /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the <code>Servlet</code> on which the method will be called. + * @param targetParameterTypes <code>Class</code> array used to instantiate a <code>Method</code> object. + * @param targetArguments <code>Object</code> array contains the runtime parameters instance. + * @param principal the <code>Principal</code> to which the security privilege applies * - * @param methodName the method to apply the security restriction - * @param targetObject the <code>Servlet</code> on which the method will - * be called. - * @param targetParameterTypes <code>Class</code> array used to instantiate a - * <code>Method</code> object. - * @param targetArguments <code>Object</code> array contains the - * runtime parameters instance. - * @param principal the <code>Principal</code> to which the security - * privilege applies * @throws Exception an execution error occurred */ - public static void doAsPrivilege(final String methodName, - final Servlet targetObject, - final Class<?>[] targetParameterTypes, - final Object[] targetArguments, - Principal principal) - throws Exception { + public static void doAsPrivilege(final String methodName, final Servlet targetObject, + final Class<?>[] targetParameterTypes, final Object[] targetArguments, Principal principal) + throws Exception { Method method = null; Method[] methodsCache = classCache.get(Servlet.class); - if(methodsCache == null) { - method = createMethodAndCacheIt(null, - Servlet.class, - methodName, - targetParameterTypes); + if (methodsCache == null) { + method = createMethodAndCacheIt(null, Servlet.class, methodName, targetParameterTypes); } else { method = findMethod(methodsCache, methodName); if (method == null) { - method = createMethodAndCacheIt(methodsCache, - Servlet.class, - methodName, - targetParameterTypes); + method = createMethodAndCacheIt(methodsCache, Servlet.class, methodName, targetParameterTypes); } } @@ -172,81 +144,58 @@ public final class SecurityUtil{ /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the <code>Filter</code> on which the method will be called. * - * @param methodName the method to apply the security restriction - * @param targetObject the <code>Filter</code> on which the method will - * be called. * @throws Exception an execution error occurred */ - public static void doAsPrivilege(final String methodName, - final Filter targetObject) - throws Exception { + public static void doAsPrivilege(final String methodName, final Filter targetObject) throws Exception { - doAsPrivilege(methodName, targetObject, null, null); + doAsPrivilege(methodName, targetObject, null, null); } /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the <code>Filter</code> on which the method will be called. + * @param targetType <code>Class</code> array used to instantiate a <code>Method</code> object. + * @param targetArguments <code>Object</code> array contains the runtime parameters instance. * - * @param methodName the method to apply the security restriction - * @param targetObject the <code>Filter</code> on which the method will - * be called. - * @param targetType <code>Class</code> array used to instantiate a - * <code>Method</code> object. - * @param targetArguments <code>Object</code> array contains the - * runtime parameters instance. * @throws Exception an execution error occurred */ - public static void doAsPrivilege(final String methodName, - final Filter targetObject, - final Class<?>[] targetType, - final Object[] targetArguments) - throws Exception { - - doAsPrivilege( - methodName, targetObject, targetType, targetArguments, null); + public static void doAsPrivilege(final String methodName, final Filter targetObject, final Class<?>[] targetType, + final Object[] targetArguments) throws Exception { + + doAsPrivilege(methodName, targetObject, targetType, targetArguments, null); } /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the <code>Filter</code> on which the method will be called. + * @param targetParameterTypes <code>Class</code> array used to instantiate a <code>Method</code> object. + * @param targetParameterValues <code>Object</code> array contains the runtime parameters instance. + * @param principal the <code>Principal</code> to which the security privilege applies * - * @param methodName the method to apply the security restriction - * @param targetObject the <code>Filter</code> on which the method will - * be called. - * @param targetParameterTypes <code>Class</code> array used to instantiate a - * <code>Method</code> object. - * @param targetParameterValues <code>Object</code> array contains the - * runtime parameters instance. - * @param principal the <code>Principal</code> to which the security - * privilege applies * @throws Exception an execution error occurred */ - public static void doAsPrivilege(final String methodName, - final Filter targetObject, - final Class<?>[] targetParameterTypes, - final Object[] targetParameterValues, - Principal principal) - throws Exception { + public static void doAsPrivilege(final String methodName, final Filter targetObject, + final Class<?>[] targetParameterTypes, final Object[] targetParameterValues, Principal principal) + throws Exception { Method method = null; Method[] methodsCache = classCache.get(Filter.class); - if(methodsCache == null) { - method = createMethodAndCacheIt(null, - Filter.class, - methodName, - targetParameterTypes); + if (methodsCache == null) { + method = createMethodAndCacheIt(null, Filter.class, methodName, targetParameterTypes); } else { method = findMethod(methodsCache, methodName); if (method == null) { - method = createMethodAndCacheIt(methodsCache, - Filter.class, - methodName, - targetParameterTypes); + method = createMethodAndCacheIt(methodsCache, Filter.class, methodName, targetParameterTypes); } } @@ -255,50 +204,40 @@ public final class SecurityUtil{ /** - * Perform work as a particular <code>Subject</code>. Here the work - * will be granted to a <code>null</code> subject. + * Perform work as a particular <code>Subject</code>. Here the work will be granted to a <code>null</code> subject. + * + * @param method the method to apply the security restriction + * @param targetObject the <code>Servlet</code> on which the method will be called. + * @param targetArguments <code>Object</code> array contains the runtime parameters instance. + * @param principal the <code>Principal</code> to which the security privilege applies * - * @param method the method to apply the security restriction - * @param targetObject the <code>Servlet</code> on which the method will - * be called. - * @param targetArguments <code>Object</code> array contains the - * runtime parameters instance. - * @param principal the <code>Principal</code> to which the security - * privilege applies * @throws Exception an execution error occurred */ - private static void execute(final Method method, - final Object targetObject, - final Object[] targetArguments, - Principal principal) - throws Exception { + private static void execute(final Method method, final Object targetObject, final Object[] targetArguments, + Principal principal) throws Exception { - try{ + try { Subject subject = null; - PrivilegedExceptionAction<Void> pea = - () -> { - method.invoke(targetObject, targetArguments); - return null; - }; + PrivilegedExceptionAction<Void> pea = () -> { + method.invoke(targetObject, targetArguments); + return null; + }; // The first argument is always the request object - if (targetArguments != null - && targetArguments[0] instanceof HttpServletRequest){ - HttpServletRequest request = - (HttpServletRequest)targetArguments[0]; + if (targetArguments != null && targetArguments[0] instanceof HttpServletRequest) { + HttpServletRequest request = (HttpServletRequest) targetArguments[0]; boolean hasSubject = false; HttpSession session = request.getSession(false); - if (session != null){ - subject = - (Subject)session.getAttribute(Globals.SUBJECT_ATTR); + if (session != null) { + subject = (Subject) session.getAttribute(Globals.SUBJECT_ATTR); hasSubject = (subject != null); } - if (subject == null){ + if (subject == null) { subject = new Subject(); - if (principal != null){ + if (principal != null) { subject.getPrincipals().add(principal); } } @@ -309,7 +248,7 @@ public final class SecurityUtil{ } Subject.doAsPrivileged(subject, pea, null); - } catch( PrivilegedActionException pe) { + } catch (PrivilegedActionException pe) { Throwable e; if (pe.getException() instanceof InvocationTargetException) { e = pe.getException().getCause(); @@ -318,7 +257,7 @@ public final class SecurityUtil{ e = pe; } - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug(sm.getString("SecurityUtil.doAsPrivilege"), e); } @@ -339,23 +278,24 @@ public final class SecurityUtil{ /** * Find a method stored within the cache. + * * @param methodsCache the cache used to store method instance - * @param methodName the method to apply the security restriction + * @param methodName the method to apply the security restriction + * * @return the method instance, null if not yet created. */ - private static Method findMethod(Method[] methodsCache, - String methodName){ - if (methodName.equals(INIT_METHOD)){ + private static Method findMethod(Method[] methodsCache, String methodName) { + if (methodName.equals(INIT_METHOD)) { return methodsCache[INIT]; - } else if (methodName.equals(DESTROY_METHOD)){ + } else if (methodName.equals(DESTROY_METHOD)) { return methodsCache[DESTROY]; - } else if (methodName.equals(SERVICE_METHOD)){ + } else if (methodName.equals(SERVICE_METHOD)) { return methodsCache[SERVICE]; - } else if (methodName.equals(DOFILTER_METHOD)){ + } else if (methodName.equals(DOFILTER_METHOD)) { return methodsCache[DOFILTER]; - } else if (methodName.equals(EVENT_METHOD)){ + } else if (methodName.equals(EVENT_METHOD)) { return methodsCache[EVENT]; - } else if (methodName.equals(DOFILTEREVENT_METHOD)){ + } else if (methodName.equals(DOFILTEREVENT_METHOD)) { return methodsCache[DOFILTEREVENT]; } return null; @@ -364,19 +304,18 @@ public final class SecurityUtil{ /** * Create the method and cache it for further re-use. - * @param methodsCache the cache used to store method instance - * @param targetType the class on which the method will be called. - * @param methodName the method to apply the security restriction - * @param parameterTypes <code>Class</code> array used to instantiate a - * <code>Method</code> object. + * + * @param methodsCache the cache used to store method instance + * @param targetType the class on which the method will be called. + * @param methodName the method to apply the security restriction + * @param parameterTypes <code>Class</code> array used to instantiate a <code>Method</code> object. + * * @return the method instance. + * * @throws Exception an execution error occurred */ - private static Method createMethodAndCacheIt(Method[] methodsCache, - Class<?> targetType, - String methodName, - Class<?>[] parameterTypes) - throws Exception { + private static Method createMethodAndCacheIt(Method[] methodsCache, Class<?> targetType, String methodName, + Class<?>[] parameterTypes) throws Exception { if (methodsCache == null) { methodsCache = new Method[4]; @@ -384,17 +323,17 @@ public final class SecurityUtil{ Method method = targetType.getMethod(methodName, parameterTypes); - if (methodName.equals(INIT_METHOD)){ + if (methodName.equals(INIT_METHOD)) { methodsCache[INIT] = method; - } else if (methodName.equals(DESTROY_METHOD)){ + } else if (methodName.equals(DESTROY_METHOD)) { methodsCache[DESTROY] = method; - } else if (methodName.equals(SERVICE_METHOD)){ + } else if (methodName.equals(SERVICE_METHOD)) { methodsCache[SERVICE] = method; - } else if (methodName.equals(DOFILTER_METHOD)){ + } else if (methodName.equals(DOFILTER_METHOD)) { methodsCache[DOFILTER] = method; - } else if (methodName.equals(EVENT_METHOD)){ + } else if (methodName.equals(EVENT_METHOD)) { methodsCache[EVENT] = method; - } else if (methodName.equals(DOFILTEREVENT_METHOD)){ + } else if (methodName.equals(DOFILTEREVENT_METHOD)) { methodsCache[DOFILTEREVENT] = method; } @@ -409,18 +348,18 @@ public final class SecurityUtil{ * * @param cachedObject The object to remove */ - public static void remove(Object cachedObject){ + public static void remove(Object cachedObject) { classCache.remove(cachedObject); } /** - * Return the <code>SecurityManager</code> only if Security is enabled AND - * package protection mechanism is enabled. + * Return the <code>SecurityManager</code> only if Security is enabled AND package protection mechanism is enabled. + * * @return <code>true</code> if package level protection is enabled */ - public static boolean isPackageProtectionEnabled(){ - if (packageDefinitionEnabled && Globals.IS_SECURITY_ENABLED){ + public static boolean isPackageProtectionEnabled() { + if (packageDefinitionEnabled && Globals.IS_SECURITY_ENABLED) { return true; } return false; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org