continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r440522 - /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 23:05:47 GMT
Author: carlos
Date: Tue Sep  5 16:05:46 2006
New Revision: 440522

URL: http://svn.apache.org/viewvc?view=rev&rev=440522
Log:
Deprecate ContinuumUserDetailsService, use MavenUserDetailsService

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=440522&r1=440521&r2=440522
==============================================================================
--- 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
Tue Sep  5 16:05:46 2006
@@ -17,114 +17,19 @@
  *
  */
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-
-import org.acegisecurity.GrantedAuthority;
-import org.acegisecurity.GrantedAuthorityImpl;
-import org.acegisecurity.userdetails.UserDetails;
 import org.acegisecurity.userdetails.UserDetailsService;
-import org.acegisecurity.userdetails.UsernameNotFoundException;
-import org.apache.maven.continuum.model.system.Permission;
-import org.apache.maven.user.model.User;
-import org.apache.maven.user.model.UserManager;
-import org.springframework.dao.DataAccessException;
+import org.apache.maven.user.acegi.MavenUserDetailsService;
 
 /**
  * Acegi {@link UserDetailsService} that loads user info from Continuum database.
  *
+ * @deprecated use {@link MavenUserDetailsService}
+ * 
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @author Henry Isidro
  * @version $Id$
  */
 public class ContinuumUserDetailsService
-    implements UserDetailsService
+    extends MavenUserDetailsService
 {
-    static final long MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
-
-    /**
-     * @plexus.requirement
-     */
-    private UserManager userManager;
-
-    /**
-     * @plexus.configuration default-value="60"
-     */
-    private int daysBeforeExpiration;
-
-    public ContinuumUserDetailsService()
-    {
-    }
-
-    public UserDetails loadUserByUsername( String username )
-        throws UsernameNotFoundException, DataAccessException
-    {
-        User user = userManager.getUser( username );
-
-        if ( user == null )
-        {
-            throw new UsernameNotFoundException( "Could not find user: " + username );
-        }
-        return getUserDetails( user );
-    }
-
-    /**
-     * Convert a Continuum user into a Acegi user
-     * 
-     * @param user the continuum user loaded from DB
-     * @return the Acegi user
-     */
-    UserDetails getUserDetails( User user )
-    {
-        List permissions = user.getGroup().getPermissions();
-
-        List grantedAuthorities = new ArrayList( permissions.size() + 1 );
-        Iterator it = permissions.iterator();
-        while ( it.hasNext() )
-        {
-            Permission permission = (Permission) it.next();
-            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;
-        boolean accountNonExpired = true;
-
-        if ( user.getLastPasswordChange() != null && daysBeforeExpiration > 0
)
-        {
-            long lastPasswordChange = user.getLastPasswordChange().getTime();
-            long currentTime = new Date().getTime();
-            accountNonExpired = lastPasswordChange + daysBeforeExpiration * MILLISECONDS_PER_DAY
> currentTime;
-        }
-
-        boolean credentialsNonExpired = true;
-        boolean accountNonLocked = true;
-
-        UserDetails userDetails = new org.acegisecurity.userdetails.User( username, password,
enabled,
-                                                                          accountNonExpired,
credentialsNonExpired,
-                                                                          accountNonLocked,
grantedAuthoritiesAsArray );
-
-        return userDetails;
-    }
-
-    protected void setDaysBeforeExpiration( int daysBeforeExpiration )
-    {
-        this.daysBeforeExpiration = daysBeforeExpiration;
-    }
-
-    /**
-     * TODO: convert Acegi user into Continuum user?
-     */
 }



Mime
View raw message