continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r440238 - /maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsService.java
Date Tue, 05 Sep 2006 03:32:25 GMT
Author: carlos
Date: Mon Sep  4 20:32:24 2006
New Revision: 440238

URL: http://svn.apache.org/viewvc?view=rev&rev=440238
Log:
Handle guest user, add it ROLE_ANONYMOUS

Modified:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsService.java

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsService.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsService.java?view=diff&rev=440238&r1=440237&r2=440238
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsService.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/ContinuumUserDetailsService.java
Mon Sep  4 20:32:24 2006
@@ -17,6 +17,7 @@
  *
  */
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -79,15 +80,23 @@
     {
         List permissions = user.getGroup().getPermissions();
 
-        GrantedAuthority[] grantedAuthorities = new GrantedAuthority[permissions.size()];
-        int i = 0;
+        List grantedAuthorities = new ArrayList( permissions.size() + 1 );
         Iterator it = permissions.iterator();
         while ( it.hasNext() )
         {
             Permission permission = (Permission) it.next();
-            grantedAuthorities[i] = new GrantedAuthorityImpl( "ROLE_" + permission.getName()
);
-            i++;
+            grantedAuthorities.add( new GrantedAuthorityImpl( "ROLE_" + permission.getName()
) );
         }
+
+        if ( user.isGuest() )
+        {
+            // TODO externalize this String
+            grantedAuthorities.add( new GrantedAuthorityImpl( "ROLE_ANONYMOUS" ) );
+        }
+
+        GrantedAuthority[] grantedAuthoritiesAsArray = (GrantedAuthority[]) grantedAuthorities
+            .toArray( new GrantedAuthority[0] );
+
         String username = user.getUsername();
         String password = user.getEncodedPassword();
         boolean enabled = true;
@@ -105,7 +114,7 @@
 
         UserDetails userDetails = new org.acegisecurity.userdetails.User( username, password,
enabled,
                                                                           accountNonExpired,
credentialsNonExpired,
-                                                                          accountNonLocked,
grantedAuthorities );
+                                                                          accountNonLocked,
grantedAuthoritiesAsArray );
 
         return userDetails;
     }



Mime
View raw message