]> source.dussan.org Git - archiva.git/commitdiff
use getUsername rather than getPrincipal
authorOlivier Lamy <olamy@apache.org>
Tue, 15 Jan 2013 15:43:29 +0000 (15:43 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 15 Jan 2013 15:43:29 +0000 (15:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1433465 13f79535-47bb-0310-9956-ffa450edef68

redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java

index 58a68074ccff5f71e9119d918bd9912698bbbe88..b66ce16a898ea68119c901c831cb61e984a88ebd 100644 (file)
@@ -87,7 +87,7 @@ public class LdapBindAuthenticator
             !config.getBoolean( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ALLOW_EMPTY_PASSWORDS, false )
                 && StringUtils.isEmpty( source.getPassword() ) ) )
         {
-            return new AuthenticationResult( false, source.getPrincipal(), null );
+            return new AuthenticationResult( false, source.getUsername(), null );
         }
 
         SearchControls ctls = new SearchControls();
@@ -99,7 +99,7 @@ public class LdapBindAuthenticator
 
         String filter = "(&(objectClass=" + mapper.getUserObjectClass() + ")" + ( mapper.getUserFilter() != null
             ? mapper.getUserFilter()
-            : "" ) + "(" + mapper.getUserIdAttribute() + "=" + source.getPrincipal() + "))";
+            : "" ) + "(" + mapper.getUserIdAttribute() + "=" + source.getUsername() + "))";
 
         log.debug( "Searching for users with filter: '{}' from base dn: {}", filter, mapper.getUserBaseDn() );
 
@@ -110,18 +110,18 @@ public class LdapBindAuthenticator
         {
             ldapConnection = getLdapConnection();
             // check the cache for user's userDn in the ldap server
-            String userDn = ldapCacheService.getLdapUserDn( source.getPrincipal() );
+            String userDn = ldapCacheService.getLdapUserDn( source.getUsername() );
 
             if ( userDn == null )
             {
                 log.debug( "userDn for user {} not found in cache. Retrieving from ldap server..",
-                           source.getPrincipal() );
+                           source.getUsername() );
 
                 DirContext context = ldapConnection.getDirContext();
 
                 results = context.search( mapper.getUserBaseDn(), filter, ctls );
 
-                log.debug( "Found user '{}': {}", source.getPrincipal(), results.hasMoreElements() );
+                log.debug( "Found user '{}': {}", source.getUsername(), results.hasMoreElements() );
 
                 if ( results.hasMoreElements() )
                 {
@@ -129,14 +129,14 @@ public class LdapBindAuthenticator
 
                     userDn = result.getNameInNamespace();
 
-                    log.debug( "Adding userDn {} for user {} to the cache..", userDn, source.getPrincipal() );
+                    log.debug( "Adding userDn {} for user {} to the cache..", userDn, source.getUsername() );
 
                     // REDBACK-289/MRM-1488 cache the ldap user's userDn to lessen calls to ldap server
-                    ldapCacheService.addLdapUserDn( source.getPrincipal(), userDn );
+                    ldapCacheService.addLdapUserDn( source.getUsername(), userDn );
                 }
                 else
                 {
-                    return new AuthenticationResult( false, source.getPrincipal(), null );
+                    return new AuthenticationResult( false, source.getUsername(), null );
                 }
             }
 
@@ -144,17 +144,17 @@ public class LdapBindAuthenticator
 
             authLdapConnection = connectionFactory.getConnection( userDn, source.getPassword() );
 
-            log.info( "user '{}' authenticated", source.getPrincipal() );
+            log.info( "user '{}' authenticated", source.getUsername() );
 
-            return new AuthenticationResult( true, source.getPrincipal(), null );
+            return new AuthenticationResult( true, source.getUsername(), null );
         }
         catch ( LdapException e )
         {
-            return new AuthenticationResult( false, source.getPrincipal(), e );
+            return new AuthenticationResult( false, source.getUsername(), e );
         }
         catch ( NamingException e )
         {
-            return new AuthenticationResult( false, source.getPrincipal(), e );
+            return new AuthenticationResult( false, source.getUsername(), e );
         }
         finally
         {
index 92de62b15a4c9be84f79f46187616660d79beba4..9731ad607366f1e3cec81b1ed667ab31a78e1002 100644 (file)
@@ -51,7 +51,7 @@ public class MemoryAuthenticator
     {
         PasswordBasedAuthenticationDataSource source = (PasswordBasedAuthenticationDataSource) s;
 
-        login = source.getPrincipal();
+        login = source.getUsername();
         password = source.getPassword();
 
         if ( source.getPassword().equals( password ) )
index 8d0f957774473c4cc9177ee5fcd8cc9d3d2f1580..fbc117767402148da7388dc5fd62f044ec85099f 100644 (file)
@@ -44,7 +44,7 @@ public class OpenAuthenticator
         throws AccountLockedException, AuthenticationException
     {
         PasswordBasedAuthenticationDataSource source = (PasswordBasedAuthenticationDataSource) s;
-        return new AuthenticationResult( true, source.getPrincipal(), null );
+        return new AuthenticationResult( true, source.getUsername(), null );
     }
 
     public String getId()
index a1da4f5986811eabced7b3e85814a407245f886f..c679c12a0a77fb15ee037c590877be256c342252 100644 (file)
@@ -43,9 +43,7 @@ import org.springframework.stereotype.Service;
 import javax.inject.Inject;
 import javax.inject.Named;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * {@link Authenticator} implementation that uses a wrapped {@link UserManager} to authenticate.
@@ -92,12 +90,12 @@ public class UserManagerAuthenticator
         try
         {
             log.debug( "Authenticate: {}", source );
-            User user = userManager.findUser( source.getPrincipal() );
+            User user = userManager.findUser( source.getUsername() );
             username = user.getUsername();
 
             if ( user.isLocked() )
             {
-                throw new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user );
+                throw new AccountLockedException( "Account " + source.getUsername() + " is locked.", user );
             }
 
             if ( user.isPasswordChangeRequired() && source.isEnforcePasswordChange() )
@@ -111,7 +109,7 @@ public class UserManagerAuthenticator
             boolean isPasswordValid = encoder.isPasswordValid( user.getEncodedPassword(), source.getPassword() );
             if ( isPasswordValid )
             {
-                log.debug( "User {} provided a valid password", source.getPrincipal() );
+                log.debug( "User {} provided a valid password", source.getUsername() );
 
                 try
                 {
@@ -132,14 +130,14 @@ public class UserManagerAuthenticator
                     userManager.updateUser( user );
                 }
 
-                return new AuthenticationResult( true, source.getPrincipal(), null );
+                return new AuthenticationResult( true, source.getUsername(), null );
             }
             else
             {
-                log.warn( "Password is Invalid for user {}.", source.getPrincipal() );
+                log.warn( "Password is Invalid for user {}.", source.getUsername() );
                 authenticationFailureCauses.add(
                     new AuthenticationFailureCause( AuthenticationConstants.AUTHN_NO_SUCH_USER,
-                                                    "Password is Invalid for user " + source.getPrincipal() + "." ) );
+                                                    "Password is Invalid for user " + source.getUsername() + "." ) );
 
                 try
                 {
@@ -150,24 +148,24 @@ public class UserManagerAuthenticator
                     userManager.updateUser( user );
                 }
 
-                return new AuthenticationResult( false, source.getPrincipal(), null, authenticationFailureCauses );
+                return new AuthenticationResult( false, source.getUsername(), null, authenticationFailureCauses );
             }
         }
         catch ( UserNotFoundException e )
         {
-            log.warn( "Login for user {} failed. user not found.", source.getPrincipal() );
+            log.warn( "Login for user {} failed. user not found.", source.getUsername() );
             resultException = e;
             authenticationFailureCauses.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_NO_SUCH_USER,
-                                                                             "Login for user " + source.getPrincipal()
+                                                                             "Login for user " + source.getUsername()
                                                                                  + " failed. user not found." ) );
         }
         catch ( UserManagerException e )
         {
-            log.warn( "Login for user {} failed, message: {}", source.getPrincipal(), e.getMessage() );
+            log.warn( "Login for user {} failed, message: {}", source.getUsername(), e.getMessage() );
             resultException = e;
             authenticationFailureCauses.add(
                 new AuthenticationFailureCause( AuthenticationConstants.AUTHN_RUNTIME_EXCEPTION,
-                                                "Login for user " + source.getPrincipal() + " failed, message: "
+                                                "Login for user " + source.getUsername() + " failed, message: "
                                                     + e.getMessage() ) );
         }
 
index 035c1e4cd98b18b7aace8f93a257b6af71cf98fc..8c13fe4dff771735e2ebc310b8e50a6fe61ef1e3 100644 (file)
@@ -77,11 +77,11 @@ public class KeyStoreAuthenticator
             // if we find a key (exception was probably thrown if not) then we should be authentic
             if ( authKey != null )
             {
-                User user = userManager.findUser( dataSource.getPrincipal() );
+                User user = userManager.findUser( dataSource.getUsername() );
 
                 if ( user.isLocked() )
                 {
-                    throw new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user );
+                    throw new AccountLockedException( "Account " + source.getUsername() + " is locked.", user );
                 }
 
                 if ( user.isPasswordChangeRequired() && source.isEnforcePasswordChange() )
@@ -89,11 +89,11 @@ public class KeyStoreAuthenticator
                     throw new MustChangePasswordException( "Password expired.", user );
                 }
 
-                return new AuthenticationResult( true, dataSource.getPrincipal(), null );
+                return new AuthenticationResult( true, dataSource.getUsername(), null );
             }
             else
             {
-                return new AuthenticationResult( false, dataSource.getPrincipal(),
+                return new AuthenticationResult( false, dataSource.getUsername(),
                                                  new AuthenticationException( "unable to find key" ) );
             }
         }
@@ -107,12 +107,12 @@ public class KeyStoreAuthenticator
         }
         catch ( UserNotFoundException e )
         {
-            log.warn( "Login for user {} failed. user not found.", source.getPrincipal() );
+            log.warn( "Login for user {} failed. user not found.", source.getUsername() );
             return new AuthenticationResult( false, null, e );
         }
         catch ( UserManagerException e )
         {
-            log.warn( "Login fail for user {} failed. message: {}", source.getPrincipal(), e.getMessage() );
+            log.warn( "Login fail for user {} failed. message: {}", source.getUsername(), e.getMessage() );
             return new AuthenticationResult( false, null, e );
         }
     }