From db15b78bc0ccda9c9c8a43a71fb128a1b066693c Mon Sep 17 00:00:00 2001 From: kfujino Date: Mon, 14 Feb 2011 08:47:49 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1070409 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/ha/session/DeltaRequest.java | 15 +++++++++++++++ .../apache/catalina/ha/session/DeltaSession.java | 22 ++++++++++++++++++++++ webapps/docs/changelog.xml | 9 +++++++++ 3 files changed, 46 insertions(+) diff --git a/java/org/apache/catalina/ha/session/DeltaRequest.java b/java/org/apache/catalina/ha/session/DeltaRequest.java index 1cddf2be5..6f02cdd09 100644 --- a/java/org/apache/catalina/ha/session/DeltaRequest.java +++ b/java/org/apache/catalina/ha/session/DeltaRequest.java @@ -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 actions = new LinkedList(); @@ -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 diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java b/java/org/apache/catalina/ha/session/DeltaSession.java index 2c271d5f0..161e7848f 100644 --- a/java/org/apache/catalina/ha/session/DeltaSession.java +++ b/java/org/apache/catalina/ha/session/DeltaSession.java @@ -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 isValid flag for this session. */ @Override diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index a9004adeb..2b3b36d08 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -100,6 +100,15 @@ + + + + 50771: Ensure HttpServletRequest#getAuthType() returns the + name of the authentication scheme if request has already been + authenticated. (kfujino) + + + -- 2.11.0