You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/04/30 10:10:51 UTC
[tomcat] branch 8.5.x updated: Fix indents (automated via Eclipse).
No functional change.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new ed56580 Fix indents (automated via Eclipse). No functional change.
ed56580 is described below
commit ed56580a50c8d3f09eb9b3152c8d7c9b8f58a283
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 30 11:10:39 2019 +0100
Fix indents (automated via Eclipse). No functional change.
---
java/org/apache/catalina/realm/JAASRealm.java | 406 +++++++++++++-------------
1 file changed, 203 insertions(+), 203 deletions(-)
diff --git a/java/org/apache/catalina/realm/JAASRealm.java b/java/org/apache/catalina/realm/JAASRealm.java
index 09216a4..3ea95c7 100644
--- a/java/org/apache/catalina/realm/JAASRealm.java
+++ b/java/org/apache/catalina/realm/JAASRealm.java
@@ -121,8 +121,8 @@ org.foobar.auth.DatabaseLoginModule REQUIRED
* prior to passing it back to the <code>LoginModule</code></li>
* </ul>
*
-* @author Craig R. McClanahan
-* @author Yoav Shapira
+ * @author Craig R. McClanahan
+ * @author Yoav Shapira
*/
public class JAASRealm extends RealmBase {
@@ -224,8 +224,8 @@ public class JAASRealm extends RealmBase {
* @param useContext True means use context ClassLoader
*/
public void setUseContextClassLoader(boolean useContext) {
- useContextClassLoader = useContext;
- log.info("Setting useContextClassLoader = " + useContext);
+ useContextClassLoader = useContext;
+ log.info("Setting useContextClassLoader = " + useContext);
}
/**
@@ -249,79 +249,79 @@ public class JAASRealm extends RealmBase {
}
}
- /**
- * Comma-delimited list of <code>java.security.Principal</code> classes
- * that represent security roles.
- */
- protected String roleClassNames = null;
-
- public String getRoleClassNames() {
- return (this.roleClassNames);
- }
-
- /**
- * Sets the list of comma-delimited classes that represent roles. The
- * classes in the list must implement <code>java.security.Principal</code>.
- * The supplied list of classes will be parsed when {@link #start()} is
- * called.
- * @param roleClassNames The class names list
- */
- public void setRoleClassNames(String roleClassNames) {
- this.roleClassNames = roleClassNames;
- }
-
- /**
- * Parses a comma-delimited list of class names, and store the class names
- * in the provided List. Each class must implement
- * <code>java.security.Principal</code>.
- *
- * @param classNamesString a comma-delimited list of fully qualified class names.
- * @param classNamesList the list in which the class names will be stored.
- * The list is cleared before being populated.
- */
- protected void parseClassNames(String classNamesString, List<String> classNamesList) {
- classNamesList.clear();
- if (classNamesString == null) return;
-
- ClassLoader loader = this.getClass().getClassLoader();
- if (isUseContextClassLoader())
- loader = Thread.currentThread().getContextClassLoader();
-
- String[] classNames = classNamesString.split("[ ]*,[ ]*");
- for (int i=0; i<classNames.length; i++) {
- if (classNames[i].length()==0) continue;
- try {
- Class<?> principalClass = Class.forName(classNames[i], false,
- loader);
- if (Principal.class.isAssignableFrom(principalClass)) {
- classNamesList.add(classNames[i]);
- } else {
- log.error("Class "+classNames[i]+" is not implementing "+
- "java.security.Principal! Class not added.");
- }
- } catch (ClassNotFoundException e) {
- log.error("Class "+classNames[i]+" not found! Class not added.");
- }
- }
- }
-
- /**
- * Comma-delimited list of <code>java.security.Principal</code> classes
- * that represent individual users.
- */
- protected String userClassNames = null;
-
- public String getUserClassNames() {
- return (this.userClassNames);
- }
-
- /**
- * Sets the list of comma-delimited classes that represent individual
- * users. The classes in the list must implement
- * <code>java.security.Principal</code>. The supplied list of classes will
- * be parsed when {@link #start()} is called.
- * @param userClassNames The class names list
- */
+ /**
+ * Comma-delimited list of <code>java.security.Principal</code> classes
+ * that represent security roles.
+ */
+ protected String roleClassNames = null;
+
+ public String getRoleClassNames() {
+ return (this.roleClassNames);
+ }
+
+ /**
+ * Sets the list of comma-delimited classes that represent roles. The
+ * classes in the list must implement <code>java.security.Principal</code>.
+ * The supplied list of classes will be parsed when {@link #start()} is
+ * called.
+ * @param roleClassNames The class names list
+ */
+ public void setRoleClassNames(String roleClassNames) {
+ this.roleClassNames = roleClassNames;
+ }
+
+ /**
+ * Parses a comma-delimited list of class names, and store the class names
+ * in the provided List. Each class must implement
+ * <code>java.security.Principal</code>.
+ *
+ * @param classNamesString a comma-delimited list of fully qualified class names.
+ * @param classNamesList the list in which the class names will be stored.
+ * The list is cleared before being populated.
+ */
+ protected void parseClassNames(String classNamesString, List<String> classNamesList) {
+ classNamesList.clear();
+ if (classNamesString == null) return;
+
+ ClassLoader loader = this.getClass().getClassLoader();
+ if (isUseContextClassLoader())
+ loader = Thread.currentThread().getContextClassLoader();
+
+ String[] classNames = classNamesString.split("[ ]*,[ ]*");
+ for (int i=0; i<classNames.length; i++) {
+ if (classNames[i].length()==0) continue;
+ try {
+ Class<?> principalClass = Class.forName(classNames[i], false,
+ loader);
+ if (Principal.class.isAssignableFrom(principalClass)) {
+ classNamesList.add(classNames[i]);
+ } else {
+ log.error("Class "+classNames[i]+" is not implementing "+
+ "java.security.Principal! Class not added.");
+ }
+ } catch (ClassNotFoundException e) {
+ log.error("Class "+classNames[i]+" not found! Class not added.");
+ }
+ }
+ }
+
+ /**
+ * Comma-delimited list of <code>java.security.Principal</code> classes
+ * that represent individual users.
+ */
+ protected String userClassNames = null;
+
+ public String getUserClassNames() {
+ return (this.userClassNames);
+ }
+
+ /**
+ * Sets the list of comma-delimited classes that represent individual
+ * users. The classes in the list must implement
+ * <code>java.security.Principal</code>. The supplied list of classes will
+ * be parsed when {@link #start()} is called.
+ * @param userClassNames The class names list
+ */
public void setUserClassNames(String userClassNames) {
this.userClassNames = userClassNames;
}
@@ -388,106 +388,106 @@ public class JAASRealm extends RealmBase {
// Establish a LoginContext to use for authentication
try {
- LoginContext loginContext = null;
- if( appName==null ) appName="Tomcat";
+ LoginContext loginContext = null;
+ if( appName==null ) appName="Tomcat";
- if( log.isDebugEnabled())
- log.debug(sm.getString("jaasRealm.beginLogin", username, appName));
+ if( log.isDebugEnabled())
+ log.debug(sm.getString("jaasRealm.beginLogin", username, appName));
- // What if the LoginModule is in the container class loader ?
- ClassLoader ocl = null;
+ // What if the LoginModule is in the container class loader ?
+ ClassLoader ocl = null;
- if (!isUseContextClassLoader()) {
- ocl = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
- this.getClass().getClassLoader());
- }
-
- try {
- Configuration config = getConfig();
- loginContext = new LoginContext(
- appName, null, callbackHandler, config);
- } catch (Throwable e) {
- ExceptionUtils.handleThrowable(e);
- log.error(sm.getString("jaasRealm.unexpectedError"), e);
- // There is configuration issue with JAAS so mark the realm as
- // unavailable
- invocationSuccess = false;
- return null;
- } finally {
- if(!isUseContextClassLoader()) {
- Thread.currentThread().setContextClassLoader(ocl);
+ if (!isUseContextClassLoader()) {
+ ocl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(
+ this.getClass().getClassLoader());
}
- }
- if( log.isDebugEnabled())
- log.debug("Login context created " + username);
+ try {
+ Configuration config = getConfig();
+ loginContext = new LoginContext(
+ appName, null, callbackHandler, config);
+ } catch (Throwable e) {
+ ExceptionUtils.handleThrowable(e);
+ log.error(sm.getString("jaasRealm.unexpectedError"), e);
+ // There is configuration issue with JAAS so mark the realm as
+ // unavailable
+ invocationSuccess = false;
+ return null;
+ } finally {
+ if(!isUseContextClassLoader()) {
+ Thread.currentThread().setContextClassLoader(ocl);
+ }
+ }
- // Negotiate a login via this LoginContext
- Subject subject = null;
- try {
- loginContext.login();
- subject = loginContext.getSubject();
- // We were able to perform login successfully so mark JAAS realm as
- // available as it could have been set to false in prior attempts.
- // Change invocationSuccess variable only when we know the outcome
- // of the JAAS operation to keep variable consistent.
- invocationSuccess = true;
- if (subject == null) {
- if( log.isDebugEnabled())
+ if( log.isDebugEnabled())
+ log.debug("Login context created " + username);
+
+ // Negotiate a login via this LoginContext
+ Subject subject = null;
+ try {
+ loginContext.login();
+ subject = loginContext.getSubject();
+ // We were able to perform login successfully so mark JAAS realm as
+ // available as it could have been set to false in prior attempts.
+ // Change invocationSuccess variable only when we know the outcome
+ // of the JAAS operation to keep variable consistent.
+ invocationSuccess = true;
+ if (subject == null) {
+ if( log.isDebugEnabled())
+ log.debug(sm.getString("jaasRealm.failedLogin", username));
+ return (null);
+ }
+ } catch (AccountExpiredException e) {
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("jaasRealm.accountExpired", username));
+ // JAAS checked LoginExceptions are successful authentication
+ // invocations so mark JAAS realm as available
+ invocationSuccess = true;
+ return null;
+ } catch (CredentialExpiredException e) {
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("jaasRealm.credentialExpired", username));
+ // JAAS checked LoginExceptions are successful authentication
+ // invocations so mark JAAS realm as available
+ invocationSuccess = true;
+ return null;
+ } catch (FailedLoginException e) {
+ if (log.isDebugEnabled())
log.debug(sm.getString("jaasRealm.failedLogin", username));
- return (null);
+ // JAAS checked LoginExceptions are successful authentication
+ // invocations so mark JAAS realm as available
+ invocationSuccess = true;
+ return null;
+ } catch (LoginException e) {
+ log.warn(sm.getString("jaasRealm.loginException", username), e);
+ // JAAS checked LoginExceptions are successful authentication
+ // invocations so mark JAAS realm as available
+ invocationSuccess = true;
+ return null;
+ } catch (Throwable e) {
+ ExceptionUtils.handleThrowable(e);
+ log.error(sm.getString("jaasRealm.unexpectedError"), e);
+ // JAAS throws exception different than LoginException so mark the
+ // realm as unavailable
+ invocationSuccess = false;
+ return null;
}
- } catch (AccountExpiredException e) {
- if (log.isDebugEnabled())
- log.debug(sm.getString("jaasRealm.accountExpired", username));
- // JAAS checked LoginExceptions are successful authentication
- // invocations so mark JAAS realm as available
- invocationSuccess = true;
- return null;
- } catch (CredentialExpiredException e) {
- if (log.isDebugEnabled())
- log.debug(sm.getString("jaasRealm.credentialExpired", username));
- // JAAS checked LoginExceptions are successful authentication
- // invocations so mark JAAS realm as available
- invocationSuccess = true;
- return null;
- } catch (FailedLoginException e) {
- if (log.isDebugEnabled())
- log.debug(sm.getString("jaasRealm.failedLogin", username));
- // JAAS checked LoginExceptions are successful authentication
- // invocations so mark JAAS realm as available
- invocationSuccess = true;
- return null;
- } catch (LoginException e) {
- log.warn(sm.getString("jaasRealm.loginException", username), e);
- // JAAS checked LoginExceptions are successful authentication
- // invocations so mark JAAS realm as available
- invocationSuccess = true;
- return null;
- } catch (Throwable e) {
- ExceptionUtils.handleThrowable(e);
- log.error(sm.getString("jaasRealm.unexpectedError"), e);
- // JAAS throws exception different than LoginException so mark the
- // realm as unavailable
- invocationSuccess = false;
- return null;
- }
- if( log.isDebugEnabled())
- log.debug(sm.getString("jaasRealm.loginContextCreated", username));
+ if( log.isDebugEnabled())
+ log.debug(sm.getString("jaasRealm.loginContextCreated", username));
- // Return the appropriate Principal for this authenticated Subject
- Principal principal = createPrincipal(username, subject, loginContext);
- if (principal == null) {
- log.debug(sm.getString("jaasRealm.authenticateFailure", username));
- return (null);
- }
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("jaasRealm.authenticateSuccess", username));
- }
+ // Return the appropriate Principal for this authenticated Subject
+ Principal principal = createPrincipal(username, subject, loginContext);
+ if (principal == null) {
+ log.debug(sm.getString("jaasRealm.authenticateFailure", username));
+ return (null);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("jaasRealm.authenticateSuccess", username));
+ }
- return (principal);
+ return (principal);
} catch( Throwable t) {
log.error( "error ", t);
//JAAS throws exception different than LoginException so mark the realm as unavailable
@@ -596,46 +596,46 @@ public class JAASRealm extends RealmBase {
loginContext);
}
- /**
- * Ensure the given name is legal for JAAS configuration.
- * Added for Bugzilla 30869, made protected for easy customization
- * in case my implementation is insufficient, which I think is
- * very likely.
- *
- * @param src The name to validate
- * @return A string that's a valid JAAS realm name
- */
- protected String makeLegalForJAAS(final String src) {
- String result = src;
-
- // Default name is "other" per JAAS spec
- if(result == null) {
- result = "other";
- }
-
- // Strip leading slash if present, as Sun JAAS impl
- // barfs on it (see Bugzilla 30869 bug report).
- if(result.startsWith("/")) {
- result = result.substring(1);
- }
-
- return result;
- }
+ /**
+ * Ensure the given name is legal for JAAS configuration.
+ * Added for Bugzilla 30869, made protected for easy customization
+ * in case my implementation is insufficient, which I think is
+ * very likely.
+ *
+ * @param src The name to validate
+ * @return A string that's a valid JAAS realm name
+ */
+ protected String makeLegalForJAAS(final String src) {
+ String result = src;
+
+ // Default name is "other" per JAAS spec
+ if(result == null) {
+ result = "other";
+ }
+
+ // Strip leading slash if present, as Sun JAAS impl
+ // barfs on it (see Bugzilla 30869 bug report).
+ if(result.startsWith("/")) {
+ result = result.substring(1);
+ }
+
+ return result;
+ }
// ------------------------------------------------------ Lifecycle Methods
- /**
- * Prepare for the beginning of active use of the public methods of this
- * component and implement the requirements of
- * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
- *
- * @exception LifecycleException if this component detects a fatal error
- * that prevents this component from being used
- */
- @Override
- protected void startInternal() throws LifecycleException {
+ /**
+ * Prepare for the beginning of active use of the public methods of this
+ * component and implement the requirements of
+ * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents this component from being used
+ */
+ @Override
+ protected void startInternal() throws LifecycleException {
// These need to be called after loading configuration, in case
// useContextClassLoader appears after them in xml config
@@ -643,7 +643,7 @@ public class JAASRealm extends RealmBase {
parseClassNames(roleClassNames, roleClasses);
super.startInternal();
- }
+ }
/**
@@ -665,7 +665,7 @@ public class JAASRealm extends RealmBase {
URI uri = resource.toURI();
@SuppressWarnings("unchecked")
Class<Configuration> sunConfigFile = (Class<Configuration>)
- Class.forName("com.sun.security.auth.login.ConfigFile");
+ Class.forName("com.sun.security.auth.login.ConfigFile");
Constructor<Configuration> constructor =
sunConfigFile.getConstructor(URI.class);
Configuration config = constructor.newInstance(uri);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org