View Javadoc

1   /* 
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.security.om.impl;
18  
19  import java.util.ArrayList;
20  import java.util.Collection;
21  
22  import org.apache.jetspeed.security.om.InternalGroupPrincipal;
23  
24  /***
25   * <p>{@link InternalGroupPrincipal} interface implementation.</p>
26   * 
27   * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
28   */
29  public class InternalGroupPrincipalImpl extends InternalPrincipalImpl implements InternalGroupPrincipal
30  {
31      /*** The serial version uid. */
32      private static final long serialVersionUID = -8236429453373927824L;
33      
34      /*** <p>Group principal security class.</p> */
35      static String GROUP_PRINCIPAL_CLASSNAME = "org.apache.jetspeed.security.InternalGroupPrincipalImpl";
36  
37      /***
38       * <p>Group principal implementation default constructor.</p>
39       */
40      public InternalGroupPrincipalImpl()
41      {
42          super();
43      }
44  
45      /***
46       * <p>Constructor to create a new group principal.</p>
47       * @param fullPath The group full path.
48       */
49      public InternalGroupPrincipalImpl(String fullPath)
50      {
51          super(GROUP_PRINCIPAL_CLASSNAME, fullPath); 
52          this.rolePrincipals = new ArrayList();       
53      }
54  
55      private Collection userPrincipals;
56  
57      /***
58       * @see org.apache.jetspeed.security.om.InternalGroupPrincipal#getUserPrincipals()
59       */
60      public Collection getUserPrincipals()
61      {
62          return this.userPrincipals;
63      }
64  
65      /***
66       * @see org.apache.jetspeed.security.om.InternalGroupPrincipal#setUserPrincipals(java.util.Collection)
67       */
68      public void setUserPrincipals(Collection userPrincipals)
69      {
70          this.userPrincipals = userPrincipals;
71      }
72  
73      private Collection rolePrincipals;
74  
75      /***
76       * @see org.apache.jetspeed.security.om.InternalGroupPrincipal#getRolePrincipals()
77       */
78      public Collection getRolePrincipals()
79      {
80          return this.rolePrincipals;
81      }
82  
83      /***
84       * @see org.apache.jetspeed.security.om.InternalGroupPrincipal#setRolePrincipals(java.util.Collection)
85       */
86      public void setRolePrincipals(Collection rolePrincipals)
87      {
88          this.rolePrincipals = rolePrincipals;
89      }
90  
91      /***
92       * <p>Compares this {@link InternalGroupPrincipal} to the provided group principal
93       * and check if they are equal.</p>
94       * return Whether the {@link InternalGroupPrincipal} are equal.
95       */
96      public boolean equals(Object object)
97      {  
98          if (!(object instanceof InternalGroupPrincipal))
99              return false;
100 
101         InternalGroupPrincipal r = (InternalGroupPrincipal) object;
102         boolean isEqual = (r.getFullPath().equals(this.getFullPath()));
103         return isEqual;
104     }
105 }