Removed DOCUMENT ME comments that were generated and applied source code
[utils] / security / src / main / java / org / wamblee / security / authorization / GroupUserCondition.java
1 /*
2  * Copyright 2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.security.authorization;
17
18 import org.wamblee.persistence.AbstractPersistent;
19
20 import org.wamblee.usermgt.User;
21
22 /**
23  * Checks if a user against a specific group.
24  * 
25  * @author Erik Brakkee
26  */
27 public class GroupUserCondition extends AbstractPersistent implements
28     UserCondition {
29     /**
30      * Group the user must be in.
31      */
32     private String group;
33
34     /**
35      * Constructs the condition.
36      * 
37      * @param aGroup
38      *            Group the user must be in.
39      */
40     public GroupUserCondition(String aGroup) {
41         group = aGroup;
42     }
43
44     /**
45      * For OR mapping.
46      * 
47      */
48     protected GroupUserCondition() {
49         group = null;
50     }
51
52     /*
53      * (non-Javadoc)
54      * 
55      * @see
56      * org.wamblee.security.authorization.UserCondition#matches(org.wamblee.
57      * usermgt.UserAccessor)
58      */
59     public boolean matches(User aUser) {
60         return aUser.isInGroup(group);
61     }
62
63     /**
64      * 
65      * @return Returns the group.
66      */
67     protected String getGroup() {
68         return group;
69     }
70
71     /**
72      * 
73      * @param aGroup
74      *            The group to set.
75      */
76     protected void setGroup(String aGroup) {
77         group = aGroup;
78     }
79
80     /*
81      * (non-Javadoc)
82      * 
83      * @see java.lang.Object#toString()
84      */
85     @Override
86     public String toString() {
87         return "GroupUserCondition(group=" + group + ")";
88     }
89 }