summaryrefslogtreecommitdiffstats
path: root/redback-authentication
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-01-15 15:43:29 +0000
committerOlivier Lamy <olamy@apache.org>2013-01-15 15:43:29 +0000
commit30bc1f3ad8592b30c1c4db67bc0b4b107081cb4a (patch)
tree91cc341075e0fd49ea5c449e161a15690d1de970 /redback-authentication
parent17f4210d6c06db0b613b9b730d40bd8172615453 (diff)
downloadarchiva-30bc1f3ad8592b30c1c4db67bc0b4b107081cb4a.tar.gz
archiva-30bc1f3ad8592b30c1c4db67bc0b4b107081cb4a.zip
use getUsername rather than getPrincipal
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1433465 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'redback-authentication')
-rw-r--r--redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java2
-rw-r--r--redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java2
-rw-r--r--redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java2
-rw-r--r--redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java24
-rw-r--r--redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java2
-rw-r--r--redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java2
-rw-r--r--redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java24
7 files changed, 28 insertions, 30 deletions
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
index 746aa1df1..d9d2dd82b 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/AuthenticationDataSource.java
@@ -30,7 +30,7 @@ package org.apache.archiva.redback.authentication;
*/
public interface AuthenticationDataSource
{
- String getPrincipal();
+ String getUsername();
boolean isEnforcePasswordChange();
}
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
index ad3a7f48a..77fb2091f 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/PasswordBasedAuthenticationDataSource.java
@@ -56,7 +56,7 @@ public class PasswordBasedAuthenticationDataSource
return password;
}
- public String getPrincipal()
+ public String getUsername()
{
return principal;
}
diff --git a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
index 3fcbb1f1c..f44b8efd3 100644
--- a/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
+++ b/redback-authentication/redback-authentication-api/src/main/java/org/apache/archiva/redback/authentication/TokenBasedAuthenticationDataSource.java
@@ -50,7 +50,7 @@ public class TokenBasedAuthenticationDataSource
{
}
- public String getPrincipal()
+ public String getUsername()
{
return principal;
}
diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
index 58a68074c..b66ce16a8 100644
--- a/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
+++ b/redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
@@ -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
{
diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
index 92de62b15..9731ad607 100644
--- a/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
+++ b/redback-authentication/redback-authentication-providers/redback-authentication-memory/src/main/java/org/apache/archiva/redback/authentication/memory/MemoryAuthenticator.java
@@ -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 ) )
diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
index 8d0f95777..fbc117767 100644
--- a/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
+++ b/redback-authentication/redback-authentication-providers/redback-authentication-open/src/main/java/org/apache/archiva/redback/authentication/open/OpenAuthenticator.java
@@ -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()
diff --git a/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java b/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
index a1da4f598..c679c12a0 100644
--- a/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
+++ b/redback-authentication/redback-authentication-providers/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
@@ -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() ) );
}