X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=security%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fusermgt%2FUsermgtTestUtils.java;h=a8e1dd5154f33f1123160d7eb9acfc232bd530ee;hb=17775e14ecfb286e59f67117e5cee7e21e95ab1f;hp=07a376c544d74e65d23554291bf149d544f8b996;hpb=532f7219273021ef3652e0abe1326b7aeed1f30a;p=utils diff --git a/security/src/test/java/org/wamblee/usermgt/UsermgtTestUtils.java b/security/src/test/java/org/wamblee/usermgt/UsermgtTestUtils.java index 07a376c5..a8e1dd51 100644 --- a/security/src/test/java/org/wamblee/usermgt/UsermgtTestUtils.java +++ b/security/src/test/java/org/wamblee/usermgt/UsermgtTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2005 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,50 +13,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.wamblee.usermgt; import org.wamblee.security.encryption.Md5HexMessageDigester; + import org.wamblee.usermgt.UserMgtException.Reason; /** - * User management test utilities. - * + * User management test utilities. + * * @author Erik Brakkee */ public class UsermgtTestUtils { - private static final String DUMMY_GROUP = "dummygroup"; + private static final String DUMMY_PASSWD = "dummypasswd"; - public static Group createGroup(String aName) { + public static Group createGroup(String aName) { return new Group(aName); } - - public static User createUser(String aUsername) throws UserMgtException { + + public static User createUser(String aUsername) throws UserMgtException { return createUser(aUsername, DUMMY_GROUP); } - - public static User createUser(String aUsername, String aGroup) throws UserMgtException { - return createUser(aUsername, createGroup(aGroup)); + + public static User createUser(String aUsername, String aGroup) + throws UserMgtException { + return createUser(aUsername, createGroup(aGroup)); } - - public static User createUser(String aUsername, Group aGroup) throws UserMgtException { + + public static User createUser(String aUsername, Group aGroup) + throws UserMgtException { return createUser(aUsername, DUMMY_PASSWD, aGroup); } - - public static User createUser(String aName, String aPassword, Group aGroup) throws UserMgtException { - return new User(aName, aPassword, aGroup, - new RegexpNameValidator(RegexpNameValidator.PASSWORD_PATTERN, - Reason.INVALID_PASSWORD, "Password must be at least 6 chars"), - new Md5HexMessageDigester()); + + public static User createUser(String aName, String aPassword, Group aGroup) + throws UserMgtException { + return new User(aName, aPassword, aGroup, new RegexpNameValidator( + RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD, + "Password must be at least 6 chars"), new Md5HexMessageDigester()); } - - public static void addUserToGroup(User aUser, Group aGroup) throws UserMgtException { + + public static void addUserToGroup(User aUser, Group aGroup) + throws UserMgtException { aUser.addGroup(aGroup); } - - public static void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException { + + public static void removeUserFromGroup(User aUser, Group aGroup) + throws UserMgtException { aUser.removeGroup(aGroup); } }