Author: markt
Date: Mon Feb  6 20:32:36 2012
New Revision: 1241162

URL: http://svn.apache.org/viewvc?rev=1241162&view=rev
Log:
Remove deprecated code. Simplify.

Modified:
    tomcat/trunk/java/org/apache/catalina/Authenticator.java
    tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java
    tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java
    tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
    tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java
    
tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
    tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java
    tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
    
tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java

Modified: tomcat/trunk/java/org/apache/catalina/Authenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Authenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Authenticator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Authenticator.java Mon Feb  6 
20:32:36 2012
@@ -14,8 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.catalina;
 
 import java.io.IOException;
@@ -24,7 +22,6 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.LoginConfig;
 
 
 /**
@@ -34,7 +31,6 @@ import org.apache.catalina.deploy.LoginC
  * @author Craig R. McClanahan
  * @version $Id$
  */
-
 public interface Authenticator {
 
     /**
@@ -52,27 +48,6 @@ public interface Authenticator {
     public boolean authenticate(Request request, HttpServletResponse response)
             throws IOException;
 
-    /**
-     * Authenticate the user making this request, based on the specified
-     * login configuration.  Return <code>true</code> if any specified
-     * constraint has been satisfied, or <code>false</code> if we have
-     * created a response challenge already.
-     *
-     * @param request Request we are processing
-     * @param response Response we are populating
-     * @param config    Login configuration describing how authentication
-     *              should be performed
-     *
-     * @exception IOException if an input/output error occurs
-     *
-     * @deprecated  Use {@link #authenticate(Request, HttpServletResponse)}.
-     *              This will be removed / have reduced visibility in Tomcat
-     *              8.0.x
-     */
-    @Deprecated
-    public boolean authenticate(Request request, HttpServletResponse response,
-            LoginConfig config) throws IOException;
-
     public void login(String userName, String password, Request request)
             throws ServletException;
 

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=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/AuthenticatorBase.java 
Mon Feb  6 20:32:36 2012
@@ -14,11 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.catalina.authenticator;
 
-
 import java.io.IOException;
 import java.security.Principal;
 import java.security.cert.X509Certificate;
@@ -193,6 +190,26 @@ public abstract class AuthenticatorBase 
                               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
 
 
@@ -401,7 +418,6 @@ public abstract class AuthenticatorBase 
             log.debug("Security checking request " +
                 request.getMethod() + " " + request.getRequestURI());
         }
