source code formatting.
[utils] / security / src / main / java / org / wamblee / usermgt / UserAdministrationImpl.java
index 55793da6256c04c0f2788035947d77c0b08dbd91..071791b258d9f806ebce0e24b1e563bc34631868 100644 (file)
@@ -1,19 +1,18 @@
 /*
  * Copyright 2005 the original author or authors.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.wamblee.usermgt;
 
 import static org.wamblee.usermgt.UserMgtException.Reason.DUPLICATE_GROUP;
@@ -25,13 +24,13 @@ import static org.wamblee.usermgt.UserMgtException.Reason.UNKNOWN_USER;
 
 import java.util.Set;
 
+
 /**
  * Administration of users and groups.
  *
  * @author Erik Brakkee
  */
 public class UserAdministrationImpl implements UserAdministration {
-   
     /**
      * All known users.
      */
@@ -41,126 +40,200 @@ public class UserAdministrationImpl implements UserAdministration {
      * All known groups.
      */
     private GroupSet groups;
-    
+
     /**
-     * Validator for user names. 
+     * Validator for user names.
      */
     private NameValidator userValidator;
-    
+
     /**
-     * Validator for group names. 
+     * Validator for group names.
      */
     private NameValidator groupValidator;
-    
-    /**
+
+/**
      * Constructs empty user administration.
      * 
      */
-    public UserAdministrationImpl(UserSet aUsers, GroupSet aGroups, NameValidator aUserValidator, 
-              NameValidator aGroupValidator) { 
-        users = aUsers;
-        groups = aGroups;
-        userValidator = aUserValidator;
-        groupValidator = aGroupValidator;
+    public UserAdministrationImpl(UserSet aUsers, GroupSet aGroups,
+        NameValidator aUserValidator, NameValidator aGroupValidator) {
+        users              = aUsers;
+        groups             = aGroups;
+        userValidator      = aUserValidator;
+        groupValidator     = aGroupValidator;
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#createUser(java.lang.String,
      *      java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aUser DOCUMENT ME!
+     * @param aPassword DOCUMENT ME!
+     * @param aGroup DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public User createUser(String aUser, String aPassword, Group aGroup)
-            throws UserMgtException {
+        throws UserMgtException {
         userValidator.validate(aUser);
         checkGroup(aGroup);
+
         User user = users.createUser(aUser, aPassword, aGroup);
+
         return new User(user);
     }
-    
+
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#createGroup(java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aName DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public Group createGroup(String aName) throws UserMgtException {
         groupValidator.validate(aName);
+
         Group group = new Group(aName);
+
         if (groups.contains(group)) {
             throw new UserMgtException(DUPLICATE_GROUP, group);
         }
+
         groups.add(group);
+
         return new Group(group);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#userModified(org.wamblee.usermgt.User)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aUser DOCUMENT ME!
+     */
     public void userModified(User aUser) {
         users.userModified(aUser);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#groupModified(org.wamblee.usermgt.Group)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aGroup DOCUMENT ME!
+     */
     public void groupModified(Group aGroup) {
         groups.groupModified(aGroup);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#getUser(java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aName DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public User getUser(String aName) {
         return users.find(aName);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#getGroup(java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aName DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public Group getGroup(String aName) {
         return groups.find(aName);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#getUsers()
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public Set<User> getUsers() {
         return users.list();
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#getUsers(org.wamblee.usermgt.Group)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aGroup DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public Set<User> getUsers(Group aGroup) {
         return users.list(aGroup);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#getGroups()
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public Set<Group> getGroups() {
         return groups.list();
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#removeUser(org.wamblee.usermgt.User)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aUser DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public void removeUser(User aUser) throws UserMgtException {
         checkUser(aUser);
         users.remove(aUser);
@@ -168,32 +241,52 @@ public class UserAdministrationImpl implements UserAdministration {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#removeGroup(org.wamblee.usermgt.Group)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aGroup DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public void removeGroup(Group aGroup) throws UserMgtException {
         checkGroup(aGroup);
+
         if (getUsers(aGroup).size() > 0) {
             throw new UserMgtException(GROUP_STILL_OCCUPIED, aGroup);
         }
+
         groups.remove(aGroup);
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#renameUser(org.wamblee.usermgt.User,
      *      java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aUser DOCUMENT ME!
+     * @param aUserName DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public void renameUser(User aUser, String aUserName)
-            throws UserMgtException {
+        throws UserMgtException {
         checkUser(aUser);
+
         if (aUser.getName().equals(aUserName)) {
             throw new UserMgtException(TRIVIAL_RENAME, aUser);
         }
+
         if (users.find(aUserName) != null) {
             throw new UserMgtException(DUPLICATE_USER, aUser);
         }
+
         userValidator.validate(aUserName);
         // we are modifying the user so we should re-insert it into the set
         // after renaming it.
@@ -204,19 +297,30 @@ public class UserAdministrationImpl implements UserAdministration {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#renameGroup(org.wamblee.usermgt.Group,
      *      java.lang.String)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aGroup DOCUMENT ME!
+     * @param aGroupName DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public void renameGroup(Group aGroup, String aGroupName)
-            throws UserMgtException {
+        throws UserMgtException {
         checkGroup(aGroup);
+
         if (aGroup.getName().equals(aGroupName)) {
             throw new UserMgtException(TRIVIAL_RENAME, aGroup);
         }
+
         if (groups.find(aGroupName) != null) {
             throw new UserMgtException(DUPLICATE_GROUP, aGroup);
         }
+
         groupValidator.validate(aGroupName);
         // we are renaming the group so we should re-insert it into the set
         // after renaming it.
@@ -227,12 +331,20 @@ public class UserAdministrationImpl implements UserAdministration {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#addUserToGroup(org.wamblee.usermgt.User,
      *      org.wamblee.usermgt.Group)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aUser DOCUMENT ME!
+     * @param aGroup DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public void addUserToGroup(User aUser, Group aGroup)
-            throws UserMgtException {
+        throws UserMgtException {
         checkUser(aUser);
         checkGroup(aGroup);
         aUser.addGroup(aGroup);
@@ -241,12 +353,20 @@ public class UserAdministrationImpl implements UserAdministration {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.wamblee.usermgt.UserAdministration#removeUserFromGroup(org.wamblee.usermgt.User,
      *      org.wamblee.usermgt.Group)
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @param aUser DOCUMENT ME!
+     * @param aGroup DOCUMENT ME!
+     *
+     * @throws UserMgtException DOCUMENT ME!
+     */
     public void removeUserFromGroup(User aUser, Group aGroup)
-            throws UserMgtException {
+        throws UserMgtException {
         checkUser(aUser);
         checkGroup(aGroup);
         aUser.removeGroup(aGroup);
@@ -254,7 +374,10 @@ public class UserAdministrationImpl implements UserAdministration {
     }
 
     /**
+     * DOCUMENT ME!
+     *
      * @param aUser
+     *
      * @throws UserMgtException
      */
     private void checkUser(User aUser) throws UserMgtException {
@@ -264,7 +387,10 @@ public class UserAdministrationImpl implements UserAdministration {
     }
 
     /**
+     * DOCUMENT ME!
+     *
      * @param aGroup
+     *
      * @throws UserMgtException
      */
     private void checkGroup(Group aGroup) throws UserMgtException {
@@ -272,18 +398,28 @@ public class UserAdministrationImpl implements UserAdministration {
             throw new UserMgtException(UNKNOWN_GROUP, aGroup);
         }
     }
-    
+
     /* (non-Javadoc)
      * @see org.wamblee.usermgt.UserAdministration#getUserCount()
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public int getUserCount() {
-        return users.size(); 
+        return users.size();
     }
-    
+
     /* (non-Javadoc)
      * @see org.wamblee.usermgt.UserAdministration#getGroupCount()
      */
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
     public int getGroupCount() {
-        return groups.size(); 
+        return groups.size();
     }
 }