jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r786147 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication: AbstractLoginModule.java LocalAuthContext.java
Date Thu, 18 Jun 2009 16:22:15 GMT
Author: angela
Date: Thu Jun 18 16:22:15 2009
New Revision: 786147

URL: http://svn.apache.org/viewvc?rev=786147&view=rev
Log:
JCR-2087 Upgrade to Java 5 as the base platform
minor improvement


Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AbstractLoginModule.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/LocalAuthContext.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AbstractLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AbstractLoginModule.java?rev=786147&r1=786146&r2=786147&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AbstractLoginModule.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AbstractLoginModule.java
Thu Jun 18 16:22:15 2009
@@ -104,7 +104,7 @@
      * @see #isInitialized()
      */
     public void initialize(Subject subject, CallbackHandler callbackHandler,
-                           Map sharedState, Map options) {
+                           Map<String,?> sharedState, Map<String,?> options)
{
         // common jaas state variables
         this.callbackHandler = callbackHandler;
         this.subject = subject;
@@ -116,13 +116,16 @@
             RepositoryCallback repositoryCb = new RepositoryCallback();
             callbackHandler.handle(new Callback[]{repositoryCb});
 
-            // retrieve the principal-provider configured for this module.
-            // if not configured -> retrieve the provider from the callback.
             PrincipalProviderRegistry registry = repositoryCb.getPrincipalProviderRegistry();
+            // check if the class name of a PrincipalProvider implementation
+            // is present with the module configuration.
             if (options.containsKey(LoginModuleConfig.PARAM_PRINCIPAL_PROVIDER_CLASS)) {
-                principalProviderClassName = (String) options.get(LoginModuleConfig.PARAM_PRINCIPAL_PROVIDER_CLASS);
-                principalProvider = registry.getProvider(principalProviderClassName);
-            } else if (principalProviderClassName != null) {
+                Object pcOption = options.get(LoginModuleConfig.PARAM_PRINCIPAL_PROVIDER_CLASS);
+                if (pcOption != null) {
+                    principalProviderClassName = pcOption.toString();
+                }
+            }
+            if (principalProviderClassName != null) {
                 principalProvider = registry.getProvider(principalProviderClassName);
             }
             if (principalProvider == null) {
@@ -526,7 +529,9 @@
                     } else if (creds instanceof GuestCredentials) {
                        credentials = creds;
                     }
-                    sharedState.put(KEY_CREDENTIALS, credentials);
+                    if (credentials != null) {
+                        sharedState.put(KEY_CREDENTIALS, credentials);
+                    }
                 }
             } catch (UnsupportedCallbackException e) {
                 log.warn("Credentials-Callback not supported try Name-Callback");
@@ -534,7 +539,7 @@
                 log.error("Credentials-Callback failed: " + e.getMessage() + ": try Name-Callback");
             }
         }
-        // ask subject if still no credentials
+        // if still no credentials -> try to retrieve them from the subject.
         if (null == credentials) {
             // try if subject contains SimpleCredentials
             Set<SimpleCredentials> preAuthCreds = subject.getPublicCredentials(SimpleCredentials.class);
@@ -542,6 +547,13 @@
                 credentials = preAuthCreds.iterator().next();
             }
         }
+        if (null == credentials) {
+            // try if subject contains GuestCredentials
+            Set<GuestCredentials> preAuthCreds = subject.getPublicCredentials(GuestCredentials.class);
+            if (!preAuthCreds.isEmpty()) {
+                credentials = preAuthCreds.iterator().next();
+            }
+        }
         return credentials;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/LocalAuthContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/LocalAuthContext.java?rev=786147&r1=786146&r2=786147&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/LocalAuthContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/LocalAuthContext.java
Thu Jun 18 16:22:15 2009
@@ -72,7 +72,7 @@
             throw new LoginException(e.getMessage());
         }
 
-        Map<String, String> state = new HashMap<String, String>();
+        Map<String, Object> state = new HashMap<String, Object>();
         Map<String, String> options = new HashMap<String, String>();
         Properties parameters = config.getParameters();
         Enumeration< ? > names = parameters.propertyNames();



Mime
View raw message