Author: markt Date: Mon Nov 10 15:47:25 2014 New Revision: 1637893 URL: http://svn.apache.org/r1637893 Log: Use new utility method to obtain StringManager and remove the constant that is now unused. Move the statics to the start of the class. A small amount of whitespace clean-up
Modified: tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java tomcat/trunk/java/org/apache/catalina/authenticator/Constants.java Modified: tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java?rev=1637893&r1=1637892&r2=1637893&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java (original) +++ tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java Mon Nov 10 15:47:25 2014 @@ -70,19 +70,20 @@ import org.apache.tomcat.util.res.String * * @author Craig R. McClanahan */ -public abstract class AuthenticatorBase extends ValveBase - implements Authenticator { +public abstract class AuthenticatorBase extends ValveBase implements Authenticator { private static final Log log = LogFactory.getLog(AuthenticatorBase.class); + /** + * "Expires" header always set to Date(1), so generate once only + */ + private static final String DATE_ONE = (new SimpleDateFormat( + FastHttpDateFormat.RFC1123_DATE, Locale.US)).format(new Date(1)); - //------------------------------------------------------ Constructor - public AuthenticatorBase() { - super(true); - } - - // ----------------------------------------------------- Instance Variables - + /** + * The string manager for this package. + */ + protected static final StringManager sm = StringManager.getManager(AuthenticatorBase.class); /** * Authentication header @@ -94,6 +95,37 @@ public abstract class AuthenticatorBase */ protected static final String REALM_NAME = "Authentication required"; + + protected static String getRealmName(Context context) { + if (context == null) { + // Very unlikely + return REALM_NAME; + } + + LoginConfig config = context.getLoginConfig(); + if (config == null) { + return REALM_NAME; + } + + String result = config.getRealmName(); + if (result == null) { + return REALM_NAME; + } + + return result; + } + + + + //------------------------------------------------------ Constructor + + public AuthenticatorBase() { + super(true); + } + + + // ----------------------------------------------------- Instance Variables + /** * Should a session always be used once a user is authenticated? This may * offer some performance benefits since the session can then be used to @@ -171,50 +203,14 @@ public abstract class AuthenticatorBase protected SessionIdGeneratorBase sessionIdGenerator = null; /** - * The string manager for this package. - */ - protected static final StringManager sm = - StringManager.getManager(Constants.Package); - - - /** * The SingleSignOn implementation in our request processing chain, * if there is one. */ protected SingleSignOn sso = null; - /** - * "Expires" header always set to Date(1), so generate once only - */ - private static final String DATE_ONE = - (new SimpleDateFormat(FastHttpDateFormat.RFC1123_DATE, - Locale.US)).format(new Date(1)); - - - protected static String getRealmName(Context context) { - if (context == null) { - // Very unlikely - return REALM_NAME; - } - - LoginConfig config = context.getLoginConfig(); - if (config == null) { - return REALM_NAME; - } - - String result = config.getRealmName(); - if (result == null) { - return REALM_NAME; - } - - return result; - } - - // ------------------------------------------------------------- Properties - public boolean getAlwaysUseSession() { return alwaysUseSession; } @@ -229,9 +225,7 @@ public abstract class AuthenticatorBase * Return the cache authenticated Principals flag. */ public boolean getCache() { - - return (this.cache); - + return this.cache; } @@ -241,9 +235,7 @@ public abstract class AuthenticatorBase * @param cache The new cache flag */ public void setCache(boolean cache) { - this.cache = cache; - } @@ -252,9 +244,7 @@ public abstract class AuthenticatorBase */ @Override public Container getContainer() { - - return (this.context); - + return this.context; } @@ -401,7 +391,6 @@ public abstract class AuthenticatorBase // --------------------------------------------------------- Public Methods - /** * Enforce the security restrictions in the web application deployment * descriptor of our associated Context. Modified: tomcat/trunk/java/org/apache/catalina/authenticator/Constants.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/Constants.java?rev=1637893&r1=1637892&r2=1637893&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/authenticator/Constants.java (original) +++ tomcat/trunk/java/org/apache/catalina/authenticator/Constants.java Mon Nov 10 15:47:25 2014 @@ -20,9 +20,6 @@ package org.apache.catalina.authenticato public class Constants { - - public static final String Package = "org.apache.catalina.authenticator"; - // Authentication methods for login configuration // Servlet spec schemes are defined in HttpServletRequest // Vendor specific schemes --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org