You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2003/01/04 19:21:50 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/services/security BaseSecurityService.java SecurityService.java TurbineSecurity.java UserManager.java
mpoeschl 2003/01/04 10:21:49
Modified: src/java/org/apache/turbine/services/security
BaseSecurityService.java SecurityService.java
TurbineSecurity.java UserManager.java
Log:
o javadocs
o code formatting
Revision Changes Path
1.9 +96 -89 jakarta-turbine-2/src/java/org/apache/turbine/services/security/BaseSecurityService.java
Index: BaseSecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/BaseSecurityService.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BaseSecurityService.java 4 Jan 2003 04:24:45 -0000 1.8
+++ BaseSecurityService.java 4 Jan 2003 18:21:49 -0000 1.9
@@ -59,16 +59,15 @@
import java.security.MessageDigest;
import javax.mail.internet.MimeUtility;
import javax.servlet.ServletConfig;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.torque.util.Criteria;
-import org.apache.turbine.Turbine;
import org.apache.turbine.om.security.Group;
import org.apache.turbine.om.security.Permission;
import org.apache.turbine.om.security.Role;
import org.apache.turbine.om.security.User;
import org.apache.turbine.services.InitializationException;
import org.apache.turbine.services.TurbineBaseService;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.turbine.util.security.DataBackendException;
import org.apache.turbine.util.security.EntityExistsException;
import org.apache.turbine.util.security.GroupSet;
@@ -96,7 +95,8 @@
* @version $Id$
*/
public abstract class BaseSecurityService
- extends TurbineBaseService implements SecurityService
+ extends TurbineBaseService
+ implements SecurityService
{
/** Logging */
private static Log log = LogFactory.getLog(BaseSecurityService.class);
@@ -109,7 +109,10 @@
/** Holds a list of all roles in the systems, for speeding up the access */
private RoleSet allRoles = null;
- /** Holds a list of all permissions in the systems, for speeding up the access */
+ /**
+ * Holds a list of all permissions in the systems, for speeding up
+ * the access
+ */
private PermissionSet allPermissions = null;
/** The number of threads concurrently reading security information */
@@ -159,7 +162,7 @@
// default encoding. Thanks to SGawin for spotting this.
byte[] digest = md.digest(password.getBytes("UTF-8"));
ByteArrayOutputStream bas = new ByteArrayOutputStream(
- digest.length + digest.length / 3 + 1);
+ digest.length + digest.length / 3 + 1);
OutputStream encodedStream = MimeUtility.encode(bas, "base64");
encodedStream.write(digest);
return bas.toString();
@@ -183,11 +186,9 @@
* This is a zero parameter variant which queries the Turbine Servlet
* for its config.
*
- * @throws InitializationException Something went wrong in the init
- * stage
+ * @throws InitializationException Something went wrong in the init stage
*/
- public void init()
- throws InitializationException
+ public void init() throws InitializationException
{
String userManagerClassName = getProperties().getProperty(
SecurityService.USER_MANAGER_KEY,
@@ -203,20 +204,21 @@
}
catch (Exception e)
{
- throw new InitializationException(
- "BaseSecurityService.init: Failed create a Class object for User implementation", e);
+ throw new InitializationException("BaseSecurityService.init: "
+ + "Failed create a Class object for User implementation",
+ e);
}
try
{
userManager = (UserManager) Class.forName(userManagerClassName)
- .newInstance();
+ .newInstance();
setInit(true);
}
catch (Exception e)
{
- throw new InitializationException(
- "BaseSecurityService.init: Failed to instantiate UserManager", e);
+ throw new InitializationException("BaseSecurityService.init: "
+ + "Failed to instantiate UserManager", e);
}
}
@@ -224,10 +226,10 @@
* Initializes the SecurityService, locating the apropriate UserManager
*
* @param config a ServletConfig, to enforce early initialization
+ * @throws InitializationException Something went wrong in the init stage
* @deprecated use init() instead.
*/
- public void init(ServletConfig config)
- throws InitializationException
+ public void init(ServletConfig config) throws InitializationException
{
init();
}
@@ -240,8 +242,7 @@
* @throws UnknownEntityException if the implementation of User interface
* could not be determined, or does not exist.
*/
- public Class getUserClass()
- throws UnknownEntityException
+ public Class getUserClass() throws UnknownEntityException
{
if (userClass == null)
{
@@ -260,8 +261,7 @@
* @return an object implementing User interface.
* @throws UnknownEntityException if the object could not be instantiated.
*/
- public User getUserInstance()
- throws UnknownEntityException
+ public User getUserInstance() throws UnknownEntityException
{
User user;
try
@@ -270,7 +270,8 @@
}
catch (Exception e)
{
- throw new UnknownEntityException("Failed instantiate an User implementation object", e);
+ throw new UnknownEntityException(
+ "Failed instantiate an User implementation object", e);
}
return user;
}
@@ -285,8 +286,7 @@
* @throws DataBackendException if there was an error accessing the data
* backend.
*/
- public boolean accountExists(User user)
- throws DataBackendException
+ public boolean accountExists(User user) throws DataBackendException
{
return userManager.accountExists(user);
}
@@ -301,8 +301,7 @@
* @throws DataBackendException if there was an error accessing the data
* backend.
*/
- public boolean accountExists(String username)
- throws DataBackendException
+ public boolean accountExists(String username) throws DataBackendException
{
return userManager.accountExists(username);
}
@@ -314,32 +313,29 @@
* @param username The user name.
* @param password The user password.
* @return An authenticated Turbine User.
- * @exception PasswordMismatchException if the supplied password was
- * incorrect.
- * @exception UnknownEntityException if the user's account does not
+ * @throws PasswordMismatchException if the supplied password was incorrect.
+ * @throws UnknownEntityException if the user's account does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
public User getAuthenticatedUser(String username, String password)
- throws DataBackendException, UnknownEntityException,
- PasswordMismatchException
+ throws DataBackendException, UnknownEntityException,
+ PasswordMismatchException
{
return userManager.retrieve(username, password);
}
/**
- * Constructs an User object to represent a registered user of the application.
+ * Constructs an User object to represent a registered user of the
+ * application.
*
* @param username The user name.
* @return A Turbine User.
- * @exception UnknownEntityException if the user's account does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws UnknownEntityException if the user's account does not exist
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public User getUser( String username )
- throws DataBackendException, UnknownEntityException
+ public User getUser(String username)
+ throws DataBackendException, UnknownEntityException
{
return userManager.retrieve(username);
}
@@ -355,24 +351,22 @@
*
* @param criteria The criteria of selection.
* @return a List of users meeting the criteria.
- * @throws DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public User[] getUsers( Criteria criteria )
- throws DataBackendException
+ public User[] getUsers(Criteria criteria) throws DataBackendException
{
return userManager.retrieve(criteria);
}
/**
- * Constructs an User object to represent an anonymous user of the application.
+ * Constructs an User object to represent an anonymous user of the
+ * application.
*
* @return An anonymous Turbine User.
* @throws UnknownEntityException if the implementation of User interface
* could not be determined, or does not exist.
*/
- public User getAnonymousUser()
- throws UnknownEntityException
+ public User getAnonymousUser() throws UnknownEntityException
{
User user = getUserInstance();
user.setUserName("");
@@ -383,13 +377,13 @@
* Saves User's data in the permanent storage. The user account is required
* to exist in the storage.
*
- * @exception UnknownEntityException if the user's account does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @param user the User object to save
+ * @throws UnknownEntityException if the user's account does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
public void saveUser(User user)
- throws UnknownEntityException, DataBackendException
+ throws UnknownEntityException, DataBackendException
{
userManager.store(user);
}
@@ -398,11 +392,13 @@
* Creates new user account with specified attributes.
*
* @param user the object describing account to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param password the password for the new user
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
* @throws EntityExistsException if the user account already exists.
*/
public void addUser(User user, String password)
- throws DataBackendException, EntityExistsException
+ throws DataBackendException, EntityExistsException
{
userManager.createAccount(user, password);
}
@@ -411,11 +407,12 @@
* Removes an user account from the system.
*
* @param user the object describing the account to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the user account is not present.
*/
public void removeUser(User user)
- throws DataBackendException, UnknownEntityException
+ throws DataBackendException, UnknownEntityException
{
// revoke all roles form the user
revokeAll(user);
@@ -429,16 +426,15 @@
* @param user an User to change password for.
* @param oldPassword the current password supplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
- * incorrect.
- * @exception UnknownEntityException if the user's record does not
+ * @throws PasswordMismatchException if the supplied password was incorrect.
+ * @throws UnknownEntityException if the user's record does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public void changePassword(User user, String oldPassword, String newPassword)
- throws PasswordMismatchException, UnknownEntityException,
- DataBackendException
+ public void changePassword(User user, String oldPassword,
+ String newPassword)
+ throws PasswordMismatchException, UnknownEntityException,
+ DataBackendException
{
userManager.changePassword(user, oldPassword, newPassword);
}
@@ -453,13 +449,12 @@
*
* @param user an User to change password for.
* @param password the new password.
- * @exception UnknownEntityException if the user's record does not
+ * @throws UnknownEntityException if the user's record does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
public void forcePassword(User user, String password)
- throws UnknownEntityException, DataBackendException
+ throws UnknownEntityException, DataBackendException
{
userManager.forcePassword(user, password);
}
@@ -500,7 +495,7 @@
{
try
{
- this.wait();
+ this.wait();
}
catch (InterruptedException e)
{
@@ -530,7 +525,7 @@
{
if (globalGroup == null)
{
- synchronized(BaseSecurityService.class)
+ synchronized (BaseSecurityService.class)
{
if (globalGroup == null)
{
@@ -555,9 +550,12 @@
*
* @param name the name of the Group.
* @return an object representing the Group with specified name.
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
+ * @throws UnknownEntityException if the group does not exist.
*/
public Group getGroup(String name)
- throws DataBackendException, UnknownEntityException
+ throws DataBackendException, UnknownEntityException
{
GroupSet groups = getAllGroups();
Group group = groups.getGroup(name);
@@ -567,7 +565,8 @@
}
else
{
- throw new UnknownEntityException("The specified group does not exist");
+ throw new UnknownEntityException(
+ "The specified group does not exist");
}
}
@@ -576,9 +575,12 @@
*
* @param name the name of the Role.
* @return an object representing the Role with specified name.
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
+ * @throws UnknownEntityException if the role does not exist.
*/
public Role getRole(String name)
- throws DataBackendException, UnknownEntityException
+ throws DataBackendException, UnknownEntityException
{
RoleSet roles = getAllRoles();
Role role = roles.getRole(name);
@@ -589,7 +591,8 @@
}
else
{
- throw new UnknownEntityException("The specified role does not exist");
+ throw new UnknownEntityException(
+ "The specified role does not exist");
}
}
@@ -598,9 +601,12 @@
*
* @param name the name of the Permission.
* @return an object representing the Permission with specified name.
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
+ * @throws UnknownEntityException if the permission does not exist.
*/
public Permission getPermission(String name)
- throws DataBackendException, UnknownEntityException
+ throws DataBackendException, UnknownEntityException
{
PermissionSet permissions = getAllPermissions();
Permission permission = permissions.getPermission(name);
@@ -610,7 +616,8 @@
}
else
{
- throw new UnknownEntityException("The specified permission does not exist");
+ throw new UnknownEntityException(
+ "The specified permission does not exist");
}
}
@@ -618,14 +625,14 @@
* Retrieves all groups defined in the system.
*
* @return the names of all groups defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
*/
- public GroupSet getAllGroups()
- throws DataBackendException
+ public GroupSet getAllGroups() throws DataBackendException
{
if (allGroups == null)
{
- synchronized(this)
+ synchronized (this)
{
if (allGroups == null)
{
@@ -640,14 +647,14 @@
* Retrieves all roles defined in the system.
*
* @return the names of all roles defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
*/
- public RoleSet getAllRoles()
- throws DataBackendException
+ public RoleSet getAllRoles() throws DataBackendException
{
if (allRoles == null)
{
- synchronized(this)
+ synchronized (this)
{
if (allRoles == null)
{
@@ -662,14 +669,14 @@
* Retrieves all permissions defined in the system.
*
* @return the names of all roles defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the
+ * data backend.
*/
- public PermissionSet getAllPermissions()
- throws DataBackendException
+ public PermissionSet getAllPermissions() throws DataBackendException
{
if (allPermissions == null)
{
- synchronized(this)
+ synchronized (this)
{
if (allPermissions == null)
{
1.4 +198 -130 jakarta-turbine-2/src/java/org/apache/turbine/services/security/SecurityService.java
Index: SecurityService.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/SecurityService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SecurityService.java 11 Jul 2002 16:53:24 -0000 1.3
+++ SecurityService.java 4 Jan 2003 18:21:49 -0000 1.4
@@ -85,32 +85,52 @@
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id$
*/
-public interface SecurityService
- extends Service
+public interface SecurityService extends Service
{
/** The name of the service */
public static final String SERVICE_NAME = "SecurityService";
- /** the key within services's properties for user implementation classname (user.class) */
+ /**
+ * the key within services's properties for user implementation
+ * classname (user.class)
+ */
public static final String USER_CLASS_KEY = "user.class";
- /** the default implementation of User interface (org.apache.turbine.om.security.DBUser) */
- public static final String USER_CLASS_DEFAULT = "org.apache.turbine.om.security.TurbineUser";
+ /**
+ * the default implementation of User interface
+ * (org.apache.turbine.om.security.DBUser)
+ */
+ public static final String USER_CLASS_DEFAULT
+ = "org.apache.turbine.om.security.TurbineUser";
- /** the key within services's properties for user implementation classname (user.manager) */
+ /**
+ * the key within services's properties for user implementation
+ * classname (user.manager)
+ */
public static final String USER_MANAGER_KEY = "user.manager";
- /** the default implementation of UserManager interface (org.apache.turbine.services.security.DBUserManager) */
- public static final String USER_MANAGER_DEFAULT = "org.apache.turbine.services.security.DBUserManager";
+ /**
+ * the default implementation of UserManager interface
+ * (org.apache.turbine.services.security.DBUserManager)
+ */
+ public static final String USER_MANAGER_DEFAULT
+ = "org.apache.turbine.services.security.DBUserManager";
- /** the key within services's properties for secure passwords flag (secure.passwords) */
+ /**
+ * the key within services's properties for secure passwords flag
+ * (secure.passwords)
+ */
public static final String SECURE_PASSWORDS_KEY = "secure.passwords";
/** the value of secure passwords flag (false) */
public static final String SECURE_PASSWORDS_DEFAULT = "false";
- /** the key within services's properties for secure passwords algorithm (secure.passwords.algorithm) */
- public static final String SECURE_PASSWORDS_ALGORITHM_KEY = "secure.passwords.algorithm";
+ /**
+ * the key within services's properties for secure passwords algorithm
+ * (secure.passwords.algorithm)
+ */
+ public static final String SECURE_PASSWORDS_ALGORITHM_KEY
+ = "secure.passwords.algorithm";
/** the default algorithm for password encryption (SHA) */
public static final String SECURE_PASSWORDS_ALGORITHM_DEFAULT = "SHA";
@@ -127,8 +147,7 @@
* @throws UnknownEntityException if the system's implementation of User
* interface could not be determined.
*/
- public Class getUserClass()
- throws UnknownEntityException;
+ public Class getUserClass() throws UnknownEntityException;
/**
* Construct a blank User object.
@@ -139,8 +158,7 @@
* @return an object implementing User interface.
* @throws UnknownEntityException if the object could not be instantiated.
*/
- public User getUserInstance()
- throws UnknownEntityException;
+ public User getUserInstance() throws UnknownEntityException;
/**
* Check whether a specified user's account exists.
@@ -149,10 +167,10 @@
*
* @param username The user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public boolean accountExists(String username)
- throws DataBackendException;
+ public boolean accountExists(String username) throws DataBackendException;
/**
* Check whether a specified user's account exists.
@@ -161,34 +179,39 @@
*
* @param user The name of the user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public boolean accountExists(User user)
- throws DataBackendException;
+ public boolean accountExists(User user) throws DataBackendException;
/**
- * Authenticates an user, and constructs an User object to represent him/her.
+ * Authenticates an user, and constructs an User object to represent
+ * him/her.
*
* @param username The user name.
* @param password The user password.
* @return An authenticated Turbine User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
* @throws PasswordMismatchException if the supplied password was incorrect.
*/
public User getAuthenticatedUser(String username, String password)
- throws DataBackendException, UnknownEntityException, PasswordMismatchException;
+ throws DataBackendException, UnknownEntityException,
+ PasswordMismatchException;
/**
- * Constructs an User object to represent a registered user of the application.
+ * Constructs an User object to represent a registered user of the
+ * application.
*
* @param username The user name.
* @return A Turbine User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
*/
- public User getUser( String username )
- throws DataBackendException, UnknownEntityException;
+ public User getUser(String username) throws DataBackendException,
+ UnknownEntityException;
/**
* Retrieve a set of users that meet the specified criteria.
@@ -201,33 +224,31 @@
*
* @param criteria The criteria of selection.
* @return a List of users meeting the criteria.
- * @throws DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public User[] getUsers( Criteria criteria )
- throws DataBackendException;
+ public User[] getUsers(Criteria criteria) throws DataBackendException;
/**
- * Constructs an User object to represent an anonymous user of the application.
+ * Constructs an User object to represent an anonymous user of the
+ * application.
*
* @return An anonymous Turbine User.
* @throws UnknownEntityException if the anonymous User object couldn't be
* constructed.
*/
- public User getAnonymousUser()
- throws UnknownEntityException;
+ public User getAnonymousUser() throws UnknownEntityException;
/**
* Saves User's data in the permanent storage. The user account is required
* to exist in the storage.
*
- * @exception UnknownEntityException if the user's account does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @param user the user object to save
+ * @throws UnknownEntityException if the user's account does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public void saveUser( User user )
- throws UnknownEntityException, DataBackendException;
+ public void saveUser(User user) throws UnknownEntityException,
+ DataBackendException;
/*-----------------------------------------------------------------------
Account management
@@ -237,21 +258,24 @@
* Creates new user account with specified attributes.
*
* @param user the object describing account to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param password password for the new user
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the user account already exists.
*/
- public void addUser( User user, String password )
- throws DataBackendException, EntityExistsException;
+ public void addUser(User user, String password)
+ throws DataBackendException, EntityExistsException;
/**
* Removes an user account from the system.
*
* @param user the object describing the account to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the user account is not present.
*/
- public void removeUser( User user )
- throws DataBackendException, UnknownEntityException;
+ public void removeUser(User user)
+ throws DataBackendException, UnknownEntityException;
/*-----------------------------------------------------------------------
Management of passwords
@@ -267,7 +291,7 @@
* @param password the password to process
* @return processed password
*/
- public String encryptPassword( String password );
+ public String encryptPassword(String password);
/**
* Change the password for an User.
@@ -282,9 +306,10 @@
* @exception DataBackendException if there is a problem accessing the
* storage.
*/
- public void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
- DataBackendException;
+ public void changePassword(User user, String oldPassword,
+ String newPassword)
+ throws PasswordMismatchException, UnknownEntityException,
+ DataBackendException;
/**
* Forcibly sets new password for an User.
@@ -301,8 +326,8 @@
* @exception DataBackendException if there is a problem accessing the
* storage.
*/
- public void forcePassword( User user, String password )
- throws UnknownEntityException, DataBackendException;
+ public void forcePassword(User user, String password)
+ throws UnknownEntityException, DataBackendException;
/*-----------------------------------------------------------------------
Retrieval of security information
@@ -312,21 +337,25 @@
* Constructs an AccessControlList for a specific user.
*
* @param user the user for whom the AccessControlList are to be retrieved
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return the AccessControlList for the user
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
*/
- public AccessControlList getACL( User user )
- throws DataBackendException, UnknownEntityException;
+ public AccessControlList getACL(User user)
+ throws DataBackendException, UnknownEntityException;
/**
* Retrieves all permissions associated with a role.
*
* @param role the role name, for which the permissions are to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return the permissions associated with the role
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role is not present.
*/
- public PermissionSet getPermissions( Role role )
- throws DataBackendException, UnknownEntityException;
+ public PermissionSet getPermissions(Role role)
+ throws DataBackendException, UnknownEntityException;
/*-----------------------------------------------------------------------
Manipulation of security information
@@ -338,11 +367,13 @@
* @param user the user.
* @param group the group.
* @param role the role.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if user account, group or role is not present.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if user account, group or role is not
+ * present.
*/
public void grant(User user, Group group, Role role)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Revoke a Role in a Group from an User.
@@ -350,11 +381,13 @@
* @param user the user.
* @param group the group.
* @param role the role.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if user account, group or role is not present.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if user account, group or role is not
+ * present.
*/
public void revoke(User user, Group group, Role role)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Revokes all roles from an User.
@@ -362,33 +395,36 @@
* This method is used when deleting an account.
*
* @param user the User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the account is not present.
*/
- public void revokeAll( User user )
- throws DataBackendException, UnknownEntityException;
+ public void revokeAll(User user)
+ throws DataBackendException, UnknownEntityException;
/**
* Grants a Role a Permission
*
* @param role the Role.
* @param permission the Permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if role or permission is not present.
*/
- public void grant( Role role, Permission permission )
- throws DataBackendException, UnknownEntityException;
+ public void grant(Role role, Permission permission)
+ throws DataBackendException, UnknownEntityException;
/**
* Revokes a Permission from a Role.
*
* @param role the Role.
* @param permission the Permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if role or permission is not present.
*/
- public void revoke( Role role, Permission permission )
- throws DataBackendException, UnknownEntityException;
+ public void revoke(Role role, Permission permission)
+ throws DataBackendException, UnknownEntityException;
/**
* Revokes all permissions from a Role.
@@ -396,11 +432,12 @@
* This method is user when deleting a Role.
*
* @param role the Role
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the Role is not present.
*/
- public void revokeAll( Role role )
- throws DataBackendException, UnknownEntityException;
+ public void revokeAll(Role role)
+ throws DataBackendException, UnknownEntityException;
/*-----------------------------------------------------------------------
Retrieval & storage of SecurityObjects
@@ -420,8 +457,9 @@
* create a new Group in the system though. Use addGroup for that.
*
* @param groupName The name of the Group to be retrieved.
+ * @return the Group
*/
- public Group getNewGroup( String groupName );
+ public Group getNewGroup(String groupName);
/**
* Retrieves a new Role. It creates
@@ -429,127 +467,148 @@
* create a new Role in the system though. Use addRole for that.
*
* @param roleName The name of the Role to be retrieved.
+ * @return the Role
*/
- public Role getNewRole( String roleName );
+ public Role getNewRole(String roleName);
/**
- * Retrieves a new Permission. It creates
- * a new Permission based on the Services Permission implementation. It does not
- * create a new Permission in the system though. Use addPermission for that.
+ * Retrieves a new Permission.
+ * It creates a new Permission based on the Services Permission
+ * implementation. It does not create a new Permission in the system though.
+ * Use addPermission for that.
*
* @param permissionName The name of the Permission to be retrieved.
+ * @return the Permission
*/
- public Permission getNewPermission( String permissionName );
+ public Permission getNewPermission(String permissionName);
/**
* Retrieve a Group object with specified name.
*
* @param name the name of the Group.
* @return an object representing the Group with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if the group does not exist.
*/
- public Group getGroup( String name )
- throws DataBackendException, UnknownEntityException;
+ public Group getGroup(String name)
+ throws DataBackendException, UnknownEntityException;
/**
* Retrieve a Role object with specified name.
*
* @param name the name of the Role.
* @return an object representing the Role with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if the role does not exist.
*/
- public Role getRole( String name )
- throws DataBackendException, UnknownEntityException;
+ public Role getRole(String name)
+ throws DataBackendException, UnknownEntityException;
/**
* Retrieve a Permission object with specified name.
*
* @param name the name of the Permission.
* @return an object representing the Permission with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if the permission does not exist.
*/
- public Permission getPermission( String name )
- throws DataBackendException, UnknownEntityException;
+ public Permission getPermission(String name)
+ throws DataBackendException, UnknownEntityException;
/**
* Retrieve a set of Groups that meet the specified Criteria.
*
* @param criteria of Group selection.
* @return a set of Groups that meet the specified Criteria.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public GroupSet getGroups(Criteria criteria)
- throws DataBackendException;
+ public GroupSet getGroups(Criteria criteria) throws DataBackendException;
/**
* Retrieve a set of Roles that meet the specified Criteria.
*
* @param criteria of Roles selection.
* @return a set of Roles that meet the specified Criteria.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public RoleSet getRoles(Criteria criteria)
- throws DataBackendException;
+ public RoleSet getRoles(Criteria criteria) throws DataBackendException;
/**
* Retrieve a set of Permissions that meet the specified Criteria.
*
* @param criteria of Permissions selection.
* @return a set of Permissions that meet the specified Criteria.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
public PermissionSet getPermissions(Criteria criteria)
- throws DataBackendException;
+ throws DataBackendException;
/**
* Retrieves all groups defined in the system.
*
* @return the names of all groups defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public GroupSet getAllGroups()
- throws DataBackendException;
+ public GroupSet getAllGroups() throws DataBackendException;
/**
* Retrieves all roles defined in the system.
*
* @return the names of all roles defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public RoleSet getAllRoles()
- throws DataBackendException;
+ public RoleSet getAllRoles() throws DataBackendException;
/**
* Retrieves all permissions defined in the system.
*
* @return the names of all roles defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public PermissionSet getAllPermissions()
- throws DataBackendException;
- /**
+ public PermissionSet getAllPermissions() throws DataBackendException;
+
+ /**
* Stores Group's attributes. The Groups is required to exist in the system.
*
* @param group The Group to be stored.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
public void saveGroup(Group group)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Stores Role's attributes. The Roles is required to exist in the system.
*
* @param role The Role to be stored.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
public void saveRole(Role role)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
- * Stores Permission's attributes. The Permissions is required to exist in the system.
+ * Stores Permission's attributes. The Permissions is required to exist in
+ * the system.
*
* @param permission The Permission to be stored.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
public void savePermission(Permission permission)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/*-----------------------------------------------------------------------
Group/Role/Permission management
@@ -560,94 +619,103 @@
*
* @param group the object describing the group to be created.
* @return the new Group object.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the group already exists.
*/
public Group addGroup(Group group)
- throws DataBackendException, EntityExistsException;
+ throws DataBackendException, EntityExistsException;
/**
* Creates a new role with specified attributes.
*
* @param role the objects describing the group to be created.
* @return the new Role object.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the role already exists.
*/
public Role addRole(Role role)
- throws DataBackendException, EntityExistsException;
+ throws DataBackendException, EntityExistsException;
/**
* Creates a new permission with specified attributes.
*
* @param permission the objects describing the group to be created.
* @return the new Permission object.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the permission already exists.
*/
public Permission addPermission(Permission permission)
- throws DataBackendException, EntityExistsException;
+ throws DataBackendException, EntityExistsException;
/**
* Removes a Group from the system.
*
* @param group the object describing group to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
public void removeGroup(Group group)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Removes a Role from the system.
*
* @param role the object describing role to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
public void removeRole(Role role)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Removes a Permission from the system.
*
* @param permission the object describing permission to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
public void removePermission(Permission permission)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Renames an existing Group.
*
* @param group the object describing the group to be renamed.
* @param name the new name for the group.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
public void renameGroup(Group group, String name)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Renames an existing Role.
*
* @param role the object describing the role to be renamed.
* @param name the new name for the role.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
public void renameRole(Role role, String name)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
/**
* Renames an existing Permission.
*
* @param permission the object describing the permission to be renamed.
* @param name the new name for the permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
public void renamePermission(Permission permission, String name)
- throws DataBackendException, UnknownEntityException;
+ throws DataBackendException, UnknownEntityException;
}
1.4 +226 -177 jakarta-turbine-2/src/java/org/apache/turbine/services/security/TurbineSecurity.java
Index: TurbineSecurity.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/TurbineSecurity.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TurbineSecurity.java 11 Jul 2002 16:53:24 -0000 1.3
+++ TurbineSecurity.java 4 Jan 2003 18:21:49 -0000 1.4
@@ -81,7 +81,8 @@
* <a name="global">
* <p> Certain Roles that the Users may have in the system may are not related
* to any specific resource nor entity. They are assigned within a special group
- * named 'global' that can be referenced in the code as {@link org.apache.turbine.om.security.Group#GLOBAL_GROUP_NAME}.
+ * named 'global' that can be referenced in the code as
+ * {@link org.apache.turbine.om.security.Group#GLOBAL_GROUP_NAME}.
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id$
@@ -96,7 +97,7 @@
*/
public static SecurityService getService()
{
- return (SecurityService)TurbineServices.getInstance().
+ return (SecurityService) TurbineServices.getInstance().
getService(SecurityService.SERVICE_NAME);
}
@@ -104,7 +105,7 @@
Management of User objects
-----------------------------------------------------------------------*/
- /*
+ /**
* This method provides client-side encryption of passwords.
*
* This is an utility method that is used by other classes to maintain
@@ -114,7 +115,7 @@
* @param password the password to process
* @return processed password
*/
- public static String encryptPassword( String password )
+ public static String encryptPassword(String password)
{
return getService().encryptPassword(password);
}
@@ -127,8 +128,7 @@
* @throws UnknownEntityException if the implementation of User interface
* could not be determined, or does not exist.
*/
- public static Class getUserClass()
- throws UnknownEntityException
+ public static Class getUserClass() throws UnknownEntityException
{
return getService().getUserClass();
}
@@ -142,8 +142,7 @@
* @return an object implementing User interface.
* @throws UnknownEntityException if the object could not be instantiated.
*/
- public static User getUserInstance()
- throws UnknownEntityException
+ public static User getUserInstance() throws UnknownEntityException
{
return getService().getUserInstance();
}
@@ -155,10 +154,10 @@
*
* @param user The user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static boolean accountExists( User user )
- throws DataBackendException
+ public static boolean accountExists(User user) throws DataBackendException
{
return getService().accountExists(user);
}
@@ -168,42 +167,48 @@
*
* The login name is used for looking up the account.
*
- * @param usename The name of the user to be checked.
+ * @param username The name of the user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static boolean accountExists( String username )
- throws DataBackendException
+ public static boolean accountExists(String username)
+ throws DataBackendException
{
return getService().accountExists(username);
}
/**
- * Authenticates an user, and constructs an User object to represent him/her.
+ * Authenticates an user, and constructs an User object to represent
+ * him/her.
*
* @param username The user name.
* @param password The user password.
* @return An authenticated Turbine User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
- * @throws PasswordMissmatchException if the supplied password was incorrect.
+ * @throws PasswordMismatchException if the supplied password was incorrect
*/
- public static User getAuthenticatedUser( String username, String password)
- throws DataBackendException, UnknownEntityException, PasswordMismatchException
+ public static User getAuthenticatedUser(String username, String password)
+ throws DataBackendException, UnknownEntityException,
+ PasswordMismatchException
{
return getService().getAuthenticatedUser(username, password);
}
/**
- * Constructs an User object to represent a registered user of the application.
+ * Constructs an User object to represent a registered user of the
+ * application.
*
* @param username The user name.
* @return A Turbine User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
*/
- public static User getUser( String username )
- throws DataBackendException, UnknownEntityException
+ public static User getUser(String username)
+ throws DataBackendException, UnknownEntityException
{
return getService().getUser(username);
}
@@ -222,21 +227,21 @@
* @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public static User[] getUsers( Criteria criteria )
- throws DataBackendException
+ public static User[] getUsers(Criteria criteria)
+ throws DataBackendException
{
return getService().getUsers(criteria);
}
/**
- * Constructs an User object to represent an anonymous user of the application.
+ * Constructs an User object to represent an anonymous user of the
+ * application.
*
* @return An anonymous Turbine User.
* @throws UnknownEntityException if the anonymous User object couldn't be
* constructed.
*/
- public static User getAnonymousUser()
- throws UnknownEntityException
+ public static User getAnonymousUser() throws UnknownEntityException
{
return getService().getAnonymousUser();
}
@@ -245,13 +250,14 @@
* Saves User's data in the permanent storage. The user account is required
* to exist in the storage.
*
- * @exception UnknownEntityException if the user's account does not
+ * @param user the user object to save
+ * @throws UnknownEntityException if the user's account does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
+ * @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public static void saveUser( User user )
- throws UnknownEntityException, DataBackendException
+ public static void saveUser(User user)
+ throws UnknownEntityException, DataBackendException
{
getService().saveUser(user);
}
@@ -262,16 +268,17 @@
* @param user an User to change password for.
* @param oldPassword the current password supplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
+ * @throws PasswordMismatchException if the supplied password was
* incorrect.
- * @exception UnknownEntityException if the user's record does not
+ * @throws UnknownEntityException if the user's record does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
+ * @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public static void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
- DataBackendException
+ public static void changePassword(User user, String oldPassword,
+ String newPassword)
+ throws PasswordMismatchException, UnknownEntityException,
+ DataBackendException
{
getService().changePassword(user, oldPassword, newPassword);
}
@@ -286,15 +293,15 @@
*
* @param user an User to change password for.
* @param password the new password.
- * @exception UnknownEntityException if the user's record does not
+ * @throws UnknownEntityException if the user's record does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
+ * @throws DataBackendException if there is a problem accessing the
* storage.
*/
- public static void forcePassword( User user, String password )
- throws UnknownEntityException, DataBackendException
+ public static void forcePassword(User user, String password)
+ throws UnknownEntityException, DataBackendException
{
- getService().forcePassword( user, password );
+ getService().forcePassword(user, password);
}
/*-----------------------------------------------------------------------
@@ -305,11 +312,13 @@
* Constructs an AccessControlList for a specific user.
*
* @param user the user for whom the AccessControlList are to be retrieved
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return the AccessControlList for the user
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if user account is not present.
*/
- public static AccessControlList getACL( User user )
- throws DataBackendException, UnknownEntityException
+ public static AccessControlList getACL(User user)
+ throws DataBackendException, UnknownEntityException
{
return getService().getACL(user);
}
@@ -321,14 +330,16 @@
/**
* Grant an User a Role in a Group.
*
- * @param User the user.
- * @param Group the group.
- * @param Role the role.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if user account, group or role is not present.
+ * @param user the user.
+ * @param group the group.
+ * @param role the role.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if user account, group or role is not
+ * present.
*/
- public static void grant( User user, Group group, Role role )
- throws DataBackendException, UnknownEntityException
+ public static void grant(User user, Group group, Role role)
+ throws DataBackendException, UnknownEntityException
{
getService().grant(user, group, role);
}
@@ -336,14 +347,16 @@
/**
* Revoke a Role in a Group from an User.
*
- * @param User the user.
- * @param Group the group.
- * @param Role the role.
- * @throws DataBackendException if there was an error accessing the data backend.
- * @throws UnknownEntityException if user account, group or role is not present.
+ * @param user the user.
+ * @param group the group.
+ * @param role the role.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
+ * @throws UnknownEntityException if user account, group or role is not
+ * present.
*/
- public static void revoke( User user, Group group, Role role )
- throws DataBackendException, UnknownEntityException
+ public static void revoke(User user, Group group, Role role)
+ throws DataBackendException, UnknownEntityException
{
getService().revoke(user, group, role);
}
@@ -354,11 +367,12 @@
* This method is used when deleting an account.
*
* @param user the User.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the account is not present.
*/
- public static void revokeAll( User user )
- throws DataBackendException, UnknownEntityException
+ public static void revokeAll(User user)
+ throws DataBackendException, UnknownEntityException
{
getService().revokeAll(user);
}
@@ -368,11 +382,12 @@
*
* @param role the Role.
* @param permission the Permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if role or permission is not present.
*/
- public static void grant( Role role, Permission permission )
- throws DataBackendException, UnknownEntityException
+ public static void grant(Role role, Permission permission)
+ throws DataBackendException, UnknownEntityException
{
getService().grant(role, permission);
}
@@ -382,11 +397,12 @@
*
* @param role the Role.
* @param permission the Permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if role or permission is not present.
*/
- public static void revoke( Role role, Permission permission )
- throws DataBackendException, UnknownEntityException
+ public static void revoke(Role role, Permission permission)
+ throws DataBackendException, UnknownEntityException
{
getService().revoke(role, permission);
}
@@ -397,11 +413,12 @@
* This method is user when deleting a Role.
*
* @param role the Role
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the Role is not present.
*/
- public static void revokeAll( Role role )
- throws DataBackendException, UnknownEntityException
+ public static void revokeAll(Role role)
+ throws DataBackendException, UnknownEntityException
{
getService().revokeAll(role);
}
@@ -416,32 +433,33 @@
* <strong>TODO</strong> throw more specific exception<br>
*
* @param user the object describing account to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param password password for the new user
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the user account already exists.
*/
- public static void addUser( User user, String password )
- throws DataBackendException, EntityExistsException
+ public static void addUser(User user, String password)
+ throws DataBackendException, EntityExistsException
{
getService().addUser(user, password);
}
-
/**
* Removes an user account from the system.
*
* <strong>TODO</strong> throw more specific exception<br>
*
* @param user the object describing the account to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the user account is not present.
*/
- public static void removeUser( User user )
- throws DataBackendException, UnknownEntityException
+ public static void removeUser(User user)
+ throws DataBackendException, UnknownEntityException
{
getService().removeUser(user);
}
-
/*-----------------------------------------------------------------------
Group/Role/Permission management
-----------------------------------------------------------------------*/
@@ -464,8 +482,7 @@
* @return An object representing the new Group.
* @throws TurbineSecurityException if the Group could not be created.
*/
- public static Group createGroup( String name )
- throws TurbineSecurityException
+ public static Group createGroup(String name) throws TurbineSecurityException
{
return getService().addGroup(getNewGroup(name));
}
@@ -478,8 +495,8 @@
* @return An object representing the new Permission.
* @throws TurbineSecurityException if the Permission could not be created.
*/
- public static Permission createPermission( String name )
- throws TurbineSecurityException
+ public static Permission createPermission(String name)
+ throws TurbineSecurityException
{
return getService().addPermission(getNewPermission(name));
}
@@ -488,11 +505,13 @@
* Retrieves a named Group.
*
* @param groupName The name of the Group to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return an object representing the Group with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the Group is not present.
*/
- public static Group getGroup( String groupName )
- throws DataBackendException, UnknownEntityException
+ public static Group getGroup(String groupName)
+ throws DataBackendException, UnknownEntityException
{
return getService().getGroup(groupName);
}
@@ -504,40 +523,45 @@
* point.
*
* @param groupName The name of the Group to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return an object representing the Group with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static Group getNewGroup( String groupName )
- throws DataBackendException
+ public static Group getNewGroup(String groupName)
+ throws DataBackendException
{
return getService().getNewGroup(groupName);
}
/**
- * Retrieves a named Permission. If the Permission does not exist, it creates
- * a new Permission based on the Services Permission implementation. It is ok
- * to pass in null or "" here and then use Permission.setName() at a later
- * point.
+ * Retrieves a named Role. If the Role does not exist, it creates a new Role
+ * based on the Services Role implementation.
+ * It is ok to pass in null or "" here and then use Role.setName() at
+ * a later point.
*
* @param roleName The name of the Role to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return an object representing the Role with specified name.
+ * @throws TurbineSecurityException if the Role could not be retrieved
*/
- public static Role getNewRole( String roleName )
- throws TurbineSecurityException
+ public static Role getNewRole(String roleName)
+ throws TurbineSecurityException
{
return getService().getNewRole(roleName);
}
/**
- * Retrieves a named Permission. If the Permission does not exist, it creates
- * a new Permission based on the Services Permission implementation. It is ok
- * to pass in null or "" here and then use Permission.setName() at a later
- * point.
+ * Retrieves a named Permission. If the Permission does not exist, it
+ * creates a new Permission based on the Services Permission implementation.
+ * It is ok to pass in null or "" here and then use Permission.setName() at
+ * a later point.
*
- * @param groupName The name of the Permission to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param permissionName The name of the Permission to be retrieved.
+ * @return an object representing the Permission with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static Permission getNewPermission( String permissionName )
- throws DataBackendException
+ public static Permission getNewPermission(String permissionName)
+ throws DataBackendException
{
return getService().getNewPermission(permissionName);
}
@@ -546,11 +570,13 @@
* Retrieves a named Role.
*
* @param roleName The name of the Role to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return an object representing the Role with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the Role is not present.
*/
- public static Role getRole( String roleName )
- throws DataBackendException, UnknownEntityException
+ public static Role getRole(String roleName)
+ throws DataBackendException, UnknownEntityException
{
return getService().getRole(roleName);
}
@@ -559,11 +585,13 @@
* Retrieves a named Permission.
*
* @param permissionName The name of the Permission to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return an object representing the Permission with specified name.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the Permission is not present.
*/
- public static Permission getPermission( String permissionName )
- throws DataBackendException, UnknownEntityException
+ public static Permission getPermission(String permissionName)
+ throws DataBackendException, UnknownEntityException
{
return getService().getPermission(permissionName);
}
@@ -571,24 +599,27 @@
/**
* Retrieve a set of Groups that meet the specified Criteria.
*
- * @param a Criteria of Group selection.
+ * @param criteria a Criteria of Group selection.
* @return a set of Groups that meet the specified Criteria.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static GroupSet getGroups( Criteria criteria )
- throws DataBackendException
+ public static GroupSet getGroups(Criteria criteria)
+ throws DataBackendException
{
return getService().getGroups(criteria);
}
-
/**
* Retrieve a set of Roles that meet the specified Criteria.
*
* @param criteria a Criteria of Roles selection.
* @return a set of Roles that meet the specified Criteria.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static RoleSet getRoles( Criteria criteria )
- throws DataBackendException
+ public static RoleSet getRoles(Criteria criteria)
+ throws DataBackendException
{
return getService().getRoles(criteria);
}
@@ -598,9 +629,11 @@
*
* @param criteria a Criteria of Permissions selection.
* @return a set of Permissions that meet the specified Criteria.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static PermissionSet getPermissions( Criteria criteria )
- throws DataBackendException
+ public static PermissionSet getPermissions(Criteria criteria)
+ throws DataBackendException
{
return getService().getPermissions(criteria);
}
@@ -609,9 +642,10 @@
* Retrieves all groups defined in the system.
*
* @return the names of all groups defined in the system.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static GroupSet getAllGroups()
- throws DataBackendException
+ public static GroupSet getAllGroups() throws DataBackendException
{
return getService().getAllGroups();
}
@@ -620,10 +654,10 @@
* Retrieves all roles defined in the system.
*
* @return the names of all roles defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static RoleSet getAllRoles()
- throws DataBackendException
+ public static RoleSet getAllRoles() throws DataBackendException
{
return getService().getAllRoles();
}
@@ -632,10 +666,10 @@
* Retrieves all permissions defined in the system.
*
* @return the names of all roles defined in the system.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public static PermissionSet getAllPermissions()
- throws DataBackendException
+ public static PermissionSet getAllPermissions() throws DataBackendException
{
return getService().getAllPermissions();
}
@@ -644,11 +678,13 @@
* Retrieves all permissions associated with a role.
*
* @param role the role name, for which the permissions are to be retrieved.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @return the Permissions for the specified role
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role is not present.
*/
- public static PermissionSet getPermissions( Role role )
- throws DataBackendException, UnknownEntityException
+ public static PermissionSet getPermissions(Role role)
+ throws DataBackendException, UnknownEntityException
{
return getService().getPermissions(role);
}
@@ -657,11 +693,12 @@
* Stores Group's attributes. The Groups is required to exist in the system.
*
* @param group The Group to be stored.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
- public static void saveGroup( Group group )
- throws DataBackendException, UnknownEntityException
+ public static void saveGroup(Group group)
+ throws DataBackendException, UnknownEntityException
{
getService().saveGroup(group);
}
@@ -670,24 +707,27 @@
* Stores Role's attributes. The Roles is required to exist in the system.
*
* @param role The Role to be stored.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
- public static void saveRole( Role role )
- throws DataBackendException, UnknownEntityException
+ public static void saveRole(Role role)
+ throws DataBackendException, UnknownEntityException
{
getService().saveRole(role);
}
/**
- * Stores Permission's attributes. The Permissions is required to exist in the system.
+ * Stores Permission's attributes. The Permissions is required to exist in
+ * the system.
*
* @param permission The Permission to be stored.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
- public static void savePermission( Permission permission )
- throws DataBackendException, UnknownEntityException
+ public static void savePermission(Permission permission)
+ throws DataBackendException, UnknownEntityException
{
getService().savePermission(permission);
}
@@ -696,11 +736,12 @@
* Creates a new group with specified attributes.
*
* @param group the object describing the group to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the group already exists.
*/
- public static void addGroup( Group group )
- throws DataBackendException, EntityExistsException
+ public static void addGroup(Group group)
+ throws DataBackendException, EntityExistsException
{
getService().addGroup(group);
}
@@ -708,12 +749,13 @@
/**
* Creates a new role with specified attributes.
*
- * @param group the objects describing the group to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param role the objects describing the role to be created.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the role already exists.
*/
- public static void addRole( Role role )
- throws DataBackendException, EntityExistsException
+ public static void addRole(Role role)
+ throws DataBackendException, EntityExistsException
{
getService().addRole(role);
}
@@ -721,12 +763,13 @@
/**
* Creates a new permission with specified attributes.
*
- * @param group the objects describing the group to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param permission the objects describing the permission to be created.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the permission already exists.
*/
- public static void addPermission( Permission permission )
- throws DataBackendException, EntityExistsException
+ public static void addPermission(Permission permission)
+ throws DataBackendException, EntityExistsException
{
getService().addPermission(permission);
}
@@ -734,12 +777,13 @@
/**
* Removes a Group from the system.
*
- * @param the object describing group to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param group the object describing group to be removed.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
- public static void removeGroup( Group group )
- throws DataBackendException, UnknownEntityException
+ public static void removeGroup(Group group)
+ throws DataBackendException, UnknownEntityException
{
getService().removeGroup(group);
}
@@ -747,12 +791,13 @@
/**
* Removes a Role from the system.
*
- * @param the object describing role to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param role the object describing role to be removed.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
- public static void removeRole( Role role )
- throws DataBackendException, UnknownEntityException
+ public static void removeRole(Role role)
+ throws DataBackendException, UnknownEntityException
{
getService().removeRole(role);
}
@@ -760,12 +805,13 @@
/**
* Removes a Permission from the system.
*
- * @param the object describing permission to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param permission the object describing permission to be removed.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
- public static void removePermission( Permission permission )
- throws DataBackendException, UnknownEntityException
+ public static void removePermission(Permission permission)
+ throws DataBackendException, UnknownEntityException
{
getService().removePermission(permission);
}
@@ -773,13 +819,14 @@
/**
* Renames an existing Group.
*
- * @param the object describing the group to be renamed.
+ * @param group the object describing the group to be renamed.
* @param name the new name for the group.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the group does not exist.
*/
- public static void renameGroup( Group group, String name )
- throws DataBackendException, UnknownEntityException
+ public static void renameGroup(Group group, String name)
+ throws DataBackendException, UnknownEntityException
{
getService().renameGroup(group, name);
}
@@ -787,13 +834,14 @@
/**
* Renames an existing Role.
*
- * @param the object describing the role to be renamed.
+ * @param role the object describing the role to be renamed.
* @param name the new name for the role.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the role does not exist.
*/
- public static void renameRole( Role role, String name )
- throws DataBackendException, UnknownEntityException
+ public static void renameRole(Role role, String name)
+ throws DataBackendException, UnknownEntityException
{
getService().renameRole(role, name);
}
@@ -801,13 +849,14 @@
/**
* Renames an existing Permission.
*
- * @param the object describing the permission to be renamed.
+ * @param permission the object describing the permission to be renamed.
* @param name the new name for the permission.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the permission does not exist.
*/
- public static void renamePermission( Permission permission, String name )
- throws DataBackendException, UnknownEntityException
+ public static void renamePermission(Permission permission, String name)
+ throws DataBackendException, UnknownEntityException
{
getService().renamePermission(permission, name);
}
1.3 +67 -72 jakarta-turbine-2/src/java/org/apache/turbine/services/security/UserManager.java
Index: UserManager.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/security/UserManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UserManager.java 11 Jul 2002 07:16:42 -0000 1.2
+++ UserManager.java 4 Jan 2003 18:21:49 -0000 1.3
@@ -54,21 +54,22 @@
* <http://www.apache.org/>.
*/
+import org.apache.torque.util.Criteria;
import org.apache.turbine.om.security.User;
import org.apache.turbine.util.security.DataBackendException;
-import org.apache.turbine.util.security.UnknownEntityException;
import org.apache.turbine.util.security.EntityExistsException;
import org.apache.turbine.util.security.PasswordMismatchException;
-
-import org.apache.torque.util.Criteria;
+import org.apache.turbine.util.security.UnknownEntityException;
/**
* An UserManager performs {@link org.apache.turbine.om.security.User} objects
- * related tasks on behalf of the {@link org.apache.turbine.services.security.BaseSecurityService}.
+ * related tasks on behalf of the
+ * {@link org.apache.turbine.services.security.BaseSecurityService}.
*
* The responsibilities of this class include loading data of an user from the
- * storage and putting them into the {@link org.apache.turbine.om.security.User} objects,
- * saving those data to the permanent storage, and authenticating users.
+ * storage and putting them into the {@link org.apache.turbine.om.security.User}
+ * objects, saving those data to the permanent storage, and authenticating
+ * users.
*
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id$
@@ -82,36 +83,35 @@
*
* @param user The user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public boolean accountExists( User user )
- throws DataBackendException;
+ public boolean accountExists(User user) throws DataBackendException;
/**
* Check whether a specified user's account exists.
*
* The login name is used for looking up the account.
*
- * @param usename The name of the user to be checked.
+ * @param username The name of the user to be checked.
* @return true if the specified account exists
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
*/
- public boolean accountExists( String username )
- throws DataBackendException;
+ public boolean accountExists(String username) throws DataBackendException;
- /**
+ /**
* Retrieve a user from persistent storage using username as the
* key.
*
* @param username the name of the user.
* @return an User object.
- * @exception UnknownEntityException if the user's record does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws UnknownEntityException if the user's record does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public User retrieve( String username )
- throws UnknownEntityException, DataBackendException;
+ public User retrieve(String username)
+ throws UnknownEntityException, DataBackendException;
/**
* Retrieve a set of users that meet the specified criteria.
@@ -124,11 +124,9 @@
*
* @param criteria The criteria of selection.
* @return a List of users meeting the criteria.
- * @throws DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public User[] retrieve( Criteria criteria )
- throws DataBackendException;
+ public User[] retrieve(Criteria criteria) throws DataBackendException;
/**
* Retrieve a user from persistent storage using username as the
@@ -139,29 +137,26 @@
* @param username the name of the user.
* @param password the user supplied password.
* @return an User object.
- * @exception PasswordMismatchException if the supplied password was
- * incorrect.
- * @exception UnknownEntityException if the user's record does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
- */
- public User retrieve( String username, String password )
- throws PasswordMismatchException, UnknownEntityException,
- DataBackendException;
+ * @throws PasswordMismatchException if the supplied password was incorrect.
+ * @throws UnknownEntityException if the user's record does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
+ */
+ public User retrieve(String username, String password)
+ throws PasswordMismatchException, UnknownEntityException,
+ DataBackendException;
/**
* Save an User object to persistent storage. User's record is
* required to exist in the storage.
*
* @param user an User object to store.
- * @exception UnknownEntityException if the user's record does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws UnknownEntityException if the user's record does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public void store( User user )
- throws UnknownEntityException, DataBackendException;
+ public void store(User user)
+ throws UnknownEntityException, DataBackendException;
/**
* Authenticate an User with the specified password. If authentication
@@ -170,52 +165,53 @@
*
* @param user an User object to authenticate.
* @param password the user supplied password.
- * @exception PasswordMismatchException if the supplied password was
- * incorrect.
- * @exception UnknownEntityException if the user's record does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
- */
- public void authenticate( User user, String password )
- throws PasswordMismatchException, UnknownEntityException,
- DataBackendException;
+ * @throws PasswordMismatchException if the supplied password was incorrect.
+ * @throws UnknownEntityException if the user's record does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
+ */
+ public void authenticate(User user, String password)
+ throws PasswordMismatchException, UnknownEntityException,
+ DataBackendException;
/**
* Creates new user account with specified attributes.
*
* @param user the object describing account to be created.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @param initialPassword password for the new user
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws EntityExistsException if the user account already exists.
*/
- public void createAccount( User user, String initialPassword )
- throws EntityExistsException, DataBackendException;
+ public void createAccount(User user, String initialPassword)
+ throws EntityExistsException, DataBackendException;
/**
* Removes an user account from the system.
*
* @param user the object describing the account to be removed.
- * @throws DataBackendException if there was an error accessing the data backend.
+ * @throws DataBackendException if there was an error accessing the data
+ * backend.
* @throws UnknownEntityException if the user account is not present.
*/
- public void removeAccount( User user )
- throws UnknownEntityException, DataBackendException;
+ public void removeAccount(User user)
+ throws UnknownEntityException, DataBackendException;
+
/**
* Change the password for an User.
*
* @param user an User to change password for.
* @param oldPassword the current password suplied by the user.
* @param newPassword the current password requested by the user.
- * @exception PasswordMismatchException if the supplied password was
- * incorrect.
- * @exception UnknownEntityException if the user's record does not
- * exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
- */
- public void changePassword( User user, String oldPassword, String newPassword )
- throws PasswordMismatchException, UnknownEntityException,
- DataBackendException;
+ * @throws PasswordMismatchException if the supplied password was incorrect.
+ * @throws UnknownEntityException if the user's record does not
+ * exist in the database.
+ * @throws DataBackendException if there is a problem accessing the storage.
+ */
+ public void changePassword(User user, String oldPassword,
+ String newPassword)
+ throws PasswordMismatchException, UnknownEntityException,
+ DataBackendException;
/**
* Forcibly sets new password for an User.
@@ -227,11 +223,10 @@
*
* @param user an User to change password for.
* @param password the new password.
- * @exception UnknownEntityException if the user's record does not
+ * @throws UnknownEntityException if the user's record does not
* exist in the database.
- * @exception DataBackendException if there is a problem accessing the
- * storage.
+ * @throws DataBackendException if there is a problem accessing the storage.
*/
- public void forcePassword( User user, String password )
- throws UnknownEntityException, DataBackendException;
+ public void forcePassword(User user, String password)
+ throws UnknownEntityException, DataBackendException;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>