continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r420650 - /maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
Date Mon, 10 Jul 2006 23:07:20 GMT
Author: carlos
Date: Mon Jul 10 16:07:19 2006
New Revision: 420650

URL: http://svn.apache.org/viewvc?rev=420650&view=rev
Log:
[CONTINUUM-764] Implement getUserDetails(ContinuumUser)

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

Modified: maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java?rev=420650&r1=420649&r2=420650&view=diff
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
Mon Jul 10 16:07:19 2006
@@ -17,12 +17,18 @@
  *
  */
 
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.GrantedAuthorityImpl;
+import org.acegisecurity.userdetails.User;
 import org.acegisecurity.userdetails.UserDetails;
 import org.acegisecurity.userdetails.UserDetailsService;
 import org.acegisecurity.userdetails.UsernameNotFoundException;
 import org.apache.maven.continuum.model.system.ContinuumUser;
+import org.apache.maven.continuum.model.system.Permission;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.security.Authentication;
@@ -125,9 +131,25 @@
      */
     private UserDetails getUserDetails( ContinuumUser user )
     {
-        UserDetails userDetails = null;
-        //TODO
-        //new User( user.getUsername(), user.getPassword(),...);
+        List permissions = user.getGroup().getPermissions();
+
+        GrantedAuthority[] grantedAuthorities = new GrantedAuthority[permissions.size()];
+        int i = 0;
+        Iterator it = permissions.iterator();
+        while ( it.hasNext() )
+        {
+            Permission permission = (Permission) it.next();
+            grantedAuthorities[i] = new GrantedAuthorityImpl( permission.getName() );
+            i++;
+        }
+        boolean enabled = true;
+        boolean accountNonExpired = true;
+        boolean credentialsNonExpired = true;
+        boolean accountNonLocked = true;
+
+        UserDetails userDetails = new User( user.getUsername(), user.getPassword(), enabled,
accountNonExpired,
+                                            credentialsNonExpired, accountNonLocked, grantedAuthorities
);
+
         return userDetails;
     }
 }



Mime
View raw message