1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */17packageorg.apache.jetspeed.security.om.impl;
1819import java.util.ArrayList;
20import java.util.Collection;
2122import org.apache.jetspeed.security.om.InternalUserPrincipal;
2324/***25 * <p>{@link InternalUserPrincipal} interface implementation.</p>26 * 27 * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>28 */29publicclassInternalUserPrincipalImplextendsInternalPrincipalImpl implements InternalUserPrincipal
30 {
31/*** The serial version uid. */32privatestaticfinallong serialVersionUID = 6713096308414915156L;
3334/*** <p>User principal security class.</p> */35static String USER_PRINCIPAL_CLASSNAME = "org.apache.jetspeed.security.InternalUserPrincipalImpl";
3637/*** The credentials. */38private Collection credentials;
3940/*** The role principals. */41private Collection rolePrincipals;
4243/*** The group principals. */44private Collection groupPrincipals;
4546/***47 * <p>InternalUserPrincipal implementation default constructor.</p>48 */49publicInternalUserPrincipalImpl()
50 {
51super();
52 }
5354/***55 * <p>Constructor to create a new user principal and its credential given56 * a username and password.</p>57 * @param username The username.58 */59publicInternalUserPrincipalImpl(String username)
60 {
61super(USER_PRINCIPAL_CLASSNAME, username);
62this.rolePrincipals = new ArrayList();
63this.groupPrincipals = new ArrayList();
64 }
6566/***67 * @see org.apache.jetspeed.security.om.InternalUserPrincipal#getCredentials()68 */69public Collection getCredentials()
70 {
71returnthis.credentials;
72 }
7374/***75 * @see org.apache.jetspeed.security.om.InternalUserPrincipal#setCredentials(java.util.Collection)76 */77publicvoid setCredentials(Collection credentials)
78 {
79this.credentials = credentials;
80 }
8182/***83 * @see org.apache.jetspeed.security.om.InternalUserPrincipal#getRolePrincipals()84 */85public Collection getRolePrincipals()
86 {
87returnthis.rolePrincipals;
88 }
8990/***91 * @see org.apache.jetspeed.security.om.InternalUserPrincipal#setRolePrincipals(java.util.Collection)92 */93publicvoid setRolePrincipals(Collection rolePrincipals)
94 {
95this.rolePrincipals = rolePrincipals;
96 }
9798/***99 * @see org.apache.jetspeed.security.om.InternalUserPrincipal#getGroupPrincipals()100 */101public Collection getGroupPrincipals()
102 {
103returnthis.groupPrincipals;
104 }
105106/***107 * @see org.apache.jetspeed.security.om.InternalUserPrincipal#setGroupPrincipals(java.util.Collection)108 */109publicvoid setGroupPrincipals(Collection groupPrincipals)
110 {
111this.groupPrincipals = groupPrincipals;
112 }
113114/***115 * <p>Compares this {@link InternalUserPrincipal} to the provided user principal116 * and check if they are equal.</p>117 * return Whether the {@link InternalUserPrincipal} are equal.118 */119publicboolean equals(Object object)
120 {
121if (!(object instanceof InternalUserPrincipal))
122return false;
123124 InternalUserPrincipal r = (InternalUserPrincipal) object;
125boolean isEqual = (r.getFullPath().equals(this.getFullPath()));
126return isEqual;
127 }
128129 }