-        LoginConfig config = this.context.getLoginConfig();
 
         // Have we got a cached authenticated Principal to record?
         if (cache) {
@@ -431,7 +447,7 @@ public abstract class AuthenticatorBase 
         String requestURI = request.getDecodedRequestURI();
         if (requestURI.startsWith(contextPath) &&
             requestURI.endsWith(Constants.FORM_ACTION)) {
-            if (!authenticate(request, response, config)) {
+            if (!authenticate(request, response)) {
                 if (log.isDebugEnabled()) {
                     log.debug(" Failed authenticate() test ??" + requestURI );
                 }
@@ -527,7 +543,7 @@ public abstract class AuthenticatorBase 
             if (log.isDebugEnabled()) {
                 log.debug(" Calling authenticate()");
             }
-            if (!authenticate(request, response, config)) {
+            if (!authenticate(request, response)) {
                 if (log.isDebugEnabled()) {
                     log.debug(" Failed authenticate() test");
                 }
@@ -602,32 +618,8 @@ public abstract class AuthenticatorBase 
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public boolean authenticate(Request request, HttpServletResponse response)
-            throws IOException {
-        if (context == null || context.getLoginConfig() == null) {
-            return true;
-        }
-        return authenticate(request, response, context.getLoginConfig());
-    }
-
-    /**
-     * Authenticate the user making this request, based on the specified
-     * login configuration.  Return <code>true</code> if any specified
-     * constraint has been satisfied, or <code>false</code> if we have
-     * created a response challenge already.
-     *
-     * @param request Request we are processing
-     * @param response Response we are populating
-     * @param config    Login configuration describing how authentication
-     *              should be performed
-     *
-     * @exception IOException if an input/output error occurs
-     */
-    @Override
     public abstract boolean authenticate(Request request,
-                                            HttpServletResponse response,
-                                            LoginConfig config)
-        throws IOException;
+            HttpServletResponse response) throws IOException;
 
 
     /**

Modified: 
tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/BasicAuthenticator.java 
Mon Feb  6 20:32:36 2012
@@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.util.Base64;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -60,16 +59,12 @@ public class BasicAuthenticator
      *
      * @param request Request we are processing
      * @param response Response we are creating
-     * @param config    Login configuration describing how authentication
-     *              should be performed
      *
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public boolean authenticate(Request request,
-                                HttpServletResponse response,
-                                LoginConfig config)
-        throws IOException {
+    public boolean authenticate(Request request, HttpServletResponse response)
+            throws IOException {
 
         // Have we already authenticated someone?
         Principal principal = request.getUserPrincipal();
@@ -145,11 +140,7 @@ public class BasicAuthenticator
 
         StringBuilder value = new StringBuilder(16);
         value.append("Basic realm=\"");
-        if (config.getRealmName() == null) {
-            value.append(REALM_NAME);
-        } else {
-            value.append(config.getRealmName());
-        }
+        value.append(getRealmName(context));
         value.append('\"');
         response.setHeader(AUTH_HEADER_NAME, value.toString());
         response.sendError(HttpServletResponse.SC_UNAUTHORIZED);

Modified: 
tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java 
(original)
+++ 
tomcat/trunk/java/org/apache/catalina/authenticator/DigestAuthenticator.java 
Mon Feb  6 20:32:36 2012
@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletRes
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.Realm;
 import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.util.MD5Encoder;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -193,16 +192,12 @@ public class DigestAuthenticator extends
      *
      * @param request Request we are processing
      * @param response Response we are creating
-     * @param config    Login configuration describing how authentication
-     *              should be performed
      *
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public boolean authenticate(Request request,
-                                HttpServletResponse response,
-                                LoginConfig config)
-        throws IOException {
+    public boolean authenticate(Request request, HttpServletResponse response)
+            throws IOException {
 
         // Have we already authenticated someone?
         Principal principal = request.getUserPrincipal();
@@ -250,7 +245,7 @@ public class DigestAuthenticator extends
         DigestInfo digestInfo = new DigestInfo(getOpaque(), getNonceValidity(),
                 getKey(), cnonces, isValidateUri());
         if (authorization != null) {
-            if (digestInfo.validate(request, authorization, config)) {
+            if (digestInfo.validate(request, authorization)) {
                 principal = digestInfo.authenticate(context.getRealm());
             }
 
@@ -268,7 +263,7 @@ public class DigestAuthenticator extends
         // to be unique).
         String nonce = generateNonce(request);
 
-        setAuthenticateHeader(request, response, config, nonce,
+        setAuthenticateHeader(request, response, nonce,
                 digestInfo.isNonceStale());
         response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
         //      hres.flushBuffer();
@@ -398,21 +393,14 @@ public class DigestAuthenticator extends
      *
      * @param request HTTP Servlet request
      * @param response HTTP Servlet response
-     * @param config    Login configuration describing how authentication
-     *              should be performed
      * @param nonce nonce token
      */
     protected void setAuthenticateHeader(HttpServletRequest request,
                                          HttpServletResponse response,
-                                         LoginConfig config,
                                          String nonce,
                                          boolean isNonceStale) {
 
-        // Get the realm name
-        String realmName = config.getRealmName();
-        if (realmName == null) {
-            realmName = REALM_NAME;
-        }
+        String realmName = getRealmName(context);
 
         String authenticateHeader;
         if (isNonceStale) {
@@ -504,8 +492,7 @@ public class DigestAuthenticator extends
             this.validateUri = validateUri;
         }
 
-        public boolean validate(Request request, String authorization,
-                LoginConfig config) {
+        public boolean validate(Request request, String authorization) {
             // Validate the authorization credentials format
             if (authorization == null) {
                 return false;
@@ -584,10 +571,7 @@ public class DigestAuthenticator extends
             }
 
             // Validate the Realm name
-            String lcRealm = config.getRealmName();
-            if (lcRealm == null) {
-                lcRealm = REALM_NAME;
-            }
+            String lcRealm = getRealmName(request.getContext());
             if (!lcRealm.equals(realmName)) {
                 return false;
             }

Modified: 
tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/FormAuthenticator.java 
Mon Feb  6 20:32:36 2012
@@ -14,11 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-
 package org.apache.catalina.authenticator;
 
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.Principal;
@@ -44,7 +41,6 @@ import org.apache.tomcat.util.buf.CharCh
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.http.MimeHeaders;
 
-
 /**
  * An <b>Authenticator</b> and <b>Valve</b> implementation of FORM BASED
  * Authentication, as described in the Servlet API Specification, Version 2.2.
@@ -122,16 +118,12 @@ public class FormAuthenticator
      *
      * @param request Request we are processing
      * @param response Response we are creating
-     * @param config    Login configuration describing how authentication
-     *              should be performed
      *
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public boolean authenticate(Request request,
-                                HttpServletResponse response,
-                                LoginConfig config)
-        throws IOException {
+    public boolean authenticate(Request request, HttpServletResponse response)
+            throws IOException {
 
         // References to objects we will need later
         Session session = null;
@@ -245,6 +237,8 @@ public class FormAuthenticator
             requestURI.startsWith(contextPath) &&
             requestURI.endsWith(Constants.FORM_ACTION);
 
+        LoginConfig config = context.getLoginConfig();
+
         // No -- Save this request and redirect to the form login page
         if (!loginAction) {
             session = request.getSessionInternal(true);

Modified: 
tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java 
(original)
+++ 
tomcat/trunk/java/org/apache/catalina/authenticator/NonLoginAuthenticator.java 
Mon Feb  6 20:32:36 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.catalina.authenticator;
 
-
 import java.io.IOException;
 import java.security.Principal;
 
@@ -24,9 +23,6 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.catalina.Session;
 import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.LoginConfig;
-
-
 
 /**
  * An <b>Authenticator</b> and <b>Valve</b> implementation that checks
@@ -77,15 +73,11 @@ public final class NonLoginAuthenticator
      *
      * @param request  Request we are processing
      * @param response Response we are creating
-     * @param config   Login configuration describing how authentication
-     *                 should be performed
      * @return boolean to indicate whether the user is authenticated
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public boolean authenticate(Request request,
-                                HttpServletResponse response,
-                                LoginConfig config)
+    public boolean authenticate(Request request, HttpServletResponse response)
         throws IOException {
 
         Principal principal = request.getUserPrincipal();

Modified: 
tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/authenticator/SSLAuthenticator.java 
Mon Feb  6 20:32:36 2012
@@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.catalina.Globals;
 import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.LoginConfig;
 import org.apache.coyote.ActionCode;
 
 /**
@@ -46,16 +45,12 @@ public class SSLAuthenticator extends Au
      *
      * @param request Request we are processing
      * @param response Response we are creating
-     * @param config    Login configuration describing how authentication
-     *              should be performed
      *
      * @exception IOException if an input/output error occurs
      */
     @Override
-    public boolean authenticate(Request request,
-                                HttpServletResponse response,
-                                LoginConfig config)
-        throws IOException {
+    public boolean authenticate(Request request, HttpServletResponse response)
+            throws IOException {
 
         // Have we already authenticated someone?
         Principal principal = request.getUserPrincipal();

Modified: 
tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- 
tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java 
(original)
+++ 
tomcat/trunk/java/org/apache/catalina/authenticator/SpnegoAuthenticator.java 
Mon Feb  6 20:32:36 2012
@@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.util.Base64;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -107,8 +106,8 @@ public class SpnegoAuthenticator extends
 
 
     @Override
-    public boolean authenticate(Request request, HttpServletResponse response,
-            LoginConfig config) throws IOException {
+    public boolean authenticate(Request request, HttpServletResponse response)
+            throws IOException {
 
         // Have we already authenticated someone?
         Principal principal = request.getUserPrincipal();

Modified: 
tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java?rev=1241162&r1=1241161&r2=1241162&view=diff
==============================================================================
--- 
tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
 (original)
+++ 
tomcat/trunk/test/org/apache/catalina/authenticator/TesterDigestAuthenticatorPerformance.java
 Mon Feb  6 20:32:36 2012
@@ -110,6 +110,11 @@ public class TesterDigestAuthenticatorPe
         context.setName(CONTEXT_PATH);
         context.setRealm(realm);
 
+        // Configure the Login config
+        LoginConfig config = new LoginConfig();
+        config.setRealmName(REALM);
+        context.setLoginConfig(config);
+
         // Make the Context and Realm visible to the Authenticator
         authenticator.setContainer(context);
 
@@ -129,7 +134,6 @@ public class TesterDigestAuthenticatorPe
 
         private TesterDigestRequest request;
         private HttpServletResponse response;
-        private LoginConfig config;
 
         // All init code should be in here. run() needs to be quick
         public TesterRunnable(int requestCount) throws Exception {
@@ -138,11 +142,9 @@ public class TesterDigestAuthenticatorPe
             request = new TesterDigestRequest();
             String nonce = authenticator.generateNonce(request);
             request.setAuthHeader(buildDigestResponse(nonce));
+            request.setContext(authenticator.context);
 
             response = new TesterResponse();
-
-            config = new LoginConfig();
-            config.setRealmName(REALM);
         }
 
         @Override
@@ -150,7 +152,7 @@ public class TesterDigestAuthenticatorPe
             long start = System.currentTimeMillis();
             for (int i = 0; i < requestCount; i++) {
                 try {
-                    if (authenticator.authenticate(request, response, config)) 
{
+                    if (authenticator.authenticate(request, response)) {
                         success++;
                     }
                 } catch (IOException ioe) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to