]> source.dussan.org Git - archiva.git/commitdiff
remove this ugly Object getPrincipal
authorOlivier Lamy <olamy@apache.org>
Thu, 22 Nov 2012 21:55:21 +0000 (21:55 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 22 Nov 2012 21:55:21 +0000 (21:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1412684 13f79535-47bb-0310-9956-ffa450edef68

20 files changed:
redback-authentication/redback-authentication-providers/redback-authentication-ldap/src/main/java/org/apache/archiva/redback/authentication/ldap/LdapBindAuthenticator.java
redback-common/redback-common-ldap/src/main/java/org/apache/archiva/redback/common/ldap/LdapUser.java
redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/AdminAutoCreateCheck.java
redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/checks/security/GuestUserEnvironmentCheck.java
redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/filter/authentication/HttpAuthenticator.java
redback-integrations/redback-common-integrations/src/main/java/org/apache/archiva/redback/integration/filter/authentication/digest/HttpDigestAuthentication.java
redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java
redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/PermissionsInterceptor.java
redback-keys/redback-authentication-keys/src/main/java/org/apache/archiva/redback/authentication/keystore/KeyStoreAuthenticator.java
redback-rbac/redback-authorization-rbac/src/main/java/org/apache/archiva/redback/authorization/rbac/RbacAuthorizer.java
redback-system/src/main/java/org/apache/archiva/redback/system/DefaultSecuritySystem.java
redback-users/redback-authentication-users/src/main/java/org/apache/archiva/redback/authentication/users/UserManagerAuthenticator.java
redback-users/redback-users-api/src/main/java/org/apache/archiva/redback/users/User.java
redback-users/redback-users-providers/redback-users-cached/src/main/java/org/apache/archiva/redback/users/cached/CachedUserManager.java
redback-users/redback-users-providers/redback-users-jdo/src/main/mdo/user.mdo
redback-users/redback-users-providers/redback-users-ldap/src/main/java/org/apache/archiva/redback/users/ldap/LdapUserManager.java
redback-users/redback-users-providers/redback-users-ldap/src/test/java/org/apache/archiva/redback/users/ldap/LdapUserManagerTest.java
redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/MemoryUserManager.java
redback-users/redback-users-providers/redback-users-memory/src/main/java/org/apache/archiva/redback/users/memory/SimpleUser.java
redback-users/redback-users-tests/src/main/java/org/apache/archiva/redback/users/provider/test/AbstractUserManagerTestCase.java

index 2cd6a50cb139c522b2bf0c8bf88332da37309bad..a66e88bf61620ef67c9ab3c091f4a6b202c5f108 100644 (file)
@@ -98,7 +98,7 @@ public class LdapBindAuthenticator
             + ( mapper.getUserFilter() != null ? mapper.getUserFilter() : "" ) + "(" + mapper.getUserIdAttribute() + "="
             + source.getPrincipal() + "))";
 
-        log.info( "Searching for users with filter: '{}'" + " from base dn: {}", filter, mapper.getUserBaseDn() );
+        log.info( "Searching for users with filter: '{}' from base dn: {}", filter, mapper.getUserBaseDn() );
                                                               
         LdapConnection ldapConnection = getLdapConnection();
         LdapConnection authLdapConnection = null;
index 5622236bb4618677a2f495c3fe6b6887b0e0dc42..2077261e81122e5925434a593cf30614e88e349a 100644 (file)
@@ -32,8 +32,6 @@ public class LdapUser
     implements User, Serializable
 {
 
-    private String key;
-
     private String username;
 
     private String fullName;
@@ -67,10 +65,9 @@ public class LdapUser
 
     public LdapUser( String username )
     {
-        key = username;
         this.username = username;
-        previousEncodedPasswords = new ArrayList<String>( 0 );
-        failedLoginAttempts = 0;
+        this.previousEncodedPasswords = new ArrayList<String>( 0 );
+        this.failedLoginAttempts = 0;
     }
 
     public LdapUser( String username, String fullName, String email )
@@ -136,10 +133,6 @@ public class LdapUser
         return previousEncodedPasswords;
     }
 
-    public Object getPrincipal()
-    {
-        return key;
-    }
 
     public String getUsername()
     {
index e5e7b14385f95fedb330c7f17f1541b31d7806b3..fce83a1b0f154ff850f95dd30e44b7153d758570 100644 (file)
@@ -188,7 +188,7 @@ public class AdminAutoCreateCheck
     private void assignAdminRole( User user )
         throws RoleManagerException
     {
-        roleManager.assignRole( "system-administrator", user.getPrincipal().toString() );
+        roleManager.assignRole( "system-administrator", user.getUsername() );
     }
 
     private String getAdminUid()
index 083c01b3671cf590fba5f849453149a006ce7ff2..21c3626dcb152c9f79ed46a303d7c1b8635f88d9 100644 (file)
@@ -78,7 +78,7 @@ public class GuestUserEnvironmentCheck
 
             try
             {
-                roleManager.assignRole( "guest", guest.getPrincipal().toString() );
+                roleManager.assignRole( "guest", guest.getUsername() );
             }
             catch ( RoleManagerException rpe )
             {
index f5d1b4a045f35abf9d673ed6c9d2bab04c3ef5e4..33a1073652d96c8f6145679e56ed1e166e47c762 100644 (file)
@@ -191,7 +191,7 @@ public abstract class HttpAuthenticator
             User user = securitySystem.getUserManager().findUser( principal );
             httpSession.setAttribute( SecuritySession.USERKEY, user );
 
-            return user.getPrincipal().toString();
+            return user.getUsername();
 
         }
         catch ( UserNotFoundException e )
index ef6632e9ded9b6fd94de2ac83447dea74c3daffd..0a91741583c48f43cf67f38dba6086f232ceac36 100644 (file)
@@ -100,7 +100,7 @@ public class HttpDigestAuthentication
 
             // Lookup password for presented username
             User user = findUser( digestHeader.username );
-            authDataSource.setPrincipal( user.getPrincipal().toString() );
+            authDataSource.setPrincipal( user.getUsername() );
 
             String serverSideHash = generateDigestHash( digestHeader, user.getPassword(), request.getMethod() );
 
index ce3447b98be311501748f8638445fa72e7b5b217..0f15631332c91bea3b4c9c9347345a18a8e4317e 100644 (file)
@@ -197,7 +197,7 @@ public class DefaultUserService
         }
         try
         {
-            roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getPrincipal().toString() );
+            roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername() );
         }
         catch ( RoleManagerException rpe )
         {
@@ -417,7 +417,7 @@ public class DefaultUserService
             org.apache.archiva.redback.users.User user = userManager.createGuestUser();
             user.setPasswordChangeRequired( false );
             user = userManager.updateUser( user, false );
-            roleManager.assignRole( "guest", user.getPrincipal().toString() );
+            roleManager.assignRole( "guest", user.getUsername() );
             return getSimpleUser( user );
         }
         catch ( RoleManagerException e )
@@ -478,7 +478,7 @@ public class DefaultUserService
 
         try
         {
-            roleManager.assignRole( "system-administrator", user.getPrincipal().toString() );
+            roleManager.assignRole( "system-administrator", user.getUsername() );
         }
         catch ( RoleManagerException e )
         {
@@ -584,7 +584,7 @@ public class DefaultUserService
 
         try
         {
-            roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getPrincipal().toString() );
+            roleManager.assignRole( RedbackRoleConstants.REGISTERED_USER_ROLE_ID, u.getUsername() );
         }
         catch ( RoleManagerException rpe )
         {
@@ -599,7 +599,7 @@ public class DefaultUserService
             try
             {
                 AuthenticationKey authkey =
-                    securitySystem.getKeyManager().createKey( u.getPrincipal().toString(), "New User Email Validation",
+                    securitySystem.getKeyManager().createKey( u.getUsername(), "New User Email Validation",
                                                               securityPolicy.getUserValidationSettings().getEmailValidationTimeout() );
 
                 String baseUrl = userRegistrationRequest.getApplicationUrl();
@@ -658,7 +658,7 @@ public class DefaultUserService
             user.setPasswordChangeRequired( true );
             user.setEncodedPassword( "" );
 
-            principal = user.getPrincipal().toString();
+            principal = user.getUsername();
 
             TokenBasedAuthenticationDataSource authsource = new TokenBasedAuthenticationDataSource();
             authsource.setPrincipal( principal );
index 96bef482024332170af447588b821c527d7c9e50..a55b07fcc2af20bc6fd545a3a37105e241b56a46 100644 (file)
@@ -19,16 +19,16 @@ package org.apache.archiva.redback.rest.services.interceptors;
  * under the License.
  */
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.message.Message;
 import org.apache.archiva.redback.authentication.AuthenticationResult;
 import org.apache.archiva.redback.authorization.AuthorizationException;
 import org.apache.archiva.redback.authorization.RedbackAuthorization;
+import org.apache.archiva.redback.integration.filter.authentication.basic.HttpBasicAuthentication;
 import org.apache.archiva.redback.system.SecuritySession;
 import org.apache.archiva.redback.system.SecuritySystem;
-import org.apache.archiva.redback.integration.filter.authentication.basic.HttpBasicAuthentication;
+import org.apache.commons.lang.StringUtils;
+import org.apache.cxf.jaxrs.ext.RequestHandler;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.message.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -42,18 +42,18 @@ import javax.ws.rs.core.Response;
  * @author Olivier Lamy
  * @since 1.3
  */
-@Service( "permissionInterceptor#rest" )
+@Service ("permissionInterceptor#rest")
 public class PermissionsInterceptor
     extends AbstractInterceptor
     implements RequestHandler
 {
 
     @Inject
-    @Named( value = "securitySystem" )
+    @Named (value = "securitySystem")
     private SecuritySystem securitySystem;
 
     @Inject
-    @Named( value = "httpAuthenticator#basic" )
+    @Named (value = "httpAuthenticator#basic")
     private HttpBasicAuthentication httpAuthenticator;
 
     private Logger log = LoggerFactory.getLogger( getClass() );
@@ -96,7 +96,7 @@ public class PermissionsInterceptor
                             }
                             else
                             {
-                                log.debug( "user {} not authorized for permission {}", session.getUser().getPrincipal(),
+                                log.debug( "user {} not authorized for permission {}", session.getUser().getUsername(),
                                            permission );
                             }
                         }
index a825bc003ad4c7f949cd706685c84f6ccda99071..66cb55838152097893c953bb4d2275745abc315d 100644 (file)
@@ -44,16 +44,16 @@ import javax.annotation.Resource;
  *
  * @author: Jesse McConnell <jesse@codehaus.org>
  */
-@Service( "authenticator#keystore" )
+@Service ("authenticator#keystore")
 public class KeyStoreAuthenticator
     implements Authenticator
 {
     private Logger log = LoggerFactory.getLogger( getClass() );
 
-    @Resource( name = "keyManager#cached" )
+    @Resource (name = "keyManager#cached")
     private KeyManager keystore;
 
-    @Resource( name = "userManager#configurable" )
+    @Resource (name = "userManager#configurable")
     private UserManager userManager;
 
     public String getId()
@@ -104,7 +104,7 @@ public class KeyStoreAuthenticator
         }
         catch ( UserNotFoundException e )
         {
-            log.warn( "Login for user " + source.getPrincipal() + " failed. user not found." );
+            log.warn( "Login for user {} failed. user not found.", source.getPrincipal() );
             return new AuthenticationResult( false, null, e );
         }
     }
index d00eb56d4540052e9f762aabd74590b0c3af94b9..d14a2d4e971ff6cb4899255b28887ae932263c7d 100644 (file)
@@ -116,7 +116,7 @@ public class RbacAuthorizer
             {
                 // Set permissions = manager.getAssignedPermissions( principal.toString(), operation );
                 Map<String, List<Permission>> permissionMap =
-                    manager.getAssignedPermissionMap( guest.getPrincipal().toString() );
+                    manager.getAssignedPermissionMap( guest.getUsername() );
 
                 if ( permissionMap.keySet().contains( operation.toString() ) )
                 {
@@ -124,7 +124,7 @@ public class RbacAuthorizer
                     {
                         log.debug( "checking permission {}", permission.getName() );
 
-                        if ( evaluator.evaluate( permission, operation, resource, guest.getPrincipal() ) )
+                        if ( evaluator.evaluate( permission, operation, resource, guest.getUsername() ) )
                         {
                             return new AuthorizationResult( true, permission, null );
                         }
index 3e7332d41f35354e634559aa7c3663fccf841c16..c37971c61015de79c9625d9e72f824e59b0cb6fd 100644 (file)
@@ -161,7 +161,7 @@ public class DefaultSecuritySystem
             User user = session.getUser();
             if ( user != null )
             {
-                source = new AuthorizationDataSource( user.getPrincipal(), user, permission, resource );
+                source = new AuthorizationDataSource( user.getUsername(), user, permission, resource );
             }
         }
 
index 3296f9ff425d7232a96e248905a7a3977ff8427b..5614fa30df594237ef99fe070be59f17ba1c39fb 100644 (file)
@@ -129,7 +129,7 @@ public class UserManagerAuthenticator
             }
             else
             {
-                log.warn( "Password is Invalid for user " + source.getPrincipal() + "." );
+                log.warn( "Password is Invalid for user {}.", source.getPrincipal() );
                 authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_NO_SUCH_USER,
                                               "Password is Invalid for user " + source.getPrincipal() + "." );
 
@@ -150,7 +150,7 @@ public class UserManagerAuthenticator
             log.warn( "Login for user {} failed. user not found.", source.getPrincipal() );
             resultException = e;
             authnResultExceptionsMap.put( AuthenticationConstants.AUTHN_NO_SUCH_USER,
-                                          "Login for user \" + source.getPrincipal() + \" failed. user not found." );
+                                          "Login for user " + source.getPrincipal() + " failed. user not found." );
         }
 
         return new AuthenticationResult( authenticationSuccess, username, resultException, authnResultExceptionsMap );
index d8c9d3f9d48e1c4e97038d3b9ee2027f03b1a407..a0d4fd188f11014a01c318733071ece0ab883e17 100644 (file)
@@ -33,13 +33,6 @@ public interface User
     extends Serializable
 {
 
-    /**
-     * This is the object used to track the user within the provider.
-     *
-     * @return the principal for this user.
-     */
-    Object getPrincipal();
-
     // --------------------------------------------------------------------
     // Standard User Requirements.
     // --------------------------------------------------------------------
index dd76882550631a1b045a75acea158c3623bc259f..b2be9a240606bc22f8f9d346eb860e61b3153bec 100644 (file)
@@ -68,7 +68,7 @@ public class CachedUserManager
     {
         if ( user != null )
         {
-            usersCache.remove( user.getPrincipal() );
+            usersCache.remove( user.getUsername() );
         }
         return this.userImpl.addUser( user );
     }
@@ -82,7 +82,7 @@ public class CachedUserManager
     {
         if ( user != null )
         {
-            usersCache.remove( user.getPrincipal() );
+            usersCache.remove( user.getUsername() );
         }
         this.userImpl.addUserUnchecked( user );
     }
@@ -235,7 +235,7 @@ public class CachedUserManager
     {
         if ( user != null )
         {
-            usersCache.remove( user.getPrincipal() );
+            usersCache.remove( user.getUsername() );
         }
         return this.userImpl.updateUser( user, passwordChangeRequired );
     }
@@ -269,7 +269,7 @@ public class CachedUserManager
 
         if ( user != null )
         {
-            usersCache.remove( user.getPrincipal() );
+            usersCache.remove( user.getUsername() );
         }
     }
 
@@ -282,7 +282,7 @@ public class CachedUserManager
 
         if ( user != null )
         {
-            usersCache.remove( user.getPrincipal() );
+            usersCache.remove( user.getUsername() );
         }
     }
 
@@ -295,7 +295,7 @@ public class CachedUserManager
 
         if ( user != null )
         {
-            usersCache.remove( user.getPrincipal() );
+            usersCache.remove( user.getUsername() );
         }
     }
 
index a0c90ca1b8c310f50c0e8df2121286275a56b688..5a8c9a1fab18b26748ab43fdb25b6ad7f3cfced1 100644 (file)
               public JdoUser()
               {
                  // Intentionally initialize List to avoid JPOX NullPointerException Issues.
-                previousEncodedPasswords = new java.util.ArrayList();
+                previousEncodedPasswords = new java.util.ArrayList<String>();
               }
 
-              public Object getPrincipal()
-              {
-                 return username;
-              }
           ]]></code>
         </codeSegment>
       </codeSegments>
index dcaa661dfb66293035242457a5da2b560f396357..7581eef67153337bc08b5fed23f40c1f34d5850e 100644 (file)
@@ -102,11 +102,11 @@ public class LdapUserManager
         }
         catch ( LdapControllerException e )
         {
-            log.error( "Error mapping user: " + user.getPrincipal() + " to LDAP attributes.", e );
+            log.error( "Error mapping user: " + user.getUsername() + " to LDAP attributes.", e );
         }
         catch ( MappingException e )
         {
-            log.error( "Error mapping user: " + user.getPrincipal() + " to LDAP attributes.", e );
+            log.error( "Error mapping user: " + user.getUsername() + " to LDAP attributes.", e );
         }
         finally
         {
@@ -422,11 +422,11 @@ public class LdapUserManager
         }
         catch ( LdapControllerException e )
         {
-            log.error( "Failed to update user: " + user.getPrincipal(), e );
+            log.error( "Failed to update user: " + user.getUsername(), e );
         }
         catch ( MappingException e )
         {
-            log.error( "Failed to update user: " + user.getPrincipal(), e );
+            log.error( "Failed to update user: " + user.getUsername(), e );
         }
         finally
         {
index e3c298b22b981e993da08d5c80308995c7e92a63..7283c3b8f8fac898d82b7aede6ce1325f3d0693a 100644 (file)
@@ -209,11 +209,11 @@ public class LdapUserManagerTest
 
         assertNotNull( jesse );
 
-        assertEquals( "jesse", jesse.getPrincipal().toString() );
+        assertEquals( "jesse", jesse.getUsername() );
         assertEquals( "jesse@apache.org", jesse.getEmail() );
         assertEquals( "foo", jesse.getFullName() );
-        log.info( "=====>"+jesse.getEncodedPassword());
-        log.info( "=====>"+passwordEncoder.encodePassword( "foo" ));
+        log.info( "=====>{}",jesse.getEncodedPassword());
+        log.info( "=====>{}",passwordEncoder.encodePassword( "foo" ));
         assertTrue( passwordEncoder.isPasswordValid( jesse.getEncodedPassword(), "foo" ) );
 
     }
index 927e4ba1d27f4fcdb255e4227a8829a2fa5d2b2a..ca7e4a55d351a3a801e55930a1a826e0249e37f7 100644 (file)
@@ -134,7 +134,7 @@ public class MemoryUserManager
     private void saveUser( User user )
     {
         triggerInit();
-        users.put( user.getPrincipal(), user );
+        users.put( user.getUsername(), user );
     }
 
     public User updateUser( User user )
@@ -209,7 +209,7 @@ public class MemoryUserManager
             throw new PermanentUserException( "Cannot delete permanent user." );
         }
 
-        users.remove( user.getPrincipal() );
+        users.remove( user.getUsername() );
 
         fireUserManagerUserRemoved( user );
     }
index 2f37a4c993a6405d862328c698ff546e1498ff63..e8ae074ed5e7cf32ee86deb461e80df37df24928 100644 (file)
@@ -121,11 +121,6 @@ public class SimpleUser
         return previousEncodedPasswords;
     }
 
-    public Object getPrincipal()
-    {
-        return username;
-    }
-
     public String getUsername()
     {
         return username;
index ce8aecdd0bb7586a1777d7d7a11dc399982f610e..d4adc137f944a9311cd37ed4c3a4345dd428596d 100644 (file)
@@ -21,29 +21,28 @@ package org.apache.archiva.redback.users.provider.test;
 
 import junit.framework.TestCase;
 import org.apache.archiva.redback.policy.UserSecurityPolicy;
+import org.apache.archiva.redback.users.PermanentUserException;
 import org.apache.archiva.redback.users.User;
+import org.apache.archiva.redback.users.UserManager;
 import org.apache.archiva.redback.users.UserNotFoundException;
 import org.apache.archiva.redback.users.UserQuery;
-import org.apache.archiva.redback.users.PermanentUserException;
-import org.apache.archiva.redback.users.UserManager;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import javax.inject.Inject;
 import java.util.List;
-import org.springframework.test.annotation.DirtiesContext;
 
 /**
- * AbstractUserManagerTestCase 
+ * AbstractUserManagerTestCase
  *
  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
- *
  */
-@RunWith( SpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath*:/spring-context.xml"} )
-@DirtiesContext( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD )
+@RunWith ( SpringJUnit4ClassRunner.class )
+@ContextConfiguration ( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+@DirtiesContext ( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD )
 public class AbstractUserManagerTestCase
     extends TestCase
 {
@@ -56,16 +55,16 @@ public class AbstractUserManagerTestCase
 
     @Inject
     private UserSecurityPolicy securityPolicy;
-    
+
     private UserManagerEventTracker eventTracker;
 
-    
+
     private static final int EVENTTRACKERCOUNT = 2;
     // assertCleanUserManager
     // getEventTracker().userManagerInit( true ); is 1
     // userManager.getUsers() is 2
     // only on clear context
-    
+
     public UserManager getUserManager()
     {
         return userManager;
@@ -100,7 +99,8 @@ public class AbstractUserManagerTestCase
         getEventTracker().userManagerInit( true );
         assertNotNull( getUserManager() );
 
-        assertEquals( "New UserManager should contain no users. " + userManager.getUsers(), 0, userManager.getUsers().size() );
+        assertEquals( "New UserManager should contain no users. " + userManager.getUsers(), 0,
+                      userManager.getUsers().size() );
     }
 
     @Test
@@ -131,7 +131,7 @@ public class AbstractUserManagerTestCase
         {
             // Expected Path.
         }
-        
+
         try
         {
             String username = "";
@@ -142,7 +142,7 @@ public class AbstractUserManagerTestCase
         {
             // Expected Path.
         }
-        
+
         try
         {
             String username = "   ";
@@ -172,53 +172,55 @@ public class AbstractUserManagerTestCase
         assertEquals( 1, userManager.getUsers().size() );
 
         /* Fetch user from userManager using principal returned earlier */
-        User actual = userManager.findUser( added.getPrincipal() );
+        User actual = userManager.findUser( added.getUsername() );
         assertEquals( added, actual );
         
         /* Check into the event tracker. */
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
     }
 
     @Test
-    public void testAddFindUserLockedStatus() throws UserNotFoundException {
-               assertCleanUserManager();
-               securityPolicy.setEnabled(false);
+    public void testAddFindUserLockedStatus()
+        throws UserNotFoundException
+    {
+        assertCleanUserManager();
+        securityPolicy.setEnabled( false );
+
+        User smcqueen = getUserManager().createUser( "smcqueen", "Steve McQueen", "the cooler king" );
 
-               User smcqueen = getUserManager().createUser("smcqueen", "Steve McQueen", "the cooler king");
+        smcqueen.setLocked( true );
 
-               smcqueen.setLocked( true );
-               
                /*
                 * Keep a reference to the object that was added. Since it has the
                 * actual principal that was managed by jpox/jdo.
                 */
-               User added = userManager.addUser( smcqueen );
+        User added = userManager.addUser( smcqueen );
 
-               assertTrue( added.isLocked() );
-               
-               assertEquals(1, userManager.getUsers().size());
+        assertTrue( added.isLocked() );
+
+        assertEquals( 1, userManager.getUsers().size() );
 
                /* Fetch user from userManager using principal returned earlier */
-               User actual = userManager.findUser(added.getPrincipal());
-               assertEquals(added, actual);
+        User actual = userManager.findUser( added.getUsername() );
+        assertEquals( added, actual );
 
-               assertTrue( actual.isLocked() );
+        assertTrue( actual.isLocked() );
                
                /* Check into the event tracker. */
-               assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit);
-               assertNotNull(getEventTracker().lastDbFreshness);
-               assertTrue(getEventTracker().lastDbFreshness.booleanValue());
+        assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
+        assertNotNull( getEventTracker().lastDbFreshness );
+        assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
 
-               assertEquals(1, getEventTracker().addedUsernames.size());
-               assertEquals(0, getEventTracker().removedUsernames.size());
-               assertEquals(0, getEventTracker().updatedUsernames.size());
-       }
+        assertEquals( 1, getEventTracker().addedUsernames.size() );
+        assertEquals( 0, getEventTracker().removedUsernames.size() );
+        assertEquals( 0, getEventTracker().updatedUsernames.size() );
+    }
 
     @Test
     public void testAddFindUserByUsername()
@@ -240,7 +242,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
@@ -264,7 +266,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
@@ -292,7 +294,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
@@ -312,7 +314,7 @@ public class AbstractUserManagerTestCase
 
         assertEquals( 1, um.getUsers().size() );
 
-        um.deleteUser( user.getPrincipal() );
+        um.deleteUser( user.getUsername() );
         assertEquals( 0, um.getUsers().size() );
 
         // attempt finding a non-existent user
@@ -330,7 +332,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 1, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
@@ -364,7 +366,7 @@ public class AbstractUserManagerTestCase
         User user = um.findUser( "root" );
         assertNotNull( user );
         assertEquals( "root@somedomain.com", user.getEmail() );
-        assertEquals( "root", user.getPrincipal() );
+        assertEquals( "root", user.getUsername() );
         assertEquals( "Root User", user.getFullName() );
         // test if the plain string password is encoded and NULL'ified
         assertNull( user.getPassword() );
@@ -386,7 +388,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 3, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
@@ -520,7 +522,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 0, getEventTracker().updatedUsernames.size() );
@@ -562,7 +564,7 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
         assertEquals( 1, getEventTracker().updatedUsernames.size() );
@@ -585,13 +587,14 @@ public class AbstractUserManagerTestCase
 
         try
         {
-            um.deleteUser( user.getPrincipal() );
-            fail("Deleting permanent user shold throw PermanentUserException.");
-        } catch( PermanentUserException e )
+            um.deleteUser( user.getUsername() );
+            fail( "Deleting permanent user shold throw PermanentUserException." );
+        }
+        catch ( PermanentUserException e )
         {
             // do nothing, expected route.
         }
-        
+
         assertEquals( 1, um.getUsers().size() );
 
         // attempt to finding user
@@ -604,10 +607,11 @@ public class AbstractUserManagerTestCase
         assertEquals( EVENTTRACKERCOUNT, getEventTracker().countInit );
         assertNotNull( getEventTracker().lastDbFreshness );
         assertTrue( getEventTracker().lastDbFreshness.booleanValue() );
-        
+
         assertEquals( 1, getEventTracker().addedUsernames.size() );
         assertEquals( 0, getEventTracker().removedUsernames.size() );
-        assertEquals( 0, getEventTracker().updatedUsernames.size() );    }
+        assertEquals( 0, getEventTracker().updatedUsernames.size() );
+    }
 
     public UserManagerEventTracker getEventTracker()
     {