jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r811100 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/
Date Thu, 03 Sep 2009 20:10:04 GMT
Author: tripod
Date: Thu Sep  3 20:10:04 2009
New Revision: 811100

URL: http://svn.apache.org/viewvc?rev=811100&view=rev
Log:
Use Java 1.5 and Generics

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/AuthContext.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CallbackHandlerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CryptedSimpleCredentials.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/DefaultLoginModule.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/JAASAuthContext.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=811100&r1=811099&r2=811100&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 Sep  3 20:10:04 2009
@@ -16,13 +16,11 @@
  */
 package org.apache.jackrabbit.core.security.authentication;
 
-import org.apache.commons.collections.set.ListOrderedSet;
-import org.apache.jackrabbit.core.config.LoginModuleConfig;
-import org.apache.jackrabbit.core.security.SecurityConstants;
-import org.apache.jackrabbit.core.security.principal.PrincipalProvider;
-import org.apache.jackrabbit.core.security.principal.PrincipalProviderRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.security.Principal;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
 
 import javax.jcr.Credentials;
 import javax.jcr.GuestCredentials;
@@ -37,11 +35,14 @@
 import javax.security.auth.login.FailedLoginException;
 import javax.security.auth.login.LoginException;
 import javax.security.auth.spi.LoginModule;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+
+import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
+import org.apache.jackrabbit.core.config.LoginModuleConfig;
+import org.apache.jackrabbit.core.security.SecurityConstants;
+import org.apache.jackrabbit.core.security.principal.PrincipalProvider;
+import org.apache.jackrabbit.core.security.principal.PrincipalProviderRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>AbstractLoginModule</code> provides the means for the common
@@ -156,11 +157,8 @@
 
             //log config values for debug
             if (log.isDebugEnabled()) {
-                Iterator itr = options.keySet().iterator();
-                while (itr.hasNext()) {
-                    String option = (String) itr.next();
-                    log.debug("- Option: "+ option +" -> '"+ options.get(option) +"'");
-
+                for (String option : options.keySet()) {
+                    log.debug("- Option: " + option + " -> '" + options.get(option) +
"'");
                 }
             }
             initialized = (this.subject != null);
@@ -339,7 +337,7 @@
             return false;
         }
 
-        Set principals = getPrincipals();
+        Set<Principal> principals = getPrincipals();
         subject.getPrincipals().addAll(principals);
         subject.getPublicCredentials().add(credentials);
         return true;
@@ -641,14 +639,14 @@
      * @return a Collection of principals that contains the current user
      * principal and all groups it is member of.
      */
-    protected Set getPrincipals() {
-        // use ListOrderedSet instead of Hashset in order to maintain the order
+    protected Set<Principal> getPrincipals() {
+        // use linked HashSet instead of HashSet in order to maintain the order
         // of principals (as in the Subject).
-        Set principals = new ListOrderedSet();
+        Set<Principal> principals = new LinkedHashSet<Principal>();
         principals.add(principal);
-        Iterator groups = principalProvider.getGroupMembership(principal);
+        PrincipalIterator groups = principalProvider.getGroupMembership(principal);
         while (groups.hasNext()) {
-            principals.add(groups.next());
+            principals.add(groups.nextPrincipal());
         }
         return principals;
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContext.java?rev=811100&r1=811099&r2=811100&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContext.java
Thu Sep  3 20:10:04 2009
@@ -30,13 +30,13 @@
  *       JAAS <code>LoginModule</code></li>
  * </ul>
  */
-public abstract interface AuthContext {
+public interface AuthContext {
 
     /**
      * Perform the authentication and, if successful, associate Principals and Credentials
      * with the authenticated<code>Subject</code>.
      *
-     * @see LoginContext#login()
+     * @see javax.security.auth.login.LoginContext#login()
      * @throws LoginException if the authentication fails.
      */
     void login() throws LoginException;
@@ -44,7 +44,7 @@
     /**
      * Return the authenticated Subject.
      *
-     * @see LoginContext#getSubject()
+     * @see javax.security.auth.login.LoginContext#getSubject()
      * @return the authenticated Subject or <code>null</code> if authentication
failed.
      */
     Subject getSubject();
@@ -52,8 +52,8 @@
     /**
      * Logout the <code>Subject</code>.
      *
-     * @see LoginContext#logout()
-     * @exception LoginException if the logout fails.
+     * @see javax.security.auth.login.LoginContext#logout()
+     * @throws LoginException if the logout fails.
      */
     void logout() throws LoginException;
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java?rev=811100&r1=811099&r2=811100&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/AuthContextProvider.java
Thu Sep  3 20:10:04 2009
@@ -134,8 +134,8 @@
             AppConfigurationEntry[] entries = getJAASConfig();
             if (entries != null) {
                 List<Properties> tmp = new ArrayList<Properties>(entries.length);
-                for (int i = 0; i < entries.length; i++) {
-                    Map opt = entries[i].getOptions();
+                for (AppConfigurationEntry entry : entries) {
+                    Map opt = entry.getOptions();
                     if (opt != null) {
                         Properties prop = new Properties();
                         prop.putAll(opt);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CallbackHandlerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CallbackHandlerImpl.java?rev=811100&r1=811099&r2=811100&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CallbackHandlerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CallbackHandlerImpl.java
Thu Sep  3 20:10:04 2009
@@ -82,9 +82,7 @@
      */
     public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
 
-        for (int i = 0; i < callbacks.length; i++) {
-            Callback callback = callbacks[i];
-
+        for (Callback callback : callbacks) {
             if (callback instanceof CredentialsCallback) {
                 ((CredentialsCallback) callback).setCredentials(credentials);
             } else if (callback instanceof RepositoryCallback) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CryptedSimpleCredentials.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CryptedSimpleCredentials.java?rev=811100&r1=811099&r2=811100&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CryptedSimpleCredentials.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/CryptedSimpleCredentials.java
Thu Sep  3 20:10:04 2009
@@ -69,8 +69,8 @@
 
         String[] attNames = credentials.getAttributeNames();
         attributes = new HashMap<String, Object>(attNames.length);
-        for (int i = 0; i < attNames.length; i++) {
-            attributes.put(attNames[i], credentials.getAttribute(attNames[i]));
+        for (String attName : attNames) {
+            attributes.put(attName, credentials.getAttribute(attName));
         }
     }
 
@@ -89,7 +89,7 @@
             algorithm = algo;
             cryptedPassword = password;
         }
-        attributes = Collections.EMPTY_MAP;
+        attributes = Collections.emptyMap();
     }
 
     public String getUserID() {
@@ -134,7 +134,7 @@
                 // uncrypted pw to match -> crypt with algorithm present here.
                 return crypt(toMatch, algorithm).equals(cryptedPassword);
             } else if (algr != null && algorithm == null) {
-                // crypted pw to match but unkown algorithm here -> crypt this pw
+                // crypted pw to match but unknown algorithm here -> crypt this pw
                 return crypt(algr, cryptedPassword).equals(toMatch);
             }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/DefaultLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/DefaultLoginModule.java?rev=811100&r1=811099&r2=811100&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/DefaultLoginModule.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/DefaultLoginModule.java
Thu Sep  3 20:10:04 2009
@@ -105,7 +105,7 @@
                 return authentication;
             }
         }
-        // no valid user or authencation could not handle the given creds.
+        // no valid user or authentication could not handle the given credentials
         return null;
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/JAASAuthContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/JAASAuthContext.java?rev=811100&r1=811099&r2=811100&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/JAASAuthContext.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authentication/JAASAuthContext.java
Thu Sep  3 20:10:04 2009
@@ -50,7 +50,7 @@
                 context = new LoginContext(appName, subject, cbHandler);
             }
         } catch (LoginException e) {
-            //all caseses it is thrown are checked -> ignore
+            //all cases it is thrown are checked -> ignore
         } finally {
             current.setContextClassLoader(orig);
         }



Mime
View raw message