From 3e8de23e00da80d5506c750a28e7d25f261eda92 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sat, 31 Jul 2010 17:32:15 +0000 Subject: [PATCH] --- .../authentication/AbstractUserSet.java | 3 +- .../security/authentication/GroupSet.java | 2 +- .../authentication/InMemoryUserSet.java | 7 +-- .../authentication/JaasUserAccessor.java | 2 +- .../authentication/Md5HexMessageDigester.java | 2 +- .../authentication/MessageDigester.java | 2 +- .../authentication/NameValidator.java | 4 +- .../wamblee/security/authentication/User.java | 11 ++-- .../security/authentication/UserAccessor.java | 2 +- .../authentication/UserAdminInitializer.java | 2 +- .../authentication/UserAdministration.java | 62 +++++++++++-------- .../UserAdministrationImpl.java | 5 +- .../authentication/UserMgtException.java | 2 +- .../security/authentication/UserSet.java | 16 ++--- .../authentication/jpa/JpaGroupSet.java | 8 ++- .../authentication/jpa/JpaUserSet.java | 13 ++-- .../security/authentication/package-info.java | 3 +- .../AbstractAuthorizationRule.java | 12 ++-- .../AbstractAuthorizationService.java | 38 ++++++------ .../AbstractOperationCondition.java | 12 ++-- .../authorization/AbstractPathCondition.java | 12 ++-- .../authorization/AbstractUserCondition.java | 12 ++-- .../security/authorization/AllOperation.java | 2 +- .../authorization/AnyUserCondition.java | 7 +-- .../authorization/AuthorizationException.java | 2 +- .../AuthorizationInitializer.java | 2 +- .../authorization/AuthorizationResult.java | 2 +- .../authorization/AuthorizationRule.java | 14 +++-- .../authorization/AuthorizationService.java | 11 ++-- .../authorization/CreateOperation.java | 2 +- .../DefaultOperationRegistry.java | 2 +- .../authorization/DeleteOperation.java | 2 +- .../authorization/GroupUserCondition.java | 12 ++-- .../authorization/IsaOperationCondition.java | 2 +- .../security/authorization/Operation.java | 2 +- .../authorization/OperationCondition.java | 2 +- .../authorization/OperationRegistry.java | 2 +- .../security/authorization/PathCondition.java | 2 +- .../security/authorization/ReadOperation.java | 2 +- .../authorization/RegexpPathCondition.java | 2 +- .../StartsWithPathCondition.java | 2 +- .../authorization/UrlAuthorizationRule.java | 20 +++--- .../security/authorization/UserCondition.java | 10 +-- .../authorization/WriteOperation.java | 2 +- .../jpa/JpaAuthorizationService.java | 2 +- .../security/authorization/package-info.java | 2 +- .../authentication/InMemoryGroupSetTest.java | 10 +-- .../authentication/MessageDigesterTest.java | 2 +- .../authentication/UsermgtTestUtils.java | 5 +- .../AuthorizationServiceTest.java | 13 ++-- .../DefaultOperationRegistryTest.java | 2 +- .../RegexpPathConditionTest.java | 2 +- .../StartsWithPathConditionTest.java | 2 +- .../authorization/TestAuthorizationRule.java | 2 +- .../security/authorization/TestResource.java | 2 +- .../authorization/TestUserAccessor.java | 32 +++++----- .../UrlAuthorizationRuleTest.java | 16 ++--- 57 files changed, 222 insertions(+), 208 deletions(-) diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/AbstractUserSet.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/AbstractUserSet.java index 04f59edc..7278f05a 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/AbstractUserSet.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/AbstractUserSet.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; - import static org.wamblee.security.authentication.UserMgtException.Reason.*; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/GroupSet.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/GroupSet.java index c6964a74..29842465 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/GroupSet.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/GroupSet.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.util.Set; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/InMemoryUserSet.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/InMemoryUserSet.java index 5988b40b..dd03f24b 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/InMemoryUserSet.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/InMemoryUserSet.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; - import java.util.Set; import java.util.TreeSet; @@ -99,9 +98,9 @@ public class InMemoryUserSet extends AbstractUserSet { public int size() { return users.size(); } - + @Override public void clearCache() { - // Empty + // Empty } } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java index 0ac6aa73..c86de356 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/JaasUserAccessor.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.security.AccessController; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/Md5HexMessageDigester.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/Md5HexMessageDigester.java index b992f5d7..1481ee76 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/Md5HexMessageDigester.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/Md5HexMessageDigester.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import org.apache.commons.codec.binary.Hex; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/MessageDigester.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/MessageDigester.java index 6e3b1f03..f30086fa 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/MessageDigester.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/MessageDigester.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/NameValidator.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/NameValidator.java index 910b345e..c0c7ef11 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/NameValidator.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/NameValidator.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; /** @@ -27,7 +27,7 @@ public interface NameValidator { * @param aName * Name * - * @return True iff the validationo is ok. + * @return True iff the validationo is ok. */ boolean validate(String aName); } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/User.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/User.java index 99774832..7d13197f 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/User.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/User.java @@ -85,13 +85,13 @@ public class User implements Serializable, Comparable { * Password validator. */ @Transient - private NameValidator passwordValidator; + private transient NameValidator passwordValidator; /** * Password encoder. */ @Transient - private MessageDigester passwordEncoder; + private transient MessageDigester passwordEncoder; /** * Constructs the user. @@ -376,13 +376,14 @@ public class User implements Serializable, Comparable { */ @Override public String toString() { - String result = "User(name=" + name + ", password=" + password; + StringBuffer result = new StringBuffer("User(name=" + name + ", password=" + password); for (Group group : groups) { - result += (", group=" + group); + result.append(", group=" + group); } + result.append(")"); - return result + ")"; + return result.toString(); } /* diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAccessor.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAccessor.java index 37d5eb73..352f657e 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAccessor.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAccessor.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java index 31a4d465..5b07ff48 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdminInitializer.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.util.logging.Logger; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministration.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministration.java index 7ed58086..74508b3e 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministration.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministration.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.util.List; @@ -50,31 +50,35 @@ public interface UserAdministration { * In case there is a conflict with an existing group. */ void createGroup(String aName); - + /** - * Checks if a user exists. - * @param aUser User to check. - * @return True iff user exists. + * Checks if a user exists. + * + * @param aUser + * User to check. + * @return True iff user exists. */ boolean checkUser(String aUser); - - + /** - * Check if a group exists. - * @param aGroup Group. - * @return True iff group exists. + * Check if a group exists. + * + * @param aGroup + * Group. + * @return True iff group exists. */ boolean checkGroup(String aGroup); - + /** * Checks the password. * - * @param aUser + * @param aUser * User to check password for. * @param aPassword * Password to check. - * @throws UserMgtException In case user does not exist. - * @return True iff password is ok. + * @throws UserMgtException + * In case user does not exist. + * @return True iff password is ok. */ boolean checkPassword(String aUser, String aPassword); @@ -82,16 +86,18 @@ public interface UserAdministration { * Changes the password. * * @param aUser - * User. + * User. * @param aOldPassword * Old password. * @param aNewPassword * New password. * - * @throws UserMgtException Inc ase the user does not exist. - * @return True if the password was changed. + * @throws UserMgtException + * Inc ase the user does not exist. + * @return True if the password was changed. */ - boolean changePassword(String aUser, String aOldPassword, String aNewPassword); + boolean changePassword(String aUser, String aOldPassword, + String aNewPassword); /** * @@ -100,18 +106,23 @@ public interface UserAdministration { * @param aPassword * The password to set. * - * @throws UserMgtException Inc ase the user does not exist. + * @throws UserMgtException + * Inc ase the user does not exist. */ void setPassword(String aUser, String aPassword); /** * Checks if the user belongs to the given group. - * @param aUser User - * @param aGroup Group. + * + * @param aUser + * User + * @param aGroup + * Group. * @return True iff user is in group - * @throws UserMgtException In case the user or group do not exist. + * @throws UserMgtException + * In case the user or group do not exist. */ - boolean isInGroup(String aUser, String aGroup); + boolean isInGroup(String aUser, String aGroup); /** * @@ -151,11 +162,12 @@ public interface UserAdministration { /** * Gets all groups for a given user. * - * @param aUser user. + * @param aUser + * user. * @return Groups. */ List getGroups(String aUser); - + /** * Renames a user. * diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java index 61505a9f..1a515db0 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserAdministrationImpl.java @@ -236,8 +236,9 @@ public class UserAdministrationImpl implements UserAdministration { group.setName(aNewGroup); groups.groupModified(group); - // Because a group has changed, a cached user could contain reference to an old copy of the - // group. Therefore, we clear the cache in this case. + // Because a group has changed, a cached user could contain reference to + // an old copy of the + // group. Therefore, we clear the cache in this case. users.clearCache(); } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserMgtException.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserMgtException.java index 744c0d8a..6f4f2b83 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserMgtException.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserMgtException.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.util.EnumMap; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserSet.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserSet.java index 7e6f9721..cbe216d9 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/UserSet.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/UserSet.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.util.Set; @@ -38,8 +38,7 @@ public interface UserSet { * @throws UserMgtException * In case the user cannot be created. */ - User createUser(String aUsername, String aPassword) - throws UserMgtException; + User createUser(String aUsername, String aPassword) throws UserMgtException; /** * Must be called whenever a user object has been modified to notify the @@ -81,9 +80,10 @@ public interface UserSet { boolean add(User aUser); /** - * Removes a user. - * - * @param aUser User to remove + * Removes a user. + * + * @param aUser + * User to remove * @return True iff user was removed. * */ @@ -110,9 +110,9 @@ public interface UserSet { * @return The number of users. */ int size(); - + /** - * Clears the user cache. + * Clears the user cache. */ void clearCache(); } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaGroupSet.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaGroupSet.java index c928b843..f15454ef 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaGroupSet.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaGroupSet.java @@ -36,8 +36,10 @@ public class JpaGroupSet implements GroupSet { private EntityManager em; /** - * Constructs the group set. - * @param aEm Contextual reference to an entity manager. + * Constructs the group set. + * + * @param aEm + * Contextual reference to an entity manager. */ public JpaGroupSet(EntityManager aEm) { em = aEm; @@ -50,7 +52,7 @@ public class JpaGroupSet implements GroupSet { return false; } em.persist(aGroup); - em.flush(); // to make sure the version is updated. + em.flush(); // to make sure the version is updated. return true; } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java index be3ebcdf..74609a1f 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/jpa/JpaUserSet.java @@ -64,7 +64,7 @@ public class JpaUserSet extends AbstractUserSet { public void userModified(User aUser) { assert aUser.getPrimaryKey() != null; User merged = entityManager.merge(aUser); - // Need to flush the entity manager to make sure the version is updated. + // Need to flush the entity manager to make sure the version is updated. entityManager.flush(); JpaMergeSupport.merge(merged, aUser); cache.remove(aUser.getName()); @@ -107,7 +107,7 @@ public class JpaUserSet extends AbstractUserSet { } entityManager.persist(aUser); - entityManager.flush(); // to make sure the version is updated. + entityManager.flush(); // to make sure the version is updated. setPasswordInfo(aUser); cache.put(aUser.getName(), aUser); @@ -147,7 +147,7 @@ public class JpaUserSet extends AbstractUserSet { TypedQuery query = entityManager.createNamedQuery( User.QUERY_FIND_BY_GROUP_NAME, User.class); query.setParameter(User.NAME_PARAM, aGroup.getName()); - + List list = query.getResultList(); users.addAll(list); for (User user : users) { @@ -159,12 +159,13 @@ public class JpaUserSet extends AbstractUserSet { @Override public int size() { - Long result = entityManager.createNamedQuery(User.QUERY_COUNT_USERS, Long.class).getSingleResult(); + Long result = entityManager.createNamedQuery(User.QUERY_COUNT_USERS, + Long.class).getSingleResult(); return result.intValue(); } - + @Override public void clearCache() { - cache.clear(); + cache.clear(); } } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authentication/package-info.java b/security/usermgt/src/main/java/org/wamblee/security/authentication/package-info.java index 7501a294..4118f2c3 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authentication/package-info.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authentication/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * This package provides support for managing users and their authentication. * @@ -75,3 +75,4 @@ *
*/ package org.wamblee.security.authentication; + diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java index 828a8915..9ac92424 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationRule.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorColumn; @@ -36,19 +36,19 @@ import javax.persistence.Version; @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "TYPE") public abstract class AbstractAuthorizationRule implements AuthorizationRule { - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Version private int version; - - public AbstractAuthorizationRule() { + + public AbstractAuthorizationRule() { // Empty } - - public AbstractAuthorizationRule(AbstractAuthorizationRule aRule) { + + public AbstractAuthorizationRule(AbstractAuthorizationRule aRule) { id = aRule.id; version = aRule.version; } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java index 79b9d3d0..2cbc4367 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractAuthorizationService.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorColumn; @@ -36,42 +36,40 @@ import javax.persistence.Version; @Table(name = "SEC_AUTH_SVC") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "TYPE") -@NamedQueries( - @NamedQuery(name = AbstractAuthorizationService.QUERY_FIND_BY_NAME, - query = "select s from AbstractAuthorizationService s where s.name = :" + - AbstractAuthorizationService.NAME_PARAM) - ) -public abstract class AbstractAuthorizationService implements AuthorizationService { - +@NamedQueries(@NamedQuery(name = AbstractAuthorizationService.QUERY_FIND_BY_NAME, query = "select s from AbstractAuthorizationService s where s.name = :" + + AbstractAuthorizationService.NAME_PARAM)) +public abstract class AbstractAuthorizationService implements + AuthorizationService { + public static final String QUERY_FIND_BY_NAME = "AuthorizationService.findByName"; public static final String NAME_PARAM = "name"; - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Version private int version; - + /** * Name for this instance of the authorization service. */ - private String name; - - public AbstractAuthorizationService() { - // Empty. + private String name; + + public AbstractAuthorizationService() { + // Empty. } - - public AbstractAuthorizationService(String aName) { - name = aName; + + public AbstractAuthorizationService(String aName) { + name = aName; } - - public AbstractAuthorizationService(AbstractAuthorizationService aSvc) { + + public AbstractAuthorizationService(AbstractAuthorizationService aSvc) { id = aSvc.id; version = aSvc.version; name = aSvc.name; } - + public String getName() { return name; } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractOperationCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractOperationCondition.java index f9333092..ccb893b1 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractOperationCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractOperationCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorColumn; @@ -35,19 +35,19 @@ import javax.persistence.Version; @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "TYPE") public abstract class AbstractOperationCondition implements OperationCondition { - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Version private int version; - - public AbstractOperationCondition() { + + public AbstractOperationCondition() { // Empty } - - public AbstractOperationCondition(AbstractOperationCondition aCondition) { + + public AbstractOperationCondition(AbstractOperationCondition aCondition) { id = aCondition.id; version = aCondition.version; } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractPathCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractPathCondition.java index f131dea3..7aaa0c83 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractPathCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractPathCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorColumn; @@ -35,19 +35,19 @@ import javax.persistence.Version; @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "TYPE") public abstract class AbstractPathCondition implements PathCondition { - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Version private int version; - - public AbstractPathCondition() { + + public AbstractPathCondition() { // Empty } - - public AbstractPathCondition(AbstractPathCondition aCondition) { + + public AbstractPathCondition(AbstractPathCondition aCondition) { id = aCondition.id; version = aCondition.version; } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java index 74487bce..07282989 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AbstractUserCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorColumn; @@ -35,19 +35,19 @@ import javax.persistence.Version; @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "TYPE") public abstract class AbstractUserCondition implements UserCondition { - + @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @Version private int version; - - public AbstractUserCondition() { + + public AbstractUserCondition() { // Empty. } - - public AbstractUserCondition(AbstractUserCondition aCondition) { + + public AbstractUserCondition(AbstractUserCondition aCondition) { id = aCondition.id; version = aCondition.version; } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AllOperation.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AllOperation.java index 83b7a4e0..913d1a6c 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AllOperation.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AllOperation.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java index 88ee8013..60764c43 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AnyUserCondition.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; - import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -36,10 +35,10 @@ public class AnyUserCondition extends AbstractUserCondition { public AnyUserCondition() { // Empty. } - + @Override public void setUserAdmin(UserAdministration aAdmin) { - // Empty. Don't need user admin. + // Empty. Don't need user admin. } @Override diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationException.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationException.java index e06a9144..d6735753 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationException.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationException.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationInitializer.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationInitializer.java index 3c6e7c7d..dab949ce 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationInitializer.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationInitializer.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import java.util.logging.Logger; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationResult.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationResult.java index e187caaa..b8ff5063 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationResult.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationResult.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java index 37ce1c87..4323ac9a 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationRule.java @@ -24,12 +24,14 @@ import org.wamblee.security.authentication.UserAdministration; * @author Erik Brakkee */ public interface AuthorizationRule { - + /** - * Sets the user admnistration to use. - * @param aAdmin User administration. + * Sets the user admnistration to use. + * + * @param aAdmin + * User administration. */ - void setUserAdministration(UserAdministration aAdmin); + void setUserAdministration(UserAdministration aAdmin); /** * Returns the supported object types for which this authorization rule @@ -54,7 +56,7 @@ public interface AuthorizationRule { * * @return Authorization result. */ - AuthorizationResult isAllowed(Object aResource, - Operation aOperation, String aUser); + AuthorizationResult isAllowed(Object aResource, Operation aOperation, + String aUser); } \ No newline at end of file diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationService.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationService.java index bfbe0f84..7f380ab2 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationService.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/AuthorizationService.java @@ -93,13 +93,14 @@ public interface AuthorizationService { * User accessor. */ void setUserAccessor(UserAccessor aUserAccessor); - + /** - * Sets the user administration so that the authorization service can check + * Sets the user administration so that the authorization service can check * information for the the current user. - * - * @param aUserAdmin User administration. + * + * @param aUserAdmin + * User administration. */ - void setUserAdministration(UserAdministration aUserAdmin); + void setUserAdministration(UserAdministration aUserAdmin); } \ No newline at end of file diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/CreateOperation.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/CreateOperation.java index 7a6214df..9611d0b6 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/CreateOperation.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/CreateOperation.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java index 2ebce1c7..0a548975 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/DefaultOperationRegistry.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import java.util.ArrayList; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/DeleteOperation.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/DeleteOperation.java index 14901149..09e58b87 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/DeleteOperation.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/DeleteOperation.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java index f50c3d12..234c75c1 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/GroupUserCondition.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; - import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; @@ -23,7 +22,6 @@ import javax.persistence.Transient; import org.wamblee.security.authentication.UserAdministration; - /** * Checks if a user against a specific group. * @@ -37,9 +35,9 @@ public class GroupUserCondition extends AbstractUserCondition { */ @Column(name = "GRP") private String group; - + @Transient - private UserAdministration admin; + private UserAdministration admin; /** * Constructs the condition. @@ -58,10 +56,10 @@ public class GroupUserCondition extends AbstractUserCondition { protected GroupUserCondition() { group = null; } - + @Override public void setUserAdmin(UserAdministration aAdmin) { - admin = aAdmin; + admin = aAdmin; } @Override diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java index b42f5d0e..3e43069f 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/IsaOperationCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.Access; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/Operation.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/Operation.java index 54a959e4..87ff1990 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/Operation.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/Operation.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationCondition.java index 06ef988b..e8cb48c4 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationRegistry.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationRegistry.java index 0986148d..42465857 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationRegistry.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/OperationRegistry.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/PathCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/PathCondition.java index 0fd91916..e25594da 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/PathCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/PathCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/ReadOperation.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/ReadOperation.java index 2ff67b53..73547eee 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/ReadOperation.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/ReadOperation.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java index e40d4aca..c740391c 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/RegexpPathCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorValue; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/StartsWithPathCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/StartsWithPathCondition.java index 9233d800..0e58c39d 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/StartsWithPathCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/StartsWithPathCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import javax.persistence.DiscriminatorValue; diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java index 2aa759cb..a9a941a3 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/UrlAuthorizationRule.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import static org.wamblee.security.authorization.AuthorizationResult.*; @@ -42,8 +42,8 @@ import org.wamblee.security.authentication.UserAdministration; * appropriate is determined by a * {@link org.wamblee.security.authorization.AbstractUserCondition}. *
  • The operation that is requested. Whether the operation is appropriate is - * determined by a {@link org.wamblee.security.authorization.AbstractOperationCondition} - * .
  • + * determined by a + * {@link org.wamblee.security.authorization.AbstractOperationCondition} . * * In case all three conditions match, the condition returns the configured * result passed at construction (GRANTED or DENIED). If the resource is not of @@ -79,7 +79,7 @@ public abstract class UrlAuthorizationRule extends AbstractAuthorizationRule { /** * Operation that this rule is for. */ - + private OperationCondition operationCondition; /** @@ -177,8 +177,8 @@ public abstract class UrlAuthorizationRule extends AbstractAuthorizationRule { * * @return Authorization result, */ - protected AuthorizationResult isAllowedWithPath(String aPath, Operation aOperation, - String aUser) { + protected AuthorizationResult isAllowedWithPath(String aPath, + Operation aOperation, String aUser) { if (!pathCondition.matches(aPath)) { return UNDECIDED; } @@ -254,8 +254,8 @@ public abstract class UrlAuthorizationRule extends AbstractAuthorizationRule { try { resourceClass = Class.forName(aResourceClass); } catch (ClassNotFoundException e) { - LOGGER.log(Level.SEVERE, "Cannot find resource class '" + aResourceClass + "'", - e); + LOGGER.log(Level.SEVERE, "Cannot find resource class '" + + aResourceClass + "'", e); throw new IllegalArgumentException(e.getMessage(), e); } } @@ -316,10 +316,10 @@ public abstract class UrlAuthorizationRule extends AbstractAuthorizationRule { protected void setUserCondition(UserCondition aUserCondition) { userCondition = aUserCondition; } - + @Override public void setUserAdministration(UserAdministration aAdmin) { - userCondition.setUserAdmin(aAdmin); + userCondition.setUserAdmin(aAdmin); } } diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/UserCondition.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/UserCondition.java index af0feb04..4e9df78b 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/UserCondition.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/UserCondition.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import org.wamblee.security.authentication.UserAdministration; @@ -23,10 +23,12 @@ import org.wamblee.security.authentication.UserAdministration; * @author Erik Brakkee */ public interface UserCondition { - + /** - * Sets the user administration object. - * @param aAdmin User administration. + * Sets the user administration object. + * + * @param aAdmin + * User administration. */ void setUserAdmin(UserAdministration aAdmin); diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/WriteOperation.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/WriteOperation.java index 5819f422..4b0c91e7 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/WriteOperation.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/WriteOperation.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java index 43bfee33..b3d501c2 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/jpa/JpaAuthorizationService.java @@ -190,7 +190,7 @@ public class JpaAuthorizationService implements AuthorizationService { // been made. service.set(null); } - + /* * (non-Javadoc) * diff --git a/security/usermgt/src/main/java/org/wamblee/security/authorization/package-info.java b/security/usermgt/src/main/java/org/wamblee/security/authorization/package-info.java index 2977aa6e..43d331de 100644 --- a/security/usermgt/src/main/java/org/wamblee/security/authorization/package-info.java +++ b/security/usermgt/src/main/java/org/wamblee/security/authorization/package-info.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ /** * The authorization package provides an authorization service that can be used to * check whether users have the rights to perform certain operations. diff --git a/security/usermgt/src/test/java/org/wamblee/security/authentication/InMemoryGroupSetTest.java b/security/usermgt/src/test/java/org/wamblee/security/authentication/InMemoryGroupSetTest.java index 9ff7a4a6..56a298a3 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authentication/InMemoryGroupSetTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authentication/InMemoryGroupSetTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import java.util.Set; @@ -197,10 +197,10 @@ public class InMemoryGroupSetTest extends TestCase { checkGroupCount(3); } - - public void testRenameGroupTwice() { - Group group = new Group("x"); - groups.add(group); + + public void testRenameGroupTwice() { + Group group = new Group("x"); + groups.add(group); groups.groupModified(group); group.setName("y"); groups.groupModified(group); diff --git a/security/usermgt/src/test/java/org/wamblee/security/authentication/MessageDigesterTest.java b/security/usermgt/src/test/java/org/wamblee/security/authentication/MessageDigesterTest.java index d5b4f854..9ca01e8f 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authentication/MessageDigesterTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authentication/MessageDigesterTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import org.wamblee.security.authentication.Md5HexMessageDigester; diff --git a/security/usermgt/src/test/java/org/wamblee/security/authentication/UsermgtTestUtils.java b/security/usermgt/src/test/java/org/wamblee/security/authentication/UsermgtTestUtils.java index 234ed266..0e8f1095 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authentication/UsermgtTestUtils.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authentication/UsermgtTestUtils.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authentication; import org.wamblee.security.authentication.Group; @@ -21,7 +21,6 @@ import org.wamblee.security.authentication.User; import org.wamblee.security.authentication.UserMgtException; import org.wamblee.security.authentication.UserMgtException.Reason; - /** * User management test utilities. * @@ -56,7 +55,7 @@ public class UsermgtTestUtils { RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD, "Password must be at least 6 chars"), new Md5HexMessageDigester()); user.addGroup(aGroup); - return user; + return user; } public static void addUserToGroup(User aUser, Group aGroup) diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java index 3e6f1594..bcd0a4ca 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/AuthorizationServiceTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import static org.wamblee.security.authorization.AuthorizationResult.*; @@ -36,7 +36,6 @@ public class AuthorizationServiceTest extends TestCase { private AuthorizationService service; private TestUserAccessor userAccessor; - protected AuthorizationService getService() { return service; @@ -51,8 +50,8 @@ public class AuthorizationServiceTest extends TestCase { protected void setUp() throws Exception { super.setUp(); - userAccessor = new TestUserAccessor(); - + userAccessor = new TestUserAccessor(); + rule1 = createRule(GRANTED, "users", "/oni/", AllOperation.class); rule2 = createRule(DENIED, "users", "/abc/", ReadOperation.class); rule3 = createRule(GRANTED, "users", "/abc/", AllOperation.class); @@ -71,10 +70,10 @@ public class AuthorizationServiceTest extends TestCase { } protected UserAccessor getUserAccessor() { - return userAccessor; + return userAccessor; } - - protected UserAdministration getUserAdministration() { + + protected UserAdministration getUserAdministration() { return userAccessor.getUserAdmin(); } diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java index e09f7fa1..444b589a 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/DefaultOperationRegistryTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import junit.framework.TestCase; diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/RegexpPathConditionTest.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/RegexpPathConditionTest.java index 5876c46f..cba57657 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/RegexpPathConditionTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/RegexpPathConditionTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import junit.framework.TestCase; diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/StartsWithPathConditionTest.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/StartsWithPathConditionTest.java index 49666ce0..64536ff5 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/StartsWithPathConditionTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/StartsWithPathConditionTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import junit.framework.TestCase; diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java index d633840b..986d62bd 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/TestAuthorizationRule.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import static org.wamblee.security.authorization.AuthorizationResult.*; diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/TestResource.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/TestResource.java index cb600d73..776a8e7f 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/TestResource.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/TestResource.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; /** diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java index e4cc232e..f04a10ed 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import org.wamblee.security.authentication.InMemoryGroupSet; @@ -24,7 +24,6 @@ import org.wamblee.security.authentication.UserAdministration; import org.wamblee.security.authentication.UserAdministrationImpl; import org.wamblee.security.authentication.UserMgtException.Reason; - /** * User access that always returns a user that belongs to a fixed group. * @@ -37,31 +36,32 @@ public class TestUserAccessor implements UserAccessor { private static final String GROUP = "users"; - private UserAdministration userAdmin; - - public TestUserAccessor() { - userAdmin = new UserAdministrationImpl( - new InMemoryUserSet(new RegexpNameValidator( - RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD, + private UserAdministration userAdmin; + + public TestUserAccessor() { + userAdmin = new UserAdministrationImpl(new InMemoryUserSet( + new RegexpNameValidator(RegexpNameValidator.PASSWORD_PATTERN, + Reason.INVALID_PASSWORD, "Password must contain at least 6 characters"), - new Md5HexMessageDigester()), new InMemoryGroupSet(), + new Md5HexMessageDigester()), new InMemoryGroupSet(), new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, Reason.INVALID_USERNAME, "Invalid user"), new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, Reason.INVALID_GROUPNAME, "Invalid group")); - userAdmin.createGroup(GROUP); - userAdmin.createUser(USER, PASSWORD); - userAdmin.addUserToGroup(USER, GROUP); + userAdmin.createGroup(GROUP); + userAdmin.createUser(USER, PASSWORD); + userAdmin.addUserToGroup(USER, GROUP); } - + // NOTE: This is only for test. Normally the user accessor would not depend - // on user administration. This just ensures that a user administration is created - // that knows about the given user. + // on user administration. This just ensures that a user administration is + // created + // that knows about the given user. public UserAdministration getUserAdmin() { return userAdmin; } - + /* * (non-Javadoc) * diff --git a/security/usermgt/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java b/security/usermgt/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java index 335a606e..766c180a 100644 --- a/security/usermgt/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java +++ b/security/usermgt/src/test/java/org/wamblee/security/authorization/UrlAuthorizationRuleTest.java @@ -12,7 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.security.authorization; import static org.wamblee.security.authorization.AuthorizationResult.*; @@ -25,14 +25,14 @@ import junit.framework.TestCase; * @author Erik Brakkee */ public class UrlAuthorizationRuleTest extends TestCase { - - private TestUserAccessor userAccessor; - - public void setUp() { - userAccessor = new TestUserAccessor(); - + + private TestUserAccessor userAccessor; + + public void setUp() { + userAccessor = new TestUserAccessor(); + } - + /** * Constructs the rule with a result of UNDECIDED. Verifies that an * IllegalArgumentException is thrown. -- 2.31.1