Modified: turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryGroupManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryGroupManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryGroupManagerTest.java (original) +++ turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryGroupManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.memory.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,10 +21,11 @@ package org.apache.fulcrum.security.memo import org.apache.fulcrum.security.SecurityService; import org.apache.fulcrum.security.model.test.AbstractGroupManagerTest; + /** * @author Eric Pugh - * - * Test the memory implementation of the Simple model.. + * + * Test the memory implementation of the Simple model.. */ public class MemoryGroupManagerTest extends AbstractGroupManagerTest { @@ -31,30 +33,36 @@ public class MemoryGroupManagerTest exte { junit.textui.TestRunner.run(MemoryGroupManagerTest.class); } - public void setUp() - { - try - { - this.setRoleFileName("src/test/DynamicMemoryRoleConfig.xml"); - this.setConfigurationFileName("src/test/DynamicMemoryComponentConfig.xml"); - securityService = (SecurityService) lookup(SecurityService.ROLE); - groupManager = securityService.getGroupManager(); - } - catch (Exception e) - { - fail(e.toString()); - } - } - public void tearDown() - { - group = null; - groupManager = null; - securityService = null; - } + + @Override + public void setUp() + { + try + { + this.setRoleFileName("src/test/DynamicMemoryRoleConfig.xml"); + this.setConfigurationFileName("src/test/DynamicMemoryComponentConfig.xml"); + securityService = (SecurityService) lookup(SecurityService.ROLE); + groupManager = securityService.getGroupManager(); + } + catch (Exception e) + { + fail(e.toString()); + } + } + + @Override + public void tearDown() + { + group = null; + groupManager = null; + securityService = null; + } + /** - * Constructor for MemoryPermissionManagerTest. - * @param arg0 - */ + * Constructor for MemoryPermissionManagerTest. + * + * @param arg0 + */ public MemoryGroupManagerTest(String arg0) { super(arg0);
Modified: turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryPermissionManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryPermissionManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryPermissionManagerTest.java (original) +++ turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryPermissionManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.memory.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,14 +20,16 @@ package org.apache.fulcrum.security.memo */ import org.apache.fulcrum.security.SecurityService; import org.apache.fulcrum.security.model.test.AbstractPermissionManagerTest; + /** * @author Eric Pugh - * - * Test the memory implementation of the Simple model.. + * + * Test the memory implementation of the Simple model.. */ public class MemoryPermissionManagerTest extends AbstractPermissionManagerTest { + @Override public void setUp() { try @@ -41,16 +44,20 @@ public class MemoryPermissionManagerTest fail(e.toString()); } } + + @Override public void tearDown() { permission = null; permissionManager = null; securityService = null; } + /** - * Constructor for MemoryPermissionManagerTest. - * @param arg0 - */ + * Constructor for MemoryPermissionManagerTest. + * + * @param arg0 + */ public MemoryPermissionManagerTest(String arg0) { super(arg0); Modified: turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryRoleManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryRoleManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryRoleManagerTest.java (original) +++ turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryRoleManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.memory.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,21 +21,23 @@ package org.apache.fulcrum.security.memo import org.apache.fulcrum.security.SecurityService; import org.apache.fulcrum.security.model.test.AbstractRoleManagerTest; + /** * @author Eric Pugh - * - * Test the memory implementation of the Simple model.. + * + * Test the memory implementation of the Simple model.. */ public class MemoryRoleManagerTest extends AbstractRoleManagerTest { + @Override public void setUp() { try { this.setRoleFileName("src/test/DynamicMemoryRoleConfig.xml"); this.setConfigurationFileName("src/test/DynamicMemoryComponentConfig.xml"); - securityService = (SecurityService) lookup(SecurityService.ROLE); + securityService = (SecurityService) lookup(SecurityService.ROLE); roleManager = securityService.getRoleManager(); } catch (Exception e) @@ -42,16 +45,20 @@ public class MemoryRoleManagerTest exten fail(e.toString()); } } + + @Override public void tearDown() { role = null; roleManager = null; securityService = null; } + /** - * Constructor for MemoryPermissionManagerTest. - * @param arg0 - */ + * Constructor for MemoryPermissionManagerTest. + * + * @param arg0 + */ public MemoryRoleManagerTest(String arg0) { super(arg0); Modified: turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryUserManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryUserManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryUserManagerTest.java (original) +++ turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/dynamic/MemoryUserManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.memory.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,21 +21,23 @@ package org.apache.fulcrum.security.memo import org.apache.fulcrum.security.SecurityService; import org.apache.fulcrum.security.model.test.AbstractUserManagerTest; + /** * @author Eric Pugh - * - * Test the memory implementation of the Simple model.. + * + * Test the memory implementation of the Simple model.. */ public class MemoryUserManagerTest extends AbstractUserManagerTest { + @Override public void setUp() { try { this.setRoleFileName("src/test/DynamicMemoryRoleConfig.xml"); this.setConfigurationFileName("src/test/DynamicMemoryComponentConfig.xml"); - securityService = (SecurityService) lookup(SecurityService.ROLE); + securityService = (SecurityService) lookup(SecurityService.ROLE); userManager = securityService.getUserManager(); } catch (Exception e) @@ -42,16 +45,20 @@ public class MemoryUserManagerTest exten fail(e.toString()); } } + + @Override public void tearDown() { user = null; userManager = null; securityService = null; } + /** - * Constructor for MemoryPermissionManagerTest. - * @param arg0 - */ + * Constructor for MemoryPermissionManagerTest. + * + * @param arg0 + */ public MemoryUserManagerTest(String arg0) { super(arg0); Modified: turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/turbine/MemoryTurbineModelManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/turbine/MemoryTurbineModelManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/turbine/MemoryTurbineModelManagerTest.java (original) +++ turbine/fulcrum/trunk/security/memory/src/test/org/apache/fulcrum/security/memory/turbine/MemoryTurbineModelManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.memory.turbine; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,24 +20,17 @@ package org.apache.fulcrum.security.memo */ import org.apache.fulcrum.security.SecurityService; -import org - .apache - .fulcrum - .security - .model - .turbine - .test - .AbstractTurbineModelManagerTest; +import org.apache.fulcrum.security.model.turbine.test.AbstractTurbineModelManagerTest; /** * @author Eric Pugh - * - * Test the memory implementation of the turbine model.. + * + * Test the memory implementation of the turbine model.. */ -public class MemoryTurbineModelManagerTest - extends AbstractTurbineModelManagerTest +public class MemoryTurbineModelManagerTest extends AbstractTurbineModelManagerTest { + @Override public void setUp() throws Exception { @@ -46,16 +40,20 @@ public class MemoryTurbineModelManagerTe super.setUp(); } + + @Override public void tearDown() { super.tearDown(); - modelManager = null; + modelManager = null; securityService = null; } + /** - * Constructor for MemoryPermissionManagerTest. - * @param arg0 - */ + * Constructor for MemoryPermissionManagerTest. + * + * @param arg0 + */ public MemoryTurbineModelManagerTest(String arg0) { super(arg0); Modified: turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/authenticator/NTAuthenticator.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/authenticator/NTAuthenticator.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/authenticator/NTAuthenticator.java (original) +++ turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/authenticator/NTAuthenticator.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.authenticator; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -24,12 +25,13 @@ import org.apache.avalon.framework.logge import org.apache.fulcrum.security.entity.User; import org.apache.fulcrum.security.nt.ParseUtils; import org.apache.fulcrum.security.util.DataBackendException; +import org.apache.fulcrum.security.util.UnknownEntityException; import com.tagish.auth.win32.NTSystem; + /** - * This class authenticates a user against NT. Requires some - * extra libraries. - * + * This class authenticates a user against NT. Requires some extra libraries. + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ @@ -37,19 +39,20 @@ public class NTAuthenticator extends Abs { /** * Authenticate an username with the specified password. If authentication - * is successful the method returns true. If it fails, it returns false - * If there are any problems, an exception is thrown. - * - * - * @param usernameAndDomain an string in the format [domain]/[username]. - * @param password the user supplied password. - * @exception UnknownEntityException if the user's account does not - * exist in the database. - * @exception DataBackendException if there is a problem accessing the - * storage. + * is successful the method returns true. If it fails, it returns false If + * there are any problems, an exception is thrown. + * + * + * @param usernameAndDomain + * an string in the format [domain]/[username]. + * @param password + * the user supplied password. + * @exception UnknownEntityException + * if the user's account does not exist in the database. + * @exception DataBackendException + * if there is a problem accessing the storage. */ - public boolean authenticate(User user, String password) - throws DataBackendException + public boolean authenticate(User user, String password) throws DataBackendException { // check NT... boolean authenticated = false; Modified: turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/NTUserManagerImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/NTUserManagerImpl.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/NTUserManagerImpl.java (original) +++ turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/NTUserManagerImpl.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -31,14 +32,16 @@ import org.apache.fulcrum.security.util. import org.apache.fulcrum.security.util.UserSet; import com.tagish.auth.win32.NTSystem; + /** * This implementation attempts to manager users against NT. - * + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ public class NTUserManagerImpl extends AbstractUserManager { + @Override protected User persistNewUser(User user) throws DataBackendException { throw new RuntimeException("This method is not supported."); @@ -48,19 +51,21 @@ public class NTUserManagerImpl extends A * Retrieve a user from persistent storage using username as the key, and * authenticate the user. The implementation may chose to authenticate to * the server as the user whose data is being retrieved. - * - * @param userName the name of the user. - * @param password the user supplied password. + * + * @param userName + * the name of the user. + * @param password + * the user supplied password. * @return an User object. - * @exception PasswordMismatchException if the supplied password was - * incorrect. - * @exception UnknownEntityException if the user's account does not exist - * in the database. - * @exception DataBackendException if there is a problem accessing the - * storage. + * @exception PasswordMismatchException + * if the supplied password was incorrect. + * @exception UnknownEntityException + * if the user's account does not exist in the database. + * @exception DataBackendException + * if there is a problem accessing the storage. */ - public User getUser(String userName, String password) - throws PasswordMismatchException, UnknownEntityException, DataBackendException + @Override + public User getUser(String userName, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendException { User user = getUserInstance(userName); authenticate(user, password); @@ -69,14 +74,16 @@ public class NTUserManagerImpl extends A /** * Check whether a specified user's account exists. - * + * * The login name is used for looking up the account. - * - * @param user The user to be checked. + * + * @param user + * The user to be checked. * @return true if the specified account exists - * @throws DataBackendException if there was an error accessing the data - * backend. + * @throws DataBackendException + * if there was an error accessing the data backend. */ + @Override public boolean checkExists(User user) throws DataBackendException { boolean exists = false; @@ -95,15 +102,17 @@ public class NTUserManagerImpl extends A } return exists; } + /** * Check whether a specified user's account exists. - * + * * The login name is used for looking up the account. - * - * @param userName The name of the user to be checked. + * + * @param userName + * The name of the user to be checked. * @return true if the specified account exists - * @throws DataBackendException if there was an error accessing the data - * backend. + * @throws DataBackendException + * if there was an error accessing the data backend. */ public boolean checkExists(String userName) throws DataBackendException { @@ -113,16 +122,17 @@ public class NTUserManagerImpl extends A /** * Retrieve a user from persistent storage using username as the key. Not * supported currently. - * - * @param userName the name of the user. + * + * @param userName + * the name of the user. * @return an User object. - * @exception UnknownEntityException if the user's account does not exist - * in the database. - * @exception DataBackendException if there is a problem accessing the - * storage. + * @exception UnknownEntityException + * if the user's account does not exist in the database. + * @exception DataBackendException + * if there is a problem accessing the storage. */ - public User getUser(String userName) - throws UnknownEntityException, DataBackendException + @Override + public User getUser(String userName) throws UnknownEntityException, DataBackendException { throw new RuntimeException("Not supported by NT User Manager"); } @@ -130,20 +140,23 @@ public class NTUserManagerImpl extends A /** * Authenticate an User with the specified password. If authentication is * successful the method returns nothing. If there are any problems, - * exception was thrown. Additionally, if the User object is of type BasicUser - * or DynamicUser, then it will populate all the group information as well! - * - * @param user an User object to authenticate. - * @param password the user supplied password. - * @exception PasswordMismatchException if the supplied password was - * incorrect. - * @exception UnknownEntityException if the user's account does not exist - * in the database. - * @exception DataBackendException if there is a problem accessing the - * storage. + * exception was thrown. Additionally, if the User object is of type + * BasicUser or DynamicUser, then it will populate all the group information + * as well! + * + * @param user + * an User object to authenticate. + * @param password + * the user supplied password. + * @exception PasswordMismatchException + * if the supplied password was incorrect. + * @exception UnknownEntityException + * if the user's account does not exist in the database. + * @exception DataBackendException + * if there is a problem accessing the storage. */ - public void authenticate(User user, String password) - throws PasswordMismatchException, UnknownEntityException, DataBackendException + @Override + public void authenticate(User user, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendException { NTSystem ntSystem = new NTSystem(); char passwordArray[] = password.toCharArray(); @@ -154,22 +167,18 @@ public class NTUserManagerImpl extends A ntSystem.logon(username, passwordArray, domain); if (!ntSystem.getName().equalsIgnoreCase(username)) { - throw new PasswordMismatchException( - "Could not authenticate user " - + username - + " against domain " - + domain); + throw new PasswordMismatchException("Could not authenticate user " + username + " against domain " + domain); } String groups[] = ntSystem.getGroupNames(false); - for (int i = 0; i < groups.length; i++) + for (String group2 : groups) { // Note how it populates groups? This // should maybe delegate a call to the // group manager to look for groups it // knows about instead. Group group = getGroupManager().getGroupInstance(); - group.setName(groups[i]); - group.setId(groups[i]); + group.setName(group2); + group.setId(group2); if (user instanceof DynamicUser) { ((DynamicUser) user).addGroup(group); @@ -190,57 +199,65 @@ public class NTUserManagerImpl extends A /** * Removes an user account from the system. Not supported currently. - * - * @param user the object describing the account to be removed. - * @throws DataBackendException if there was an error accessing the data - * backend. - * @throws UnknownEntityException if the user account is not present. + * + * @param user + * the object describing the account to be removed. + * @throws DataBackendException + * if there was an error accessing the data backend. + * @throws UnknownEntityException + * if the user account is not present. */ - public void removeUser(User user) - throws DataBackendException, UnknownEntityException + public void removeUser(User user) throws DataBackendException, UnknownEntityException { throw new RuntimeException("Not supported by NT User Manager"); } + /** * Creates new user account with specified attributes. Not supported * currently. - * - * @param user the object describing account to be created. - * @param password The password to use for the account. - * - * @throws DataBackendException if there was an error accessing the data - * backend. - * @throws EntityExistsException if the user account already exists. + * + * @param user + * the object describing account to be created. + * @param password + * The password to use for the account. + * + * @throws DataBackendException + * if there was an error accessing the data backend. + * @throws EntityExistsException + * if the user account already exists. */ - public User addUser(User user, String password) - throws DataBackendException, EntityExistsException + @Override + public User addUser(User user, String password) throws DataBackendException, EntityExistsException { throw new RuntimeException("Not supported by NT User Manager"); } + /** * Stores User attributes. The User is required to exist in the system. Not * supported currently. - * - * @param role The User to be stored. - * @throws DataBackendException if there was an error accessing the data - * backend. - * @throws UnknownEntityException if the role does not exist. + * + * @param role + * The User to be stored. + * @throws DataBackendException + * if there was an error accessing the data backend. + * @throws UnknownEntityException + * if the role does not exist. */ - public void saveUser(User user) - throws DataBackendException, UnknownEntityException + public void saveUser(User user) throws DataBackendException, UnknownEntityException { throw new RuntimeException("Not supported by NT User Manager"); } - /** - * Retrieves all users defined in the system. - * - * @return the names of all users defined in the system. - * @throws DataBackendException if there was an error accessing the data backend. - */ - public UserSet getAllUsers() throws DataBackendException - { - throw new RuntimeException("Not supported by NT User Manager"); - } + /** + * Retrieves all users defined in the system. + * + * @return the names of all users defined in the system. + * @throws DataBackendException + * if there was an error accessing the data backend. + */ + public UserSet getAllUsers() throws DataBackendException + { + throw new RuntimeException("Not supported by NT User Manager"); + } } Modified: turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/ParseUtils.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/ParseUtils.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/ParseUtils.java (original) +++ turbine/fulcrum/trunk/security/nt/src/java/org/apache/fulcrum/security/nt/ParseUtils.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,7 +23,7 @@ import javax.security.auth.login.LoginEx /** * Utility class for parsing username and domain out of a single string. - * + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ Modified: turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicACLTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicACLTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicACLTest.java (original) +++ turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicACLTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -28,11 +29,12 @@ import org.apache.fulcrum.security.model import org.apache.fulcrum.security.util.DataBackendException; import org.apache.fulcrum.security.util.UnknownEntityException; import org.apache.fulcrum.testcontainer.BaseUnitTest; + /** - * - * Test the NT implementation of the user manager. This test traps some exceptions that can be - * thrown if there is NO nt dll. - * + * + * Test the NT implementation of the user manager. This test traps some + * exceptions that can be thrown if there is NO nt dll. + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ @@ -40,11 +42,12 @@ public class NTBasicACLTest extends Base { private static Log log = LogFactory.getLog(NTBasicACLTest.class); private static final String DOMAIN = "IQUITOS"; - private static final String GUESTUSER = DOMAIN + "/" + "Guest"; - private SecurityService securityService; - private UserManager userManager; - private User user; + private static final String GUESTUSER = DOMAIN + "/" + "Guest"; + private SecurityService securityService; + private UserManager userManager; + private User user; + @Override public void setUp() throws Exception { this.setRoleFileName("src/test/BasicNTRoleConfig.xml"); @@ -53,6 +56,7 @@ public class NTBasicACLTest extends Base userManager = securityService.getUserManager(); } + @Override public void tearDown() { user = null; @@ -62,7 +66,7 @@ public class NTBasicACLTest extends Base /** * Constructor for NTBasicACLTest. - * + * * @param arg0 */ public NTBasicACLTest(String arg0) @@ -74,17 +78,18 @@ public class NTBasicACLTest extends Base { try { - user = userManager.getUser(GUESTUSER, ""); + user = userManager.getUser(GUESTUSER, ""); user.setPassword(""); AccessControlList acl = userManager.getACL(user); assertTrue(acl instanceof BasicAccessControlList); - BasicAccessControlList bacl = (BasicAccessControlList)acl; - assertEquals(4,bacl.getGroups().size()); - assertTrue(bacl.hasGroup("Guests")); - assertTrue(bacl.hasGroup("gUEsts")); + BasicAccessControlList bacl = (BasicAccessControlList) acl; + assertEquals(4, bacl.getGroups().size()); + assertTrue(bacl.hasGroup("Guests")); + assertTrue(bacl.hasGroup("gUEsts")); } - catch(DataBackendException dbe){ - assertTrue(dbe.getMessage().indexOf(SCB_INVALID)>-1); + catch (DataBackendException dbe) + { + assertTrue(dbe.getMessage().indexOf(SCB_INVALID) > -1); } catch (UnknownEntityException re) { Modified: turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicModelManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicModelManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicModelManagerTest.java (original) +++ turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTBasicModelManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -28,11 +29,12 @@ import org.apache.fulcrum.security.model import org.apache.fulcrum.security.util.DataBackendException; import org.apache.fulcrum.security.util.UnknownEntityException; import org.apache.fulcrum.testcontainer.BaseUnitTest; + /** - * - * Test the NT implementation of the user manager. This test traps some exceptions that can be - * thrown if there is NO nt dll. - * + * + * Test the NT implementation of the user manager. This test traps some + * exceptions that can be thrown if there is NO nt dll. + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ @@ -44,6 +46,7 @@ public class NTBasicModelManagerTest ext private UserManager userManager; private User user; + @Override public void setUp() throws Exception { this.setRoleFileName("src/test/BasicNTRoleConfig.xml"); @@ -53,6 +56,7 @@ public class NTBasicModelManagerTest ext modelManager = (BasicModelManager) securityService.getModelManager(); } + @Override public void tearDown() { user = null; @@ -62,7 +66,7 @@ public class NTBasicModelManagerTest ext /** * Constructor for NTBasicModelManagerTest. - * + * * @param arg0 */ public NTBasicModelManagerTest(String arg0) @@ -79,8 +83,9 @@ public class NTBasicModelManagerTest ext modelManager.revokeAll(user); fail("Should throw runtime exception"); } - catch(DataBackendException dbe){ - assertTrue(dbe.getMessage().indexOf(SCB_INVALID)>-1); + catch (DataBackendException dbe) + { + assertTrue(dbe.getMessage().indexOf(SCB_INVALID) > -1); } catch (UnknownEntityException re) { @@ -112,7 +117,8 @@ public class NTBasicModelManagerTest ext { log.info("Unit test not being run due to missing NT DLL"); } - catch (java.lang.NoClassDefFoundError ncdfe){ + catch (java.lang.NoClassDefFoundError ncdfe) + { log.info("Unit test not being run due to missing NT DLL"); } } @@ -137,7 +143,8 @@ public class NTBasicModelManagerTest ext { log.info("Unit test not being run due to missing NT DLL"); } - catch (java.lang.NoClassDefFoundError ncdfe){ + catch (java.lang.NoClassDefFoundError ncdfe) + { log.info("Unit test not being run due to missing NT DLL"); } } Modified: turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTDynamicModelManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTDynamicModelManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTDynamicModelManagerTest.java (original) +++ turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTDynamicModelManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -28,13 +29,15 @@ import org.apache.fulcrum.security.model import org.apache.fulcrum.security.util.DataBackendException; import org.apache.fulcrum.security.util.UnknownEntityException; import org.apache.fulcrum.testcontainer.BaseUnitTest; + /** - * - * Test the NT implementation of the user manager. This test traps some exceptions that can be - * thrown if there is NO nt dll. - * + * + * Test the NT implementation of the user manager. This test traps some + * exceptions that can be thrown if there is NO nt dll. + * * @author <a href="mailto:[email protected]">Eric Pugh</a> - * @version $Id$ + * @version $Id: NTDynamicModelManagerTest.java 1374015 2012-08-16 19:48:54Z tv + * $ */ public class NTDynamicModelManagerTest extends BaseUnitTest implements TestConstants { @@ -44,6 +47,7 @@ public class NTDynamicModelManagerTest e private UserManager userManager; private User user; + @Override public void setUp() throws Exception { this.setRoleFileName("src/test/DynamicNTRoleConfig.xml"); @@ -53,6 +57,7 @@ public class NTDynamicModelManagerTest e modelManager = (DynamicModelManager) securityService.getModelManager(); } + @Override public void tearDown() { user = null; @@ -62,7 +67,7 @@ public class NTDynamicModelManagerTest e /** * Constructor for NTDynamicModelManagerTest. - * + * * @param arg0 */ public NTDynamicModelManagerTest(String arg0) @@ -79,8 +84,9 @@ public class NTDynamicModelManagerTest e modelManager.revokeAll(user); fail("Should throw runtime exception"); } - catch(DataBackendException dbe){ - assertTrue(dbe.getMessage().indexOf(SCB_INVALID)>-1); + catch (DataBackendException dbe) + { + assertTrue(dbe.getMessage().indexOf(SCB_INVALID) > -1); } catch (UnknownEntityException re) { @@ -112,7 +118,8 @@ public class NTDynamicModelManagerTest e { log.info("Unit test not being run due to missing NT DLL"); } - catch (java.lang.NoClassDefFoundError ncdfe){ + catch (java.lang.NoClassDefFoundError ncdfe) + { log.info("Unit test not being run due to missing NT DLL"); } } @@ -137,7 +144,8 @@ public class NTDynamicModelManagerTest e { log.info("Unit test not being run due to missing NT DLL"); } - catch (java.lang.NoClassDefFoundError ncdfe){ + catch (java.lang.NoClassDefFoundError ncdfe) + { log.info("Unit test not being run due to missing NT DLL"); } } Modified: turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTUserManagerTest.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTUserManagerTest.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTUserManagerTest.java (original) +++ turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/NTUserManagerTest.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -28,11 +29,12 @@ import org.apache.fulcrum.security.model import org.apache.fulcrum.security.util.DataBackendException; import com.tagish.auth.win32.NTSystem; + /** - * - * Test the NT implementation of the user manager. This test traps some exceptions that can be - * thrown if there is NO nt dll. - * + * + * Test the NT implementation of the user manager. This test traps some + * exceptions that can be thrown if there is NO nt dll. + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ @@ -45,6 +47,7 @@ public class NTUserManagerTest extends A private static final String PASSWORD = ""; private static final String GUESTUSER = DOMAIN + "/" + "Guest"; + @Override public void setUp() throws Exception { this.setRoleFileName("src/test/DynamicNTRoleConfig.xml"); @@ -53,6 +56,7 @@ public class NTUserManagerTest extends A userManager = securityService.getUserManager(); } + @Override public void tearDown() { user = null; @@ -62,7 +66,7 @@ public class NTUserManagerTest extends A /** * Constructor for NTUserManagerTest. - * + * * @param arg0 */ public NTUserManagerTest(String arg0) @@ -70,6 +74,7 @@ public class NTUserManagerTest extends A super(arg0); } + @Override public void testCheckExists() throws Exception { try @@ -78,8 +83,9 @@ public class NTUserManagerTest extends A user.setPassword(""); assertTrue(userManager.checkExists(user)); } - catch(DataBackendException dbe){ - assertTrue(dbe.getMessage().indexOf(SCB_INVALID)>-1); + catch (DataBackendException dbe) + { + assertTrue(dbe.getMessage().indexOf(SCB_INVALID) > -1); } catch (UnsatisfiedLinkError ule) { @@ -110,9 +116,7 @@ public class NTUserManagerTest extends A try { NTSystem ntSystem = new NTSystem(); - assertTrue( - "Name is eric:" + ntSystem.getName(), - USERNAME.equals(ntSystem.getName())); + assertTrue("Name is eric:" + ntSystem.getName(), USERNAME.equals(ntSystem.getName())); } catch (NoClassDefFoundError ule) { @@ -128,9 +132,7 @@ public class NTUserManagerTest extends A try { NTSystem ntSystem = new NTSystem(); - assertTrue( - "Domain is:" + ntSystem.getDomain(), - DOMAIN.equals(ntSystem.getDomain())); + assertTrue("Domain is:" + ntSystem.getDomain(), DOMAIN.equals(ntSystem.getDomain())); } catch (NoClassDefFoundError ule) { @@ -149,20 +151,14 @@ public class NTUserManagerTest extends A char password[] = "editor!".toCharArray(); ntSystem.logon(USERNAME, password, DOMAIN); String groups[] = ntSystem.getGroupNames(false); - for (int i = 0; i < groups.length; i++) + for (String group : groups) { - System.out.println("Groups :" + groups[i]); + System.out.println("Groups :" + group); } ntSystem.logoff(); - assertTrue( - "User is:" + ntSystem.getName(), - USERNAME.equals(ntSystem.getName())); - assertTrue( - "Domain is:" + ntSystem.getName(), - "IQUITOS".equals(ntSystem.getDomain())); - assertTrue( - "Primary Group is:" + ntSystem.getPrimaryGroupName(), - "None".equals(ntSystem.getPrimaryGroupName())); + assertTrue("User is:" + ntSystem.getName(), USERNAME.equals(ntSystem.getName())); + assertTrue("Domain is:" + ntSystem.getName(), "IQUITOS".equals(ntSystem.getDomain())); + assertTrue("Primary Group is:" + ntSystem.getPrimaryGroupName(), "None".equals(ntSystem.getPrimaryGroupName())); } catch (NoClassDefFoundError ule) { @@ -173,6 +169,7 @@ public class NTUserManagerTest extends A /* * test for User retrieve(String, String) */ + @Override public void testGetUserStringString() throws Exception { try @@ -187,6 +184,7 @@ public class NTUserManagerTest extends A } } + @Override public void testAuthenticate() throws Exception { try @@ -200,6 +198,7 @@ public class NTUserManagerTest extends A } } + @Override public void testGetACL() throws Exception { try @@ -219,22 +218,24 @@ public class NTUserManagerTest extends A /* * test for User retrieve(String, String) */ + @Override public void testGetAllUsers() throws Exception { try - { - userManager.getAllUsers(); - fail("Should throw runtime exception"); - } - catch (RuntimeException re) - { - assertTrue(re.getMessage().equals(ERROR_MSG)); - } + { + userManager.getAllUsers(); + fail("Should throw runtime exception"); + } + catch (RuntimeException re) + { + assertTrue(re.getMessage().equals(ERROR_MSG)); + } } /* * Class to test for User retrieve(String) */ + @Override public void testGetUserString() throws Exception { try @@ -248,6 +249,7 @@ public class NTUserManagerTest extends A } } + @Override public void testGetUserById() throws Exception { try @@ -261,6 +263,7 @@ public class NTUserManagerTest extends A } } + @Override public void testChangePassword() throws Exception { try @@ -281,6 +284,7 @@ public class NTUserManagerTest extends A } } + @Override public void testForcePassword() throws Exception { try @@ -301,6 +305,7 @@ public class NTUserManagerTest extends A } } + @Override public void testSaveUser() throws Exception { try @@ -314,6 +319,7 @@ public class NTUserManagerTest extends A } } + @Override public void testRemoveUser() throws Exception { try @@ -327,6 +333,7 @@ public class NTUserManagerTest extends A } } + @Override public void testAddUser() throws Exception { try @@ -356,6 +363,7 @@ public class NTUserManagerTest extends A /* * Override parent class, doesn't make sense.. */ + @Override public void testCheckExistsWithString() throws Exception { // empty @@ -364,6 +372,7 @@ public class NTUserManagerTest extends A /* * Override parent class, doesn't make sense.. */ + @Override public void testAddUserTwiceFails() throws Exception { // empty @@ -372,6 +381,7 @@ public class NTUserManagerTest extends A /* * Override parent class, doesn't make sense.. */ + @Override public void testCheckUserCaseSensitiveExists() throws Exception { // empty Modified: turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/TestConstants.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/TestConstants.java?rev=1374616&r1=1374615&r2=1374616&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/TestConstants.java (original) +++ turbine/fulcrum/trunk/security/nt/src/test/org/apache/fulcrum/security/nt/dynamic/TestConstants.java Sat Aug 18 17:26:07 2012 @@ -1,4 +1,5 @@ package org.apache.fulcrum.security.nt.dynamic; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -20,11 +21,11 @@ package org.apache.fulcrum.security.nt.d /** * Test constants - * + * * @author <a href="mailto:[email protected]">Eric Pugh</a> * @version $Id$ */ public interface TestConstants { - public static final String SCB_INVALID="The storage control block address is invalid."; + public static final String SCB_INVALID = "The storage control block address is invalid."; }
