Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50771
authorkfujino <kfujino@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 14 Feb 2011 08:47:49 +0000 (08:47 +0000)
committerkfujino <kfujino@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 14 Feb 2011 08:47:49 +0000 (08:47 +0000)
Ensure HttpServletRequest#getAuthType() returns the name of the authentication scheme
if request has already been authenticated.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1070409 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/ha/session/DeltaRequest.java
java/org/apache/catalina/ha/session/DeltaSession.java
webapps/docs/changelog.xml

index 1cddf2b..6f02cdd 100644 (file)
@@ -53,6 +53,7 @@ public class DeltaRequest implements Externalizable {
     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 Externalizable {
     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<AttributeInfo> actions = new LinkedList<AttributeInfo>();
@@ -119,6 +121,11 @@ public class DeltaRequest implements Externalizable {
         addAction(TYPE_ISNEW,action,NAME_ISNEW,Boolean.valueOf(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,
@@ -185,6 +192,14 @@ public class DeltaRequest implements Externalizable {
                     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
index 2c271d5..161e784 100644 (file)
@@ -338,6 +338,28 @@ public class DeltaSession extends StandardSession implements Externalizable,Clus
     }
 
     /**
+     * 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.
      */
     @Override
index a9004ad..2b3b36d 100644 (file)
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Cluster">
+    <changelog>
+      <fix>
+        <bug>50771</bug>: Ensure HttpServletRequest#getAuthType() returns the 
+        name of the authentication scheme if request has already been 
+        authenticated. (kfujino)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Tribes">
     <changelog>
       <fix>