Author: fmeschbe
Date: Thu Aug 12 13:52:24 2010
New Revision: 984778

URL: http://svn.apache.org/viewvc?rev=984778&view=rev
Log:
SLING-1647 Set handler specific properties in the AuthenticationInfo instead of 
the credentials. The properties will be transferred to the session by the 
ResourceResolverFactory implementation

Modified:
    
sling/trunk/bundles/extensions/formauth/src/main/java/org/apache/sling/formauth/impl/FormAuthenticationHandler.java
    
sling/trunk/bundles/extensions/openidauth/src/main/java/org/apache/sling/openidauth/impl/OpenIDAuthenticationHandler.java

Modified: 
sling/trunk/bundles/extensions/formauth/src/main/java/org/apache/sling/formauth/impl/FormAuthenticationHandler.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/formauth/src/main/java/org/apache/sling/formauth/impl/FormAuthenticationHandler.java?rev=984778&r1=984777&r2=984778&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/formauth/src/main/java/org/apache/sling/formauth/impl/FormAuthenticationHandler.java
 (original)
+++ 
sling/trunk/bundles/extensions/formauth/src/main/java/org/apache/sling/formauth/impl/FormAuthenticationHandler.java
 Thu Aug 12 13:52:24 2010
@@ -592,7 +592,7 @@ public class FormAuthenticationHandler e
             final AuthenticationInfo authInfo) {
 
         // get current authentication data, may be missing after first login
-        String authData = 
getCookieAuthData((Credentials)authInfo.get(AuthenticationInfo.CREDENTIALS));
+        String authData = getCookieAuthData(authInfo);
 
         // check whether we have to "store" or create the data
         final boolean refreshCookie = needsRefresh(authData,
@@ -660,17 +660,21 @@ public class FormAuthenticationHandler e
             return null;
         }
 
-        final SimpleCredentials cookieAuthCredentials = new SimpleCredentials(
-            userId, new char[0]);
-        cookieAuthCredentials.setAttribute(attrCookieAuthData, authData);
-
         final AuthenticationInfo info = new AuthenticationInfo(
             HttpServletRequest.FORM_AUTH, userId);
-        info.put(AuthenticationInfo.CREDENTIALS, cookieAuthCredentials);
+        info.put(attrCookieAuthData, authData);
 
         return info;
     }
 
+    private String getCookieAuthData(final AuthenticationInfo info) {
+        Object data = info.get(attrCookieAuthData);
+        if (data instanceof String) {
+            return (String) data;
+        }
+        return null;
+    }
+
     // ---------- LoginModulePlugin support
 
     private String getCookieAuthData(final Credentials credentials) {

Modified: 
sling/trunk/bundles/extensions/openidauth/src/main/java/org/apache/sling/openidauth/impl/OpenIDAuthenticationHandler.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/openidauth/src/main/java/org/apache/sling/openidauth/impl/OpenIDAuthenticationHandler.java?rev=984778&r1=984777&r2=984778&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/openidauth/src/main/java/org/apache/sling/openidauth/impl/OpenIDAuthenticationHandler.java
 (original)
+++ 
sling/trunk/bundles/extensions/openidauth/src/main/java/org/apache/sling/openidauth/impl/OpenIDAuthenticationHandler.java
 Thu Aug 12 13:52:24 2010
@@ -652,28 +652,19 @@ public class OpenIDAuthenticationHandler
     }
 
     private AuthenticationInfo getAuthInfoFromUser(final OpenIdUser user) {
-        final SimpleCredentials credentials = getCredentials(user);
         final AuthenticationInfo info = new AuthenticationInfo(
-            OpenIDConstants.OPENID_AUTH, credentials.getUserID());
-        info.put(AuthenticationInfo.CREDENTIALS, credentials);
-        return info;
-    }
-
-    private SimpleCredentials getCredentials(final OpenIdUser user) {
-        final String userName = getUserName(user);
-        final SimpleCredentials creds = new SimpleCredentials(userName,
-            new char[0]);
+            OpenIDConstants.OPENID_AUTH, getUserName(user));
 
         // if there is no login module plugin service, set the credentials
         // attribute to the user's OpenID identity, otherwise set it to
         // the actual OpenIDUser object
         if (loginModule == null) {
-            creds.setAttribute(openIdAttribute, user.getIdentity());
+            info.put(openIdAttribute, user.getIdentity());
         } else {
-            creds.setAttribute(openIdAttribute, user);
+            info.put(openIdAttribute, user);
         }
 
-        return creds;
+        return info;
     }
 
     OpenIdUser getOpenIdUser(final Credentials credentials) {


Reply via email to