Author: kfujino
Date: Wed Aug  3 01:34:02 2011
New Revision: 1153318

URL: http://svn.apache.org/viewvc?rev=1153318&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50771
Ensure HttpServletRequest#getAuthType() returns the name of the authentication 
scheme 
if request has already been authenticated.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java?rev=1153318&r1=1153317&r2=1153318&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java 
Wed Aug  3 01:34:02 2011
@@ -53,6 +53,7 @@ public class DeltaRequest implements Ext
     public static final int TYPE_PRINCIPAL = 1;
     public static final int TYPE_ISNEW = 2;
     public static final int TYPE_MAXINTERVAL = 3;
+    public static final int TYPE_AUTHTYPE = 4;
 
     public static final int ACTION_SET = 0;
     public static final int ACTION_REMOVE = 1;
@@ -60,6 +61,7 @@ public class DeltaRequest implements Ext
     public static final String NAME_PRINCIPAL = "__SET__PRINCIPAL__";
     public static final String NAME_MAXINTERVAL = "__SET__MAXINTERVAL__";
     public static final String NAME_ISNEW = "__SET__ISNEW__";
+    public static final String NAME_AUTHTYPE = "__SET__AUTHTYPE__";
 
     private String sessionId;
     private LinkedList actions = new LinkedList();
@@ -118,6 +120,11 @@ public class DeltaRequest implements Ext
         addAction(TYPE_ISNEW,action,NAME_ISNEW,new Boolean(n));
     }
 
+    public void setAuthType(String authType) {
+        int action = (authType==null)?ACTION_REMOVE:ACTION_SET;
+        addAction(TYPE_AUTHTYPE,action,NAME_AUTHTYPE, authType);
+    }
+
     protected void addAction(int type,
                              int action,
                              String name,
@@ -188,6 +195,14 @@ public class DeltaRequest implements Ext
                     session.setPrincipal(p,false);
                     break;
                 }//case
+                case TYPE_AUTHTYPE: {
+                    String authType = null;
+                    if ( info.getAction() == ACTION_SET ) {
+                        authType = (String)info.getValue();
+                    }
+                    session.setAuthType(authType,false);
+                    break;
+                }//case
                 default : throw new 
java.lang.IllegalArgumentException("Invalid attribute info type="+info);
             }//switch
         }//for

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java?rev=1153318&r1=1153317&r2=1153318&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java 
Wed Aug  3 01:34:02 2011
@@ -335,6 +335,28 @@ public class DeltaSession extends Standa
     }
 
     /**
+     * Set the authentication type used to authenticate our cached
+     * Principal, if any.
+     *
+     * @param authType The new cached authentication type
+     */
+    @Override
+    public void setAuthType(String authType) {
+        setAuthType(authType, true);
+    }
+
+    public void setAuthType(String authType, boolean addDeltaRequest) {
+        try { 
+            lock();
+            super.setAuthType(authType);
+            if (addDeltaRequest && (deltaRequest != null))
+                deltaRequest.setAuthType(authType);
+        } finally {
+            unlock();
+        }
+    }
+
+    /**
      * Return the <code>isValid</code> flag for this session.
      */
     public boolean isValid() {

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1153318&r1=1153317&r2=1153318&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Aug  3 01:34:02 2011
@@ -262,6 +262,11 @@
         (markt)
       </fix>
       <fix>
+        <bug>50771</bug>: Ensure HttpServletRequest#getAuthType() returns the 
+        name of the authentication scheme if request has already been 
+        authenticated. (kfujino)
+      </fix>
+      <fix>
         <bug>50950</bug>: Correct possible NotSerializableException for an
         authenticated session when running with a security manager. (markt)
       </fix>



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

Reply via email to