Author: painter Date: Mon Nov 5 21:14:02 2018 New Revision: 1845858 URL: http://svn.apache.org/viewvc?rev=1845858&view=rev Log: Javadoc cleanup!
Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/GroupManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/PermissionManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/RoleManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/UserManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/CryptoAuthenticator.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/NoOpAuthenticator.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/TextMatchAuthenticator.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicACLFactory.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlList.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlListImpl.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicModelManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/BasicGroup.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/impl/BasicGroupImpl.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicAccessControlListImpl.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicModelManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/impl/DynamicRoleImpl.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineACLFactory.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineModelManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineUserManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbinePermission.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineRole.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineUserGroupRoleEntity.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/impl/TurbineRoleImpl.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/session/Session.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractGroupManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractPermissionManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractRoleManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractUserManager.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/util/GroupSet.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/util/PermissionSet.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/util/RoleSet.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/util/SecuritySet.java turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/util/UserSet.java turbine/fulcrum/trunk/security/api/src/test/org/apache/fulcrum/security/model/basic/test/AbstractModelManagerTest.java turbine/fulcrum/trunk/security/api/src/test/org/apache/fulcrum/security/model/test/AbstractGroupManagerTest.java turbine/fulcrum/trunk/security/api/src/test/org/apache/fulcrum/security/model/test/AbstractPermissionManagerTest.java turbine/fulcrum/trunk/security/api/src/test/org/apache/fulcrum/security/model/test/AbstractRoleManagerTest.java turbine/fulcrum/trunk/security/api/src/test/org/apache/fulcrum/security/model/test/AbstractUserManagerTest.java Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/GroupManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/GroupManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/GroupManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/GroupManager.java Mon Nov 5 21:14:02 2018 @@ -88,8 +88,8 @@ public interface GroupManager extends Se /** * Retrieve a Group object with specified Id. * - * @param name - * the name of the Group. + * @param id + * the Id of the Group. * * @return an object representing the Group with specified name. * @@ -151,13 +151,11 @@ public interface GroupManager extends Se /** * Determines if the <code>Group</code> exists in the security system. * - * @param permission + * @param group * a <code>Group</code> value * @return true if the group exists in the system, false otherwise * @throws DataBackendException * when more than one group with the same name exists. - * @throws Exception - * A generic exception. */ boolean checkExists(Group group) throws DataBackendException; @@ -170,8 +168,6 @@ public interface GroupManager extends Se * @return true if the group exists in the system, false otherwise * @throws DataBackendException * when more than one group with the same name exists. - * @throws Exception - * A generic exception. */ - boolean checkExists(String group) throws DataBackendException; + boolean checkExists(String groupName) throws DataBackendException; } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/PermissionManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/PermissionManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/PermissionManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/PermissionManager.java Mon Nov 5 21:14:02 2018 @@ -52,9 +52,8 @@ public interface PermissionManager exten * the default constructor. * * @return an object implementing Permission interface. - * @throws UnknownEntityException - * if the object could not be instantiated. - * @throws DataBackendException + * @throws DataBackendException + * if there was an error accessing the data backend. */ <T extends Permission> T getPermissionInstance() throws DataBackendException; @@ -68,8 +67,8 @@ public interface PermissionManager exten * The name of the Permission * * @return an object implementing Permission interface. - * @throws UnknownEntityException - * if the object could not be instantiated. + * @throws DataBackendException + * if there was an error accessing the data backend. */ <T extends Permission> T getPermissionInstance(String permName) throws DataBackendException; @@ -89,8 +88,8 @@ public interface PermissionManager exten /** * Retrieve a Permission object with specified Id. * - * @param name - * the name of the Permission. + * @param id + * the Id of the Permission. * * @return an object representing the Permission with specified name. * @@ -157,8 +156,6 @@ public interface PermissionManager exten * @return true if the permission exists in the system, false otherwise * @throws DataBackendException * when more than one Permission with the same name exists. - * @throws Exception - * A generic exception. */ boolean checkExists(Permission permission) throws DataBackendException; @@ -171,8 +168,6 @@ public interface PermissionManager exten * @return true if the permission exists in the system, false otherwise * @throws DataBackendException * when more than one Permission with the same name exists. - * @throws Exception - * A generic exception. */ boolean checkExists(String permissionName) throws DataBackendException; } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/RoleManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/RoleManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/RoleManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/RoleManager.java Mon Nov 5 21:14:02 2018 @@ -45,14 +45,13 @@ public interface RoleManager extends Ser String ROLE = RoleManager.class.getName(); /** - * Construct a blank Role object. + * Construct a blank Role object * * This method calls getRoleClass, and then creates a new object using the * default constructor. - * + * * @return an object implementing Role interface. - * @throws DataBackendException - * if the object could not be instantiated. + * @throws DataBackendException if the object could not be instantiated */ <T extends Role> T getRoleInstance() throws DataBackendException; @@ -87,8 +86,8 @@ public interface RoleManager extends Ser /** * Retrieve a Role object with specified Id. * - * @param name - * the name of the Role. + * @param id + * the Id of the Role. * * @return an object representing the Role with specified name. * @@ -155,8 +154,6 @@ public interface RoleManager extends Ser * @return true if the role exists in the system, false otherwise * @throws DataBackendException * when more than one Role with the same name exists. - * @throws Exception - * A generic exception. */ boolean checkExists(Role role) throws DataBackendException; @@ -169,8 +166,6 @@ public interface RoleManager extends Ser * @return true if the role exists in the system, false otherwise * @throws DataBackendException * when more than one Role with the same name exists. - * @throws Exception - * A generic exception. */ boolean checkExists(String roleName) throws DataBackendException; } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/UserManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/UserManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/UserManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/UserManager.java Mon Nov 5 21:14:02 2018 @@ -77,13 +77,11 @@ public interface UserManager extends Ser /** * Determines if the <code>User</code> exists in the security system. * - * @param role + * @param user * a <code>User</code> value * @return true if the user exists in the system, false otherwise * @throws DataBackendException * when more than one user with the same name exists. - * @throws Exception - * A generic exception. */ boolean checkExists(User user) throws DataBackendException; @@ -106,9 +104,9 @@ public interface UserManager extends Ser * @param username * the name of the user. * @return an User object. - * @exception UnknownEntityException + * @throws UnknownEntityException * if the user's record does not exist in the database. - * @exception DataBackendException + * @throws DataBackendException * if there is a problem accessing the storage. */ <T extends User> T getUser(String username) throws UnknownEntityException, DataBackendException; @@ -119,9 +117,9 @@ public interface UserManager extends Ser * @param id * the id of the user. * @return an User object. - * @exception UnknownEntityException + * @throws UnknownEntityException * if the user's record does not exist in the database. - * @exception DataBackendException + * @throws DataBackendException * if there is a problem accessing the storage. */ <T extends User> T getUserById(Object id) throws UnknownEntityException, DataBackendException; @@ -136,11 +134,11 @@ public interface UserManager extends Ser * @param password * the user supplied password. * @return an User object. - * @exception PasswordMismatchException + * @throws PasswordMismatchException * if the supplied password was incorrect. - * @exception UnknownEntityException + * @throws UnknownEntityException * if the user's record does not exist in the database. - * @exception DataBackendException + * @throws DataBackendException * if there is a problem accessing the storage. */ <T extends User> T getUser(String username, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendException; @@ -176,11 +174,11 @@ public interface UserManager extends Ser * an User object to authenticate. * @param password * the user supplied password. - * @exception PasswordMismatchException + * @throws PasswordMismatchException * if the supplied password was incorrect. - * @exception UnknownEntityException + * @throws UnknownEntityException * if the user's record does not exist in the database. - * @exception DataBackendException + * @throws DataBackendException * if there is a problem accessing the storage. */ void authenticate(User user, String password) throws PasswordMismatchException, UnknownEntityException, DataBackendException; @@ -193,6 +191,8 @@ public interface UserManager extends Ser * @param password * The password to use for the object creation * + * @return User the user added + * * @throws DataBackendException * if there was an error accessing the data backend. * @throws EntityExistsException @@ -221,11 +221,11 @@ public interface UserManager extends Ser * the current password suplied by the user. * @param newPassword * the current password requested by the user. - * @exception PasswordMismatchException + * @throws PasswordMismatchException * if the supplied password was incorrect. - * @exception UnknownEntityException + * @throws UnknownEntityException * if the user's record does not exist in the database. - * @exception DataBackendException + * @throws DataBackendException * if there is a problem accessing the storage. */ void changePassword(User user, String oldPassword, String newPassword) throws PasswordMismatchException, UnknownEntityException, @@ -243,9 +243,9 @@ public interface UserManager extends Ser * an User to change password for. * @param password * the new password. - * @exception UnknownEntityException + * @throws UnknownEntityException * if the user's record does not exist in the database. - * @exception DataBackendException + * @throws DataBackendException * if there is a problem accessing the storage. */ void forcePassword(User user, String password) throws UnknownEntityException, DataBackendException; @@ -253,7 +253,8 @@ public interface UserManager extends Ser /** * Return a Class object representing the system's chosen implementation of * of ACL interface. - * + * + * @param user the user * @return systems's chosen implementation of ACL interface. * @throws UnknownEntityException * if the implementation of ACL interface could not be Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/CryptoAuthenticator.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/CryptoAuthenticator.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/CryptoAuthenticator.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/CryptoAuthenticator.java Mon Nov 5 21:14:02 2018 @@ -36,12 +36,13 @@ import org.apache.fulcrum.security.util. /** * This class authenticates using the Fulcrum Crypto service a user and their * password + * + * avalon.component name="crypto-authenticator" + * avalon.service type="org.apache.fulcrum.security.authenticator.Authenticator" * * @author <a href="mailto:ep...@upstate.com">Eric Pugh</a> * @version $Id$ - * @avalon.component name="crypto-authenticator" - * @avalon.service - * type="org.apache.fulcrum.security.authenticator.Authenticator" + * */ public class CryptoAuthenticator extends AbstractLogEnabled implements Authenticator, Serviceable, Disposable, Configurable { @@ -83,8 +84,8 @@ public class CryptoAuthenticator extends } // ---------------- Avalon Lifecycle Methods --------------------- - /** - * Avalon component lifecycle method + /* (non-Javadoc) + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) */ @Override public void configure(Configuration conf) throws ConfigurationException @@ -93,8 +94,8 @@ public class CryptoAuthenticator extends cipher = conf.getChild("cipher").getValue(); } - /** - * Avalon component lifecycle method + /* (non-Javadoc) + * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager) */ @Override public void service(ServiceManager manager) throws ServiceException @@ -102,8 +103,8 @@ public class CryptoAuthenticator extends this.cryptoService = (CryptoService) manager.lookup(CryptoService.ROLE); } - /** - * Avalon component lifecycle method + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Disposable#dispose() */ @Override public void dispose() Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/NoOpAuthenticator.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/NoOpAuthenticator.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/NoOpAuthenticator.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/NoOpAuthenticator.java Mon Nov 5 21:14:02 2018 @@ -25,30 +25,22 @@ import org.apache.fulcrum.security.util. /** * This class authenticates by returning TRUE always. Regardless of the user and * password data. + * + * + * avalon.component name="noop-authenticator" avalon.service + * type="org.apache.fulcrum.security.authenticator.Authenticator" * * @author <a href="mailto:ep...@upstate.com">Eric Pugh</a> * @version $Id$ - * @avalon.component name="noop-authenticator" - * @avalon.service - * type="org.apache.fulcrum.security.authenticator.Authenticator" + * */ -public class NoOpAuthenticator extends AbstractLogEnabled implements Authenticator -{ - /** - * Authenticate an username with the specified password. Always returns - * true. - * - * - * @param user - * object - * @param password - * the user supplied password. - * @exception DataBackendException - * if there is a problem accessing the storage. - */ - @Override - public boolean authenticate(User user, String password) throws DataBackendException - { - return true; - } +public class NoOpAuthenticator extends AbstractLogEnabled implements Authenticator { + + /* (non-Javadoc) + * @see org.apache.fulcrum.security.authenticator.Authenticator#authenticate(org.apache.fulcrum.security.entity.User, java.lang.String) + */ + @Override + public boolean authenticate(User user, String password) throws DataBackendException { + return true; + } } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/TextMatchAuthenticator.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/TextMatchAuthenticator.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/TextMatchAuthenticator.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/authenticator/TextMatchAuthenticator.java Mon Nov 5 21:14:02 2018 @@ -25,38 +25,31 @@ import org.apache.fulcrum.security.util. /** * This class authenticates by doing a plain text match of the user's passwords. * Very insecure! + * + * avalon.component name="textmatch-authenticator" avalon.service + * type="org.apache.fulcrum.security.authenticator.Authenticator" * * @author <a href="mailto:ep...@upstate.com">Eric Pugh</a> * @version $Id$ - * @avalon.component name="textmatch-authenticator" - * @avalon.service - * type="org.apache.fulcrum.security.authenticator.Authenticator" + * */ -public class TextMatchAuthenticator extends AbstractLogEnabled implements Authenticator -{ - /** - * Authenticate an username with the specified password. Returns true if the - * user password plain text matches the passed in password. - * - * - * @param user - * object - * @param password - * the user supplied password. - * @exception DataBackendException - * if there is a problem accessing the storage. - */ - @Override - public boolean authenticate(User user, String password) throws DataBackendException - { - if (user == null) - { - return false; - } +public class TextMatchAuthenticator extends AbstractLogEnabled implements Authenticator { + /** + * Authenticate an username with the specified password. Returns true if the + * user password plain text matches the passed in password. + * + * @param user object + * @param password the user supplied password. + * @exception DataBackendException if there is a problem accessing the storage. + */ + @Override + public boolean authenticate(User user, String password) throws DataBackendException { + if (user == null) { + return false; + } - String referenced = user.getPassword() == null ? "" : user.getPassword().trim(); - String tested = password == null ? "" : password.trim(); - - return referenced.equals(tested); - } + String referenced = user.getPassword() == null ? "" : user.getPassword().trim(); + String tested = password == null ? "" : password.trim(); + return referenced.equals(tested); + } } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/entity/impl/SecurityEntityImpl.java Mon Nov 5 21:14:02 2018 @@ -1,5 +1,7 @@ package org.apache.fulcrum.security.entity.impl; +import org.apache.commons.lang3.StringUtils; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -37,7 +39,7 @@ public class SecurityEntityImpl implemen private Object id; /** - * @return + * @return object id */ public Object getId() { @@ -45,7 +47,7 @@ public class SecurityEntityImpl implemen } /** - * @param id + * @param id the object id */ public void setId(Object id) { @@ -53,7 +55,7 @@ public class SecurityEntityImpl implemen } /** - * @return + * @return object name */ public String getName() { @@ -63,16 +65,15 @@ public class SecurityEntityImpl implemen /** * Pass in the name for this entity. Also lowercases it. * - * @param name + * @param name name of entity + * @throws IllegalArgumentException must provide a name */ - public void setName(String name) + public void setName(String name) throws IllegalArgumentException { - if (name == null) - { + if (StringUtils.isEmpty(name)) throw new IllegalArgumentException("Must provide a valid name for all SecurityEntities."); - } - - this.name = name.toLowerCase(); + else + this.name = name.toLowerCase(); } @Override Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicACLFactory.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicACLFactory.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicACLFactory.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicACLFactory.java Mon Nov 5 21:14:02 2018 @@ -41,10 +41,8 @@ public class BasicACLFactory extends Abs * This constructs a new ACL object from the configured class and * initializes it with the supplied roles and permissions. * - * @param roles - * The roles that this ACL should contain - * @param permissions - * The permissions for this ACL + * @param groupSet + * The GroupSet that this ACL should contain * * @return an object implementing ACL interface. * @throws UnknownEntityException @@ -66,6 +64,9 @@ public class BasicACLFactory extends Abs return accessControlList; } + /* (non-Javadoc) + * @see org.apache.fulcrum.security.model.ACLFactory#getAccessControlList(org.apache.fulcrum.security.entity.User) + */ public <T extends AccessControlList> T getAccessControlList(User user) { GroupSet groupSet = ((BasicUser) user).getGroups(); Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlList.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlList.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlList.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlList.java Mon Nov 5 21:14:02 2018 @@ -45,7 +45,7 @@ public interface BasicAccessControlList /** * Checks if the user is assigned a specific Group * - * @param role + * @param group * the Group * @return <code>true</code> if the user is assigned to the Group */ @@ -54,7 +54,7 @@ public interface BasicAccessControlList /** * Checks if the user is assigned a specific Group * - * @param role + * @param group * the group name * @return <code>true</code>if the user is assigned the Group. */ Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlListImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlListImpl.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlListImpl.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicAccessControlListImpl.java Mon Nov 5 21:14:02 2018 @@ -25,14 +25,14 @@ import org.apache.fulcrum.security.util. * This is a control class that makes it easy to find out if a particular User * has a given Permission. It also determines if a User has a a particular Role. * - * @todo Need to rethink the two maps.. Why not just a single list of groups? - * That would then cascade down to all the other roles and so on.. * @author <a href="mailto:ep...@upstate.com">Eric Pugh</a> * @version $Id: BasicAccessControlListImpl.java 535465 2007-05-05 06:58:06Z tv - * $ */ public class BasicAccessControlListImpl implements BasicAccessControlList { + // TODO Need to rethink the two maps.. Why not just a single list of groups? + // That would then cascade down to all the other roles and so on.. + /** * Serial number */ @@ -53,13 +53,8 @@ public class BasicAccessControlListImpl * The objects that constructs an AccessControlList must supply hashtables * of role/permission sets keyed with group objects. <br> * - * @param roleSets - * a hashtable containing RoleSet objects keyed with Group - * objects - * @param permissionSets - * a hashtable containing PermissionSet objects keyed with Roles - * objects - * @todo need to check this method over... + * @param groupSet + * a hashtable containing GroupSet objects */ public BasicAccessControlListImpl(GroupSet groupSet) { @@ -79,7 +74,7 @@ public class BasicAccessControlListImpl /** * Checks if the user is assigned a specific Group * - * @param role + * @param group * the Group * @return <code>true</code> if the user is assigned the Group */ @@ -91,7 +86,7 @@ public class BasicAccessControlListImpl /** * Checks if the user is assigned a specific Group * - * @param role + * @param group * the Group name * @return <code>true</code> if the user is assigned the Group */ Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicModelManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicModelManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicModelManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/BasicModelManager.java Mon Nov 5 21:14:02 2018 @@ -40,26 +40,26 @@ public interface BasicModelManager exten * * This method is used when adding a user to a group * - * @param user - * the User. + * @param user the User + * @param group the Group * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException * if the account is not present. */ - void grant(User user, Group group) throws DataBackendException, UnknownEntityException; + public void grant(User user, Group group) throws DataBackendException, UnknownEntityException; /** * Removes a user from a group * - * @param user - * the User. + * @param user the User + * @param group the Group * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException * if the user or group is not present. */ - void revoke(User user, Group group) throws DataBackendException, UnknownEntityException; + public void revoke(User user, Group group) throws DataBackendException, UnknownEntityException; /** * Revokes all groups from an User. @@ -73,5 +73,5 @@ public interface BasicModelManager exten * @throws UnknownEntityException * if the account is not present. */ - void revokeAll(User user) throws DataBackendException, UnknownEntityException; + public void revokeAll(User user) throws DataBackendException, UnknownEntityException; } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/BasicGroup.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/BasicGroup.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/BasicGroup.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/BasicGroup.java Mon Nov 5 21:14:02 2018 @@ -59,7 +59,7 @@ public interface BasicGroup extends Grou /** * Set the users that are part of this group as a Set * - * @param userSet + * @param users * a set of users */ public <T extends User> void setUsersAsSet(Set<T> users); Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/impl/BasicGroupImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/impl/BasicGroupImpl.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/impl/BasicGroupImpl.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/basic/entity/impl/BasicGroupImpl.java Mon Nov 5 21:14:02 2018 @@ -35,23 +35,29 @@ import org.apache.fulcrum.security.util. */ public class BasicGroupImpl extends SecurityEntityImpl implements BasicGroup { - private Set<? extends User> userSet = new UserSet(); + /** + * Serial version + */ + private static final long serialVersionUID = 8754093174457116551L; + + /** User set **/ + private Set<? extends User> userSet = new UserSet<>(); /** * Get the users that are part of this group * * @return a set of users */ - public UserSet getUsers() + public UserSet<?> getUsers() { if (userSet instanceof UserSet) { - return (UserSet) userSet; + return (UserSet<?>) userSet; } else { - userSet = new UserSet(userSet); - return (UserSet) userSet; + userSet = new UserSet<>(userSet); + return (UserSet<?>) userSet; } } @@ -69,7 +75,7 @@ public class BasicGroupImpl extends Secu } else { - this.userSet = new UserSet(); + this.userSet = new UserSet<>(); } } @@ -87,7 +93,7 @@ public class BasicGroupImpl extends Secu /** * Set the users that are part of this group as a Set * - * @param userSet + * @param users * a set of users */ public <T extends User> void setUsersAsSet(Set<T> users) Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicAccessControlListImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicAccessControlListImpl.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicAccessControlListImpl.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicAccessControlListImpl.java Mon Nov 5 21:14:02 2018 @@ -31,437 +31,349 @@ import org.apache.fulcrum.security.util. * This is a control class that makes it easy to find out if a particular User * has a given Permission. It also determines if a User has a a particular Role. * - * @todo Need to rethink the two maps.. Why not just a single list of groups? - * That would then cascade down to all the other roles and so on.. * @author <a href="mailto:ep...@upstate.com">Eric Pugh</a> * @version $Id: DynamicAccessControlListImpl.java 1372918 2012-08-14 15:19:40Z * tv $ */ -public class DynamicAccessControlListImpl implements DynamicAccessControlList -{ - /** - * Serial number - */ - private static final long serialVersionUID = -5180551537096244085L; - - /** The sets of roles that the user has in different groups */ - private Map<? extends Group, ? extends RoleSet> roleSets; - /** The sets of permissions that the user has in different groups */ - private Map<? extends Role, ? extends PermissionSet> permissionSets; - /** The distinct list of groups that this user is part of */ - private GroupSet groupSet = new GroupSet(); - /** The distinct list of roles that this user is part of */ - private RoleSet roleSet = new RoleSet(); - /** the distinct list of permissions that this user has */ - private PermissionSet permissionSet = new PermissionSet(); - - /** - * Constructs a new AccessControlList. - * - * This class follows 'immutable' pattern - it's objects can't be modified - * once they are created. This means that the permissions the users have are - * in effect form the moment they log in to the moment they log out, and - * changes made to the security settings in that time are not reflected in - * the state of this object. If you need to reset an user's permissions you - * need to invalidate his session. <br> - * The objects that constructs an AccessControlList must supply hashtables - * of role/permission sets keyed with group objects. <br> - * - * @param roleSets - * a hashtable containing RoleSet objects keyed with Group - * objects - * @param permissionSets - * a hashtable containing PermissionSet objects keyed with Roles - * objects - */ - public DynamicAccessControlListImpl(Map<? extends Group, ? extends RoleSet> roleSets, - Map<? extends Role, ? extends PermissionSet> permissionSets) - { - this.roleSets = roleSets; - this.permissionSets = permissionSets; - for (Map.Entry<? extends Group, ? extends RoleSet> entry : roleSets.entrySet()) - { - Group group = entry.getKey(); - groupSet.add(group); - RoleSet rs = entry.getValue(); - roleSet.add(rs); - } - for (Map.Entry<? extends Role, ? extends PermissionSet> entry : permissionSets.entrySet()) - { - Role role = entry.getKey(); - roleSet.add(role); - PermissionSet ps = entry.getValue(); - permissionSet.add(ps); - } - } - - /** - * Retrieves a set of Roles an user is assigned in a Group. - * - * @param group - * the Group - * @return the set of Roles this user has within the Group. - */ - public RoleSet getRoles(Group group) - { - if (group == null) - { - return null; - } - - return roleSets.get(group); - } - - /** - * Retrieves a set of Roles an user is assigned in the global Group. - * - * @return the set of Roles this user has within the global Group. - */ - public RoleSet getRoles() - { - return roleSet; - } - - /** - * Retrieves a set of Permissions an user is assigned in a Group. - * - * @param group - * the Group - * @return the set of Permissions this user has within the Group. - */ - public PermissionSet getPermissions(Group group) - { - PermissionSet permissionSet = new PermissionSet(); - if (roleSets.containsKey(group)) - { - for (Role role : roleSets.get(group)) - { - if (permissionSets.containsKey(role)) - { - permissionSet.add(permissionSets.get(role)); - } - } - } - return permissionSet; - } - - /** - * Retrieves a set of Permissions an user is assigned in the global Group. - * - * @return the set of Permissions this user has within the global Group. - */ - public PermissionSet getPermissions() - { - return permissionSet; - } - - /** - * Checks if the user is assigned a specific Role in the Group. - * - * @param role - * the Role - * @param group - * the Group - * @return <code>true</code> if the user is assigned the Role in the Group. - */ - public boolean hasRole(Role role, Group group) - { - RoleSet set = getRoles(group); - if (set == null || role == null) - { - return false; - } - return set.contains(role); - } - - /** - * Checks if the user is assigned a specific Role in any of the given Groups - * - * @param role - * the Role - * @param groupset - * a Groupset - * @return <code>true</code> if the user is assigned the Role in any of the - * given Groups. - */ - public boolean hasRole(Role role, GroupSet groupset) - { - if (role == null) - { - return false; - } - - for (Group group : groupset) - { - RoleSet roles = getRoles(group); - if (roles != null && roles.contains(role)) - { - return true; - } - } - return false; - } - - /** - * Checks if the user is assigned a specific Role in the Group. - * - * @param role - * the Role - * @param group - * the Group - * @return <code>true</code> if the user is assigned the Role in the Group. - */ - public boolean hasRole(String role, String group) - { - boolean roleFound = false; - try - { - for (Map.Entry<? extends Group, ? extends RoleSet> entry : roleSets.entrySet()) - { - Group g = entry.getKey(); - if (g.getName().equalsIgnoreCase(group)) - { - RoleSet rs = entry.getValue(); - roleFound = rs.containsName(role); - } - } - } - catch (Exception e) - { - roleFound = false; - } - return roleFound; - } - - /** - * Checks if the user is assigned a specific Role in any of the given Groups - * - * @param rolename - * the name of the Role - * @param groupset - * a Groupset - * @return <code>true</code> if the user is assigned the Role in any of the - * given Groups. - */ - public boolean hasRole(String rolename, GroupSet groupset) - { - Role role; - try - { - role = roleSet.getByName(rolename); - } - catch (Exception e) - { - return false; - } - if (role == null) - { - return false; - } - for (Group group : groupset) - { - RoleSet roles = getRoles(group); - if (roles != null && roles.contains(role)) - { - return true; - } - } - return false; - } - - /** - * Checks if the user is assigned a specific Role - * - * @param role - * the Role - * @return <code>true</code> if the user is assigned the Role in the global - * Group. - */ - public boolean hasRole(Role role) - { - return roleSet.contains(role); - } - - /** - * Checks if the user is assigned a specific Role . - * - * @param role - * the Role - * @return <code>true</code> if the user is assigned the Role . - */ - public boolean hasRole(String role) - { - try - { - return roleSet.containsName(role); - } - catch (Exception e) - { - return false; - } - } - - /** - * Checks if the user is assigned a specific Permission in the Group. - * - * @param permission - * the Permission - * @param group - * the Group - * @return <code>true</code> if the user is assigned the Permission in the - * Group. - */ - public boolean hasPermission(Permission permission, Group group) - { - PermissionSet set = getPermissions(group); - if (set == null || permission == null) - { - return false; - } - return set.contains(permission); - } - - /** - * Checks if the user is assigned a specific Permission in any of the given - * Groups - * - * @param permission - * the Permission - * @param groupset - * a Groupset - * @return <code>true</code> if the user is assigned the Permission in any - * of the given Groups. - */ - public boolean hasPermission(Permission permission, GroupSet groupset) - { - if (permission == null) - { - return false; - } - for (Group group : groupset) - { - PermissionSet permissions = getPermissions(group); - if (permissions != null && permissions.contains(permission)) - { - return true; - } - } - return false; - } - - /** - * Checks if the user is assigned a specific Permission in the Group. - * - * @param permission - * the Permission - * @param group - * the Group - * @return <code>true</code> if the user is assigned the Permission in the - * Group. - */ - public boolean hasPermission(String permission, String group) - { - try - { - return hasPermission(permissionSet.getByName(permission), groupSet.getByName(group)); - } - catch (Exception e) - { - return false; - } - } - - /** - * Checks if the user is assigned a specific Permission in the Group. - * - * @param permission - * the Permission - * @param group - * the Group - * @return <code>true</code> if the user is assigned the Permission in the - * Group. - */ - public boolean hasPermission(String permission, Group group) - { - try - { - return hasPermission(permissionSet.getByName(permission), group); - } - catch (Exception e) - { - return false; - } - } - - /** - * Checks if the user is assigned a specific Permission in any of the given - * Groups - * - * @param permissionName - * the name of the Permission - * @param groupset - * a Groupset - * @return <code>true</code> if the user is assigned the Permission in any - * of the given Groups. - */ - public boolean hasPermission(String permissionName, GroupSet groupset) - { - Permission permission; - try - { - permission = permissionSet.getByName(permissionName); - } - catch (Exception e) - { - return false; - } - if (permission == null) - { - return false; - } - for (Group group : groupset) - { - PermissionSet permissions = getPermissions(group); - if (permissions != null) - { - if (permissions.contains(permission)) - { - return true; - } - } - } - return false; - } - - /** - * Checks if the user is assigned a specific Permission. - * - * @param permission - * the Permission - * @return <code>true</code> if the user is assigned the Permission . - */ - public boolean hasPermission(Permission permission) - { - return permissionSet.contains(permission); - } - - /** - * Checks if the user is assigned a specific Permission in the global Group. - * - * @param permission - * the Permission - * @return <code>true</code> if the user is assigned the Permission in the - * global Group. - */ - public boolean hasPermission(String permission) - { - try - { - return permissionSet.containsName(permission); - } - catch (Exception e) - { - return false; - } - } +public class DynamicAccessControlListImpl implements DynamicAccessControlList { + // TODO Need to rethink the two maps.. Why not just a single list of groups? + // That would then cascade down to all the other roles and so on.. + + /** + * Serial number + */ + private static final long serialVersionUID = -5180551537096244085L; + + /** The sets of roles that the user has in different groups */ + private Map<? extends Group, ? extends RoleSet> roleSets; + /** The sets of permissions that the user has in different groups */ + private Map<? extends Role, ? extends PermissionSet> permissionSets; + /** The distinct list of groups that this user is part of */ + private GroupSet groupSet = new GroupSet(); + /** The distinct list of roles that this user is part of */ + private RoleSet roleSet = new RoleSet(); + /** the distinct list of permissions that this user has */ + private PermissionSet permissionSet = new PermissionSet(); + + /** + * Constructs a new AccessControlList. + * + * This class follows 'immutable' pattern - it's objects can't be modified once + * they are created. This means that the permissions the users have are in + * effect form the moment they log in to the moment they log out, and changes + * made to the security settings in that time are not reflected in the state of + * this object. If you need to reset an user's permissions you need to + * invalidate his session. <br> + * The objects that constructs an AccessControlList must supply hashtables of + * role/permission sets keyed with group objects. <br> + * + * @param roleSets a hashtable containing RoleSet objects keyed with Group + * objects + * @param permissionSets a hashtable containing PermissionSet objects keyed with + * Roles objects + */ + public DynamicAccessControlListImpl(Map<? extends Group, ? extends RoleSet> roleSets, + Map<? extends Role, ? extends PermissionSet> permissionSets) { + this.roleSets = roleSets; + this.permissionSets = permissionSets; + for (Map.Entry<? extends Group, ? extends RoleSet> entry : roleSets.entrySet()) { + Group group = entry.getKey(); + groupSet.add(group); + RoleSet rs = entry.getValue(); + roleSet.add(rs); + } + for (Map.Entry<? extends Role, ? extends PermissionSet> entry : permissionSets.entrySet()) { + Role role = entry.getKey(); + roleSet.add(role); + PermissionSet ps = entry.getValue(); + permissionSet.add(ps); + } + } + + /** + * Retrieves a set of Roles an user is assigned in a Group. + * + * @param group the Group + * @return the set of Roles this user has within the Group. + */ + public RoleSet getRoles(Group group) { + if (group == null) { + return null; + } + + return roleSets.get(group); + } + + /** + * Retrieves a set of Roles an user is assigned in the global Group. + * + * @return the set of Roles this user has within the global Group. + */ + public RoleSet getRoles() { + return roleSet; + } + + /** + * Retrieves a set of Permissions an user is assigned in a Group. + * + * @param group the Group + * @return the set of Permissions this user has within the Group. + */ + public PermissionSet getPermissions(Group group) { + PermissionSet permissionSet = new PermissionSet(); + if (roleSets.containsKey(group)) { + for (Role role : roleSets.get(group)) { + if (permissionSets.containsKey(role)) { + permissionSet.add(permissionSets.get(role)); + } + } + } + return permissionSet; + } + + /** + * Retrieves a set of Permissions an user is assigned in the global Group. + * + * @return the set of Permissions this user has within the global Group. + */ + public PermissionSet getPermissions() { + return permissionSet; + } + + /** + * Checks if the user is assigned a specific Role in the Group. + * + * @param role the Role + * @param group the Group + * @return <code>true</code> if the user is assigned the Role in the Group. + */ + public boolean hasRole(Role role, Group group) { + RoleSet set = getRoles(group); + if (set == null || role == null) { + return false; + } + return set.contains(role); + } + + /** + * Checks if the user is assigned a specific Role in any of the given Groups + * + * @param role the Role + * @param groupset a Groupset + * @return <code>true</code> if the user is assigned the Role in any of the + * given Groups. + */ + public boolean hasRole(Role role, GroupSet groupset) { + if (role == null) { + return false; + } + + for (Group group : groupset) { + RoleSet roles = getRoles(group); + if (roles != null && roles.contains(role)) { + return true; + } + } + return false; + } + + /** + * Checks if the user is assigned a specific Role in the Group. + * + * @param role the Role + * @param group the Group + * @return <code>true</code> if the user is assigned the Role in the Group. + */ + public boolean hasRole(String role, String group) { + boolean roleFound = false; + try { + for (Map.Entry<? extends Group, ? extends RoleSet> entry : roleSets.entrySet()) { + Group g = entry.getKey(); + if (g.getName().equalsIgnoreCase(group)) { + RoleSet rs = entry.getValue(); + roleFound = rs.containsName(role); + } + } + } catch (Exception e) { + roleFound = false; + } + return roleFound; + } + + /** + * Checks if the user is assigned a specific Role in any of the given Groups + * + * @param rolename the name of the Role + * @param groupset a Groupset + * @return <code>true</code> if the user is assigned the Role in any of the + * given Groups. + */ + public boolean hasRole(String rolename, GroupSet groupset) { + Role role; + try { + role = roleSet.getByName(rolename); + } catch (Exception e) { + return false; + } + if (role == null) { + return false; + } + for (Group group : groupset) { + RoleSet roles = getRoles(group); + if (roles != null && roles.contains(role)) { + return true; + } + } + return false; + } + + /** + * Checks if the user is assigned a specific Role + * + * @param role the Role + * @return <code>true</code> if the user is assigned the Role in the global + * Group. + */ + public boolean hasRole(Role role) { + return roleSet.contains(role); + } + + /** + * Checks if the user is assigned a specific Role . + * + * @param role the Role + * @return <code>true</code> if the user is assigned the Role . + */ + public boolean hasRole(String role) { + try { + return roleSet.containsName(role); + } catch (Exception e) { + return false; + } + } + + /** + * Checks if the user is assigned a specific Permission in the Group. + * + * @param permission the Permission + * @param group the Group + * @return <code>true</code> if the user is assigned the Permission in the + * Group. + */ + public boolean hasPermission(Permission permission, Group group) { + PermissionSet set = getPermissions(group); + if (set == null || permission == null) { + return false; + } + return set.contains(permission); + } + + /** + * Checks if the user is assigned a specific Permission in any of the given + * Groups + * + * @param permission the Permission + * @param groupset a Groupset + * @return <code>true</code> if the user is assigned the Permission in any of + * the given Groups. + */ + public boolean hasPermission(Permission permission, GroupSet groupset) { + if (permission == null) { + return false; + } + for (Group group : groupset) { + PermissionSet permissions = getPermissions(group); + if (permissions != null && permissions.contains(permission)) { + return true; + } + } + return false; + } + + /** + * Checks if the user is assigned a specific Permission in the Group. + * + * @param permission the Permission + * @param group the Group + * @return <code>true</code> if the user is assigned the Permission in the + * Group. + */ + public boolean hasPermission(String permission, String group) { + try { + return hasPermission(permissionSet.getByName(permission), groupSet.getByName(group)); + } catch (Exception e) { + return false; + } + } + + /** + * Checks if the user is assigned a specific Permission in the Group. + * + * @param permission the Permission + * @param group the Group + * @return <code>true</code> if the user is assigned the Permission in the + * Group. + */ + public boolean hasPermission(String permission, Group group) { + try { + return hasPermission(permissionSet.getByName(permission), group); + } catch (Exception e) { + return false; + } + } + + /** + * Checks if the user is assigned a specific Permission in any of the given + * Groups + * + * @param permissionName the name of the Permission + * @param groupset a Groupset + * @return <code>true</code> if the user is assigned the Permission in any of + * the given Groups. + */ + public boolean hasPermission(String permissionName, GroupSet groupset) { + Permission permission; + try { + permission = permissionSet.getByName(permissionName); + } catch (Exception e) { + return false; + } + if (permission == null) { + return false; + } + for (Group group : groupset) { + PermissionSet permissions = getPermissions(group); + if (permissions != null) { + if (permissions.contains(permission)) { + return true; + } + } + } + return false; + } + + /** + * Checks if the user is assigned a specific Permission. + * + * @param permission the Permission + * @return <code>true</code> if the user is assigned the Permission . + */ + public boolean hasPermission(Permission permission) { + return permissionSet.contains(permission); + } + + /** + * Checks if the user is assigned a specific Permission in the global Group. + * + * @param permission the Permission + * @return <code>true</code> if the user is assigned the Permission in the + * global Group. + */ + public boolean hasPermission(String permission) { + try { + return permissionSet.containsName(permission); + } catch (Exception e) { + return false; + } + } } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicModelManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicModelManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicModelManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/DynamicModelManager.java Mon Nov 5 21:14:02 2018 @@ -73,8 +73,9 @@ public interface DynamicModelManager ext * * This method is used when adding a permission to a role * - * @param user - * the User. + * @param role the Role + * @param permission the Permission + * * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException @@ -84,9 +85,10 @@ public interface DynamicModelManager ext /** * Removes a permission from a role + * + * @param role the Role + * @param permission the Permission * - * @param role - * the Role. * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException @@ -99,8 +101,9 @@ public interface DynamicModelManager ext * * This method is used when adding a user to a group * - * @param user - * the User. + * @param user the User + * @param group the Group + * * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException @@ -111,8 +114,9 @@ public interface DynamicModelManager ext /** * Removes a user from a group * - * @param user - * the User. + * @param user the User + * @param group the Group + * * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException @@ -125,8 +129,8 @@ public interface DynamicModelManager ext * * This method is typically used when deleting an account. * - * @param user - * the User. + * @param user the User + * * @throws DataBackendException * if there was an error accessing the data backend. * @throws UnknownEntityException @@ -183,16 +187,26 @@ public interface DynamicModelManager ext * A * @param delegatee * B + * + * @throws DataBackendException + * if there was an error accessing the data backend. + * @throws UnknownEntityException + * if the Group is not present. */ void addDelegate(User delegator, User delegatee) throws DataBackendException, UnknownEntityException; /** * Stop A having B's roles, groups and permissions * - * @param delegate + * @param delegator * A * @param delegatee * B + * + * @throws DataBackendException + * if there was an error accessing the data backend. + * @throws UnknownEntityException + * if the Group is not present. */ void removeDelegate(User delegator, User delegatee) throws DataBackendException, UnknownEntityException; } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/DynamicRole.java Mon Nov 5 21:14:02 2018 @@ -70,14 +70,14 @@ public interface DynamicRole extends Rol /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission the Permission to add */ public void addPermission(Permission permission); /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission the Permission to remove */ public void removePermission(Permission permission); @@ -99,14 +99,14 @@ public interface DynamicRole extends Rol /** * This method should only be used by a RoleManager. Not directly. * - * @param group + * @param group the Group to remove */ public void removeGroup(Group group); /** * This method should only be used by a RoleManager. Not directly. * - * @param group + * @param group the Group to add */ public void addGroup(Group group); Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/impl/DynamicRoleImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/impl/DynamicRoleImpl.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/impl/DynamicRoleImpl.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/dynamic/entity/impl/DynamicRoleImpl.java Mon Nov 5 21:14:02 2018 @@ -103,7 +103,7 @@ public class DynamicRoleImpl extends Sec /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission the Permission to add */ public void addPermission(Permission permission) { @@ -113,7 +113,7 @@ public class DynamicRoleImpl extends Sec /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission the Permission to remove */ public void removePermission(Permission permission) { @@ -141,7 +141,7 @@ public class DynamicRoleImpl extends Sec /** * Set the groups this role belongs to * - * @param groups + * @param groupSet * the set of groups */ public void setGroups(GroupSet groupSet) @@ -159,7 +159,7 @@ public class DynamicRoleImpl extends Sec /** * This method should only be used by a RoleManager. Not directly. * - * @param group + * @param group the Group to remove */ public void removeGroup(Group group) { @@ -169,7 +169,7 @@ public class DynamicRoleImpl extends Sec /** * This method should only be used by a RoleManager. Not directly. * - * @param group + * @param group the Group to add */ public void addGroup(Group group) { Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineACLFactory.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineACLFactory.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineACLFactory.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineACLFactory.java Mon Nov 5 21:14:02 2018 @@ -49,7 +49,8 @@ public class TurbineACLFactory extends A private TurbineModelManager modelManager; /** - * @return + * @return A model manager + * @throws DataBackendException generic exception */ protected TurbineModelManager getTurbineModelManager() throws DataBackendException { @@ -68,7 +69,7 @@ public class TurbineACLFactory extends A return modelManager; } - /** + /* (non-Javadoc) * @see org.apache.fulcrum.security.model.ACLFactory#getAccessControlList(org.apache.fulcrum.security.entity.User) */ @Override Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineModelManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineModelManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineModelManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineModelManager.java Mon Nov 5 21:14:02 2018 @@ -67,6 +67,7 @@ public interface TurbineModelManager ext * href="#global">global group</a>. * * @return A Group object that represents the global group. + * @throws DataBackendException generic exception */ Group getGlobalGroup() throws DataBackendException; @@ -85,6 +86,8 @@ public interface TurbineModelManager ext * the old Role * @param newRole * the new Role + * @throws DataBackendException generic exception + * @throws UnknownEntityException generic exception */ void replace(User user, Role oldRole, Role newRole) throws DataBackendException, UnknownEntityException; @@ -159,7 +162,7 @@ public interface TurbineModelManager ext * @throws UnknownEntityException * if the Group is not present. */ - void revokeAll(Group role) throws DataBackendException, UnknownEntityException; + void revokeAll(Group group) throws DataBackendException, UnknownEntityException; /** * Grant an User a Role in a Group. Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineUserManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineUserManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineUserManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/TurbineUserManager.java Mon Nov 5 21:14:02 2018 @@ -35,13 +35,14 @@ import org.apache.fulcrum.security.util. * or mapped to method names as listed below: * * <ul> - * <li>Turbine (framework) user manager method(s) -> method(s) in this (Fulcrum )manager - * <li>createAccount -> {@link #addUser(User, String)} - * <li>removeAccount -> {@link #removeUser(User)} - * <li>store -> {@link #saveUser(User)} - * <li>retrieve (2x)-> {@link #getUser(String)}, {@link #getUser(String, String)} - * <li>retrieveList -> {@link #getAllUsers()} - * <li>accountExists (2x)-> {@link #checkExists(String)}, {@link #checkExists(User)} + * <li>Turbine (framework) user manager method(s) -> method(s) in this (Fulcrum) manager + * <li>createAccount -> {@link #addUser(User, String)} + * <li>removeAccount -> {@link #removeUser(User)} + * <li>store -> {@link #saveUser(User)} + * <li>retrieve (2x)-> {@link #getUser(String)}, {@link #getUser(String, String)} + * <li>retrieveList -> {@link #getAllUsers()} + * <li>accountExists (2x)-> {@link #checkExists(String)}, {@link #checkExists(User)} + * </ul> * * @author <a href="mailto:ep...@upstate.com">Eric Pugh</a> * @version $Id$ @@ -62,11 +63,8 @@ public interface TurbineUserManager exte * Checks whether a passed user object matches the anonymous user pattern * according to the configured user manager * - * @param An - * user object - * + * @param user A user object * @return True if this is an anonymous user - * */ - boolean isAnonymousUser(User u); + boolean isAnonymousUser(User user); } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbinePermission.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbinePermission.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbinePermission.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbinePermission.java Mon Nov 5 21:14:02 2018 @@ -71,6 +71,7 @@ public interface TurbinePermission exten * * @param roles * a set of roles + * @param <T> Role */ public <T extends Role> void setRolesAsSet(Set<T> roles); Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineRole.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineRole.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineRole.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineRole.java Mon Nov 5 21:14:02 2018 @@ -62,20 +62,21 @@ public interface TurbineRole extends Rol * * @param permissions * a set of permissions + * @param <T> Permission */ public <T extends Permission> void setPermissionsAsSet(Set<T> permissions); /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission perm to add */ public void addPermission(Permission permission); /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission perm to remove */ public void removePermission(Permission permission); } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineUserGroupRoleEntity.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineUserGroupRoleEntity.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineUserGroupRoleEntity.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/TurbineUserGroupRoleEntity.java Mon Nov 5 21:14:02 2018 @@ -31,40 +31,37 @@ import org.apache.fulcrum.security.util. * @author <a href="mailto:ep...@upstate.com">Eric Pugh </a> * @version $Id: TurbineRole.java 535465 2007-05-05 06:58:06Z tv $ */ -public interface TurbineUserGroupRoleEntity -{ - - /** - * Get the User/Group/Role set associated with this entity - * - * @return a set of User/Group/Role relations - * @throws DataBackendException - */ - public <T extends TurbineUserGroupRole> Set<T> getUserGroupRoleSet() throws DataBackendException; +public interface TurbineUserGroupRoleEntity { - /** - * Set the User/Group/Role set associated with this entity - * - * @param userGroupRoleSet - * a set of User/Group/Role relations - */ - public <T extends TurbineUserGroupRole> void setUserGroupRoleSet(Set<T> userGroupRoleSet); + /** + * Get the User/Group/Role set associated with this entity + * + * @return a set of User/Group/Role relations + * @throws DataBackendException generic exception + */ + public <T extends TurbineUserGroupRole> Set<T> getUserGroupRoleSet() throws DataBackendException; - /** - * Add a User/Group/Role relation to this entity - * - * @param userGroupRole - * a User/Group/Role relation to add - * @throws DataBackendException - */ - public void addUserGroupRole(TurbineUserGroupRole userGroupRole) throws DataBackendException; + /** + * Set the User/Group/Role set associated with this entity + * + * @param userGroupRoleSet a set of User/Group/Role relations + * @param <T> TurbineUserGroupRole + */ + public <T extends TurbineUserGroupRole> void setUserGroupRoleSet(Set<T> userGroupRoleSet); - /** - * Remove a User/Group/Role relation from this entity - * - * @param userGroupRole - * a User/Group/Role relation to remove - * @throws DataBackendException - */ - public void removeUserGroupRole(TurbineUserGroupRole userGroupRole) throws DataBackendException; + /** + * Add a User/Group/Role relation to this entity + * + * @param userGroupRole a User/Group/Role relation to add + * @throws DataBackendException generic exception + */ + public void addUserGroupRole(TurbineUserGroupRole userGroupRole) throws DataBackendException; + + /** + * Remove a User/Group/Role relation from this entity + * + * @param userGroupRole a User/Group/Role relation to remove + * @throws DataBackendException generic exception + */ + public void removeUserGroupRole(TurbineUserGroupRole userGroupRole) throws DataBackendException; } Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/impl/TurbineRoleImpl.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/impl/TurbineRoleImpl.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/impl/TurbineRoleImpl.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/model/turbine/entity/impl/TurbineRoleImpl.java Mon Nov 5 21:14:02 2018 @@ -89,6 +89,7 @@ public class TurbineRoleImpl extends Abs * * @param permissions * a set of permissions + * @param <T> Permission */ public <T extends Permission> void setPermissionsAsSet(Set<T> permissions) { @@ -98,7 +99,7 @@ public class TurbineRoleImpl extends Abs /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission the permission to add */ public void addPermission(Permission permission) { @@ -108,7 +109,7 @@ public class TurbineRoleImpl extends Abs /** * This method should only be used by a RoleManager. Not directly. * - * @param permission + * @param permission the permission to remove */ public void removePermission(Permission permission) { Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/session/Session.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/session/Session.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/session/Session.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/session/Session.java Mon Nov 5 21:14:02 2018 @@ -19,8 +19,9 @@ package org.apache.fulcrum.security.sess * under the License. */ + /** - * This interface provides access to the {@link javax.servlet.HttpSession} + * This interface provides access to the <code>javax.servlet.HttpSession</code> * interface. * * @author <a href="mailto:d...@finemaltcoding.com">Daniel Rall</a> Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractGroupManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractGroupManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractGroupManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractGroupManager.java Mon Nov 5 21:14:02 2018 @@ -114,8 +114,8 @@ public abstract class AbstractGroupManag /** * Retrieve a Group object with specified Id. * - * @param name - * the name of the Group. + * @param id + * the ID of the Group. * * @return an object representing the Group with specified name. * @@ -177,7 +177,7 @@ public abstract class AbstractGroupManag * * The name is used for looking up the group * - * @param role + * @param group * The group to be checked. * @return true if the specified group exists * @throws DataBackendException Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractManager.java Mon Nov 5 21:14:02 2018 @@ -49,7 +49,7 @@ public abstract class AbstractManager ex private UserManager userManager; /** - * @return + * @return the service manager */ protected ServiceManager getServiceManager() { @@ -57,7 +57,8 @@ public abstract class AbstractManager ex } /** - * @return + * @return the user manager + * @throws DataBackendException if fail to connect to datasource */ protected UserManager getUserManager() throws DataBackendException { @@ -77,7 +78,8 @@ public abstract class AbstractManager ex } /** - * @return + * @return the permission manager + * @throws DataBackendException if fail to connect to datasource */ protected PermissionManager getPermissionManager() throws DataBackendException { @@ -97,7 +99,8 @@ public abstract class AbstractManager ex } /** - * @return + * @return the role manager + * @throws DataBackendException if fail to connect to datasource */ protected RoleManager getRoleManager() throws DataBackendException { @@ -117,7 +120,8 @@ public abstract class AbstractManager ex } /** - * @return + * @return the group manager + * @throws DataBackendException if fail to connect to datasource */ protected GroupManager getGroupManager() throws DataBackendException { @@ -138,6 +142,7 @@ public abstract class AbstractManager ex /** * Avalon Service lifecycle method + * @throws ServiceException if fail to connect */ @Override public void service(ServiceManager manager) throws ServiceException @@ -156,6 +161,9 @@ public abstract class AbstractManager ex manager = null; } + /** + * @param obj the object to release + */ protected void release(Object obj) { if (obj != null) @@ -165,11 +173,11 @@ public abstract class AbstractManager ex } /** - * @return A resolved object - * @throws DataBackendException - * if the backend failed for some reason. + * @param lookup the object to resolve + * @return the actual object + * @throws RuntimeException exception if fails to find the manager */ - protected Object resolve(String lookup) + protected Object resolve(String lookup) throws RuntimeException { Object component = null; { Modified: turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractPermissionManager.java URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractPermissionManager.java?rev=1845858&r1=1845857&r2=1845858&view=diff ============================================================================== --- turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractPermissionManager.java (original) +++ turbine/fulcrum/trunk/security/api/src/java/org/apache/fulcrum/security/spi/AbstractPermissionManager.java Mon Nov 5 21:14:02 2018 @@ -109,8 +109,8 @@ public abstract class AbstractPermission /** * Retrieve a Permission object with specified Id. * - * @param name - * the name of the Permission. + * @param id + * the ID of the Permission. * * @return an object representing the Permission with specified name. * @@ -176,7 +176,7 @@ public abstract class AbstractPermission * * The name is used for looking up the permission * - * @param role + * @param permission * The permission to be checked. * @return true if the specified permission exists * @throws DataBackendException