Author: olamy
Date: Tue Jan 15 15:43:29 2013
New Revision: 1433465
URL: http://svn.apache.org/viewvc?rev=1433465&view=rev
Log:
use getUsername rather than getPrincipal
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
archiva/redback/redback-core/trunk/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
Tue Jan 15 15:43:29 2013
@@ -30,7 +30,7 @@ package org.apache.archiva.redback.authe
*/
public interface AuthenticationDataSource
{
- String getPrincipal();
+ String getUsername();
boolean isEnforcePasswordChange();
}
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
Tue Jan 15 15:43:29 2013
@@ -56,7 +56,7 @@ public class PasswordBasedAuthentication
return password;
}
- public String getPrincipal()
+ public String getUsername()
{
return principal;
}
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
Tue Jan 15 15:43:29 2013
@@ -50,7 +50,7 @@ public class TokenBasedAuthenticationDat
{
}
- public String getPrincipal()
+ public String getUsername()
{
return principal;
}
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
Tue Jan 15 15:43:29 2013
@@ -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
{
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
Tue Jan 15 15:43:29 2013
@@ -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 ) )
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
Tue Jan 15 15:43:29 2013
@@ -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()
Modified:
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
(original)
+++
archiva/redback/redback-core/trunk/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
Tue Jan 15 15:43:29 2013
@@ -43,9 +43,7 @@ import org.springframework.stereotype.Se
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() ) );
}
Modified:
archiva/redback/redback-core/trunk/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java
URL:
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java?rev=1433465&r1=1433464&r2=1433465&view=diff
==============================================================================
---
archiva/redback/redback-core/trunk/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java
(original)
+++
archiva/redback/redback-core/trunk/redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java
Tue Jan 15 15:43:29 2013
@@ -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 );
}
}