use getUsername rather than getPrincipal

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1433464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-15 15:43:09 +00:00
parent 5ed3102690
commit e0bd11b548
3 changed files with 18 additions and 18 deletions

View File

@ -106,14 +106,14 @@ public class ArchivaUserManagerAuthenticator
try try
{ {
log.debug( "Authenticate: {} with userManager: {}", source, userManager.getId() ); log.debug( "Authenticate: {} with userManager: {}", source, userManager.getId() );
User user = userManager.findUser( source.getPrincipal() ); User user = userManager.findUser( source.getUsername() );
username = user.getUsername(); username = user.getUsername();
if ( user.isLocked() ) if ( user.isLocked() )
{ {
//throw new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user ); //throw new AccountLockedException( "Account " + source.getUsername() + " is locked.", user );
AccountLockedException e = AccountLockedException e =
new AccountLockedException( "Account " + source.getPrincipal() + " is locked.", user ); new AccountLockedException( "Account " + source.getUsername() + " is locked.", user );
log.warn( "{}", e.getMessage() ); log.warn( "{}", e.getMessage() );
resultException = e; resultException = e;
authnResultErrors.add( authnResultErrors.add(
@ -138,7 +138,7 @@ public class ArchivaUserManagerAuthenticator
boolean isPasswordValid = encoder.isPasswordValid( user.getEncodedPassword(), source.getPassword() ); boolean isPasswordValid = encoder.isPasswordValid( user.getEncodedPassword(), source.getPassword() );
if ( isPasswordValid ) if ( isPasswordValid )
{ {
log.debug( "User {} provided a valid password", source.getPrincipal() ); log.debug( "User {} provided a valid password", source.getUsername() );
try try
{ {
@ -156,7 +156,7 @@ public class ArchivaUserManagerAuthenticator
} }
} }
return new AuthenticationResult( true, source.getPrincipal(), null ); return new AuthenticationResult( true, source.getUsername(), null );
} }
catch ( MustChangePasswordException e ) catch ( MustChangePasswordException e )
{ {
@ -169,11 +169,11 @@ public class ArchivaUserManagerAuthenticator
} }
else else
{ {
log.warn( "Password is Invalid for user {} and userManager '{}'.", source.getPrincipal(), log.warn( "Password is Invalid for user {} and userManager '{}'.", source.getUsername(),
userManager.getId() ); userManager.getId() );
authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_NO_SUCH_USER, authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_NO_SUCH_USER,
"Password is Invalid for user " "Password is Invalid for user "
+ source.getPrincipal() + "." ) ); + source.getUsername() + "." ) );
try try
{ {
@ -189,23 +189,23 @@ public class ArchivaUserManagerAuthenticator
} }
} }
//return new AuthenticationResult( false, source.getPrincipal(), null, authnResultExceptionsMap ); //return new AuthenticationResult( false, source.getUsername(), null, authnResultExceptionsMap );
} }
} }
catch ( UserNotFoundException e ) 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; resultException = e;
authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_NO_SUCH_USER, authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_NO_SUCH_USER,
"Login for user " + source.getPrincipal() "Login for user " + source.getUsername()
+ " failed. user not found." ) ); + " failed. user not found." ) );
} }
catch ( UserManagerException e ) 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; resultException = e;
authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_RUNTIME_EXCEPTION, authnResultErrors.add( new AuthenticationFailureCause( AuthenticationConstants.AUTHN_RUNTIME_EXCEPTION,
"Login for user " + source.getPrincipal() "Login for user " + source.getUsername()
+ " failed, message: " + e.getMessage() ) ); + " failed, message: " + e.getMessage() ) );
} }
} }

View File

@ -68,19 +68,19 @@ public class SecuritySystemStub
AuthenticationResult result = null; AuthenticationResult result = null;
SecuritySession session = null; SecuritySession session = null;
if ( users.get( source.getPrincipal() ) != null ) if ( users.get( source.getUsername() ) != null )
{ {
result = new AuthenticationResult( true, source.getPrincipal(), null ); result = new AuthenticationResult( true, source.getUsername(), null );
User user = new JdoUser(); User user = new JdoUser();
user.setUsername( source.getPrincipal() ); user.setUsername( source.getUsername() );
user.setPassword( users.get( source.getPrincipal() ) ); user.setPassword( users.get( source.getUsername() ) );
session = new DefaultSecuritySession( result, user ); session = new DefaultSecuritySession( result, user );
} }
else else
{ {
result = new AuthenticationResult( false, source.getPrincipal(), null ); result = new AuthenticationResult( false, source.getUsername(), null );
session = new DefaultSecuritySession( result ); session = new DefaultSecuritySession( result );
} }
return session; return session;

View File

@ -63,7 +63,7 @@ public class BypassSecuritySystem
public SecuritySession authenticate( AuthenticationDataSource source ) public SecuritySession authenticate( AuthenticationDataSource source )
throws AuthenticationException, UserNotFoundException, AccountLockedException throws AuthenticationException, UserNotFoundException, AccountLockedException
{ {
AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null ); AuthenticationResult result = new AuthenticationResult( true, source.getUsername(), null );
return new DefaultSecuritySession( result ); return new DefaultSecuritySession( result );
} }