X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=security%2Fimpl%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsecurity%2Fauthentication%2FUserAdministration.java;h=ab8b8f1c82fad8cbd421b914b94be5ab613d918a;hb=f4f8467b507b7bb401e4ad0749ea426208831846;hp=321481d0d79313b5035131c7f41eac8272449792;hpb=03b34d260efda9f7df9fe35a703acd83c0cfe317;p=utils diff --git a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java index 321481d0..ab8b8f1c 100644 --- a/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java +++ b/security/impl/src/main/java/org/wamblee/security/authentication/UserAdministration.java @@ -15,8 +15,11 @@ */ package org.wamblee.security.authentication; +import java.util.List; import java.util.Set; +import org.wamblee.security.authentication.UserMgtException.Reason; + /** * Interface for user administration. Manages the users and groups. * @@ -30,16 +33,13 @@ public interface UserAdministration { * Username. * @param aPassword * Password. - * @param aGroup - * Group. * * @return User. * * @throws UserMgtException * In case there is a conflict with an existing user. */ - User createUser(String aUser, String aPassword, Group aGroup) - throws UserMgtException; + void createUser(String aUser, String aPassword); /** * Creates a new group. @@ -52,63 +52,88 @@ public interface UserAdministration { * @throws UserMgtException * In case there is a conflict with an existing group. */ - Group createGroup(String aName) throws UserMgtException; - + void createGroup(String aName); + /** + * Checks if a user exists. + * @param aUser User to check. + * @return True iff user exists. + */ + boolean checkUser(String aUser); + + + /** + * Check if a group exists. + * @param aGroup Group. + * @return True iff group exists. + */ + boolean checkGroup(String aGroup); + + /** + * Checks the password. * - * @return Number of users. + * @param aUser + * User to check password for. + * @param aPassword + * Password to check. + * @throws UserMgtException In case user does not exist. + * @return True iff password is ok. */ - int getUserCount(); + boolean checkPassword(String aUser, String aPassword); /** + * Changes the password. * - * @return Number of groups. + * @param aUser + * User. + * @param aOldPassword + * Old password. + * @param aNewPassword + * New password. + * + * @throws UserMgtException Inc ase the user does not exist. + * @return True if the password was changed. */ - int getGroupCount(); + boolean changePassword(String aUser, String aOldPassword, String aNewPassword); /** - * Must be called when the user is modified. * * @param aUser * User. - * @return The modified user. The user passed in to this call should be considered invalid. + * @param aPassword + * The password to set. + * + * @throws UserMgtException Inc ase the user does not exist. */ - void userModified(User aUser); + void setPassword(String aUser, String aPassword); /** - * Must be called when the group is modified. - * - * @param aGroup - * Group. + * Checks if the user belongs to the given group. + * @param aUser User + * @param aGroup Group. + * @return True iff user is in group + * @throws UserMgtException In case the user or group do not exist. */ - void groupModified(Group aGroup); + boolean isInGroup(String aUser, String aGroup); /** - * Gets the user for a given name. - * - * @param aName - * User name. * - * @return User or null if not found. + * @return Number of users. */ - User getUser(String aName); + int getUserCount(); /** - * Gets the group for a given group name. * - * @param aName - * Group name. - * - * @return Group or null if not found. + * @return Number of groups. */ - Group getGroup(String aName); + int getGroupCount(); /** * Get the users. * * @return All known users. */ - Set getUsers(); + List getUsers(); /** * Gets the users for a given group. @@ -117,20 +142,28 @@ public interface UserAdministration { * Group. * @return Set of users (always non-null). */ - Set getUsers(Group aGroup); + List getUsers(String aGroup); /** - * Gets all known groups. + * Gets all groups. * * @return Groups. */ - Set getGroups(); + List getGroups(); + /** + * Gets all groups for a given user. + * + * @param aUser user. + * @return Groups. + */ + List getGroups(String aUser); + /** * Renames a user. * - * @param aUser - * User object for which user name must be changed. + * @param aOldUserName + * Current user name. * @param aUserName * New user name. * @@ -138,7 +171,7 @@ public interface UserAdministration { * In case the user is not known or the new user name is already * in use by another user. */ - void renameUser(User aUser, String aUserName) throws UserMgtException; + void renameUser(String aOldUserName, String aUserName); /** * Renames a group. @@ -152,7 +185,7 @@ public interface UserAdministration { * In case the new group name is already used by another group * of if the existing group is unknown. */ - void renameGroup(Group aGroup, String aGroupName) throws UserMgtException; + void renameGroup(String aOldGroup, String aGroupName); /** * Removes the user. @@ -163,7 +196,7 @@ public interface UserAdministration { * @throws UserMgtException * In case the user does not exist. */ - void removeUser(User aUser) throws UserMgtException; + void removeUser(String aUser); /** * Removes the group. @@ -174,7 +207,7 @@ public interface UserAdministration { * @throws UserMgtException * In case there are still users that are in the given group. */ - void removeGroup(Group aGroup) throws UserMgtException; + void removeGroup(String aGroup); /** * Adds a user to a group. @@ -188,7 +221,7 @@ public interface UserAdministration { * In case the user or group or not known or if the user is * already part of the group. */ - void addUserToGroup(User aUser, Group aGroup) throws UserMgtException; + void addUserToGroup(String aUser, String aGroup); /** * Removes a user from a group. @@ -202,5 +235,5 @@ public interface UserAdministration { * In case the user or group are unknown or if the user is not * part of the group. */ - void removeUserFromGroup(User aUser, Group aGroup) throws UserMgtException; + void removeUserFromGroup(String aUser, String aGroup); }