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.Collection;
20  
21  import org.apache.jetspeed.security.om.InternalRolePrincipal;
22  
23  /***
24   * <p>{@link InternalRolePrincipal} interface implementation.</p>
25   * 
26   * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
27   */
28  public class InternalRolePrincipalImpl extends InternalPrincipalImpl implements InternalRolePrincipal
29  {
30      /*** The serial version uid. */
31      private static final long serialVersionUID = 4422827842052325846L;
32      
33      /*** <p>Role principal security class.</p> */
34      static String ROLE_PRINCIPAL_CLASSNAME = "org.apache.jetspeed.security.InternalRolePrincipalImpl";
35  
36      /***
37       * <p>Role principal implementation default constructor.</p>
38       */
39      public InternalRolePrincipalImpl()
40      {
41          super();
42      }
43  
44      /***
45       * <p>Constructor to create a new role principal.</p>
46       * @param fullPath The role full path.
47       */
48      public InternalRolePrincipalImpl(String fullPath)
49      {
50          super(ROLE_PRINCIPAL_CLASSNAME, fullPath);
51      }
52  
53      private Collection userPrincipals;
54  
55      /***
56       * @see org.apache.jetspeed.security.om.InternalRolePrincipal#getUserPrincipals()
57       */
58      public Collection getUserPrincipals()
59      {
60          return this.userPrincipals;
61      }
62  
63      /***
64       * @see org.apache.jetspeed.security.om.InternalRolePrincipal#setUserPrincipals(java.util.Collection)
65       */
66      public void setUserPrincipals(Collection userPrincipals)
67      {
68          this.userPrincipals = userPrincipals;
69      }
70  
71      private Collection groupPrincipals;
72  
73      /***
74       * @see org.apache.jetspeed.security.om.InternalRolePrincipal#getGroupPrincipals()
75       */
76      public Collection getGroupPrincipals()
77      {
78          return this.groupPrincipals;
79      }
80  
81      /***
82       * @see org.apache.jetspeed.security.om.InternalRolePrincipal#setGroupPrincipals(java.util.Collection)
83       */
84      public void setGroupPrincipals(Collection groupPrincipals)
85      {
86          this.groupPrincipals = groupPrincipals;
87      }
88  
89      /***
90       * <p>Compares this {@link InternalRolePrincipal} to the provided role principal
91       * and check if they are equal.</p>
92       * return Whether the {@link InternalRolePrincipal} are equal.
93       */
94      public boolean equals(Object object)
95      {  
96          if (!(object instanceof InternalRolePrincipal))
97              return false;
98  
99          InternalRolePrincipal r = (InternalRolePrincipal) object;
100         boolean isEqual = (r.getFullPath().equals(this.getFullPath()));
101         return isEqual;
102     }
103 
104 }