001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.security.om.impl;
018:
019: import java.util.ArrayList;
020: import java.util.Collection;
021:
022: import org.apache.jetspeed.security.om.InternalUserPrincipal;
023:
024: /**
025: * <p>{@link InternalUserPrincipal} interface implementation.</p>
026: *
027: * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
028: */
029: public class InternalUserPrincipalImpl extends InternalPrincipalImpl
030: implements InternalUserPrincipal {
031: /** The serial version uid. */
032: private static final long serialVersionUID = 6713096308414915156L;
033:
034: /** <p>User principal security class.</p> */
035: static String USER_PRINCIPAL_CLASSNAME = "org.apache.jetspeed.security.InternalUserPrincipalImpl";
036:
037: /** The credentials. */
038: private Collection credentials;
039:
040: /** The role principals. */
041: private Collection rolePrincipals;
042:
043: /** The group principals. */
044: private Collection groupPrincipals;
045:
046: /**
047: * <p>InternalUserPrincipal implementation default constructor.</p>
048: */
049: public InternalUserPrincipalImpl() {
050: super ();
051: }
052:
053: /**
054: * <p>Constructor to create a new user principal and its credential given
055: * a username and password.</p>
056: * @param username The username.
057: */
058: public InternalUserPrincipalImpl(String username) {
059: super (USER_PRINCIPAL_CLASSNAME, username);
060: this .rolePrincipals = new ArrayList();
061: this .groupPrincipals = new ArrayList();
062: }
063:
064: /**
065: * @see org.apache.jetspeed.security.om.InternalUserPrincipal#getCredentials()
066: */
067: public Collection getCredentials() {
068: return this .credentials;
069: }
070:
071: /**
072: * @see org.apache.jetspeed.security.om.InternalUserPrincipal#setCredentials(java.util.Collection)
073: */
074: public void setCredentials(Collection credentials) {
075: this .credentials = credentials;
076: }
077:
078: /**
079: * @see org.apache.jetspeed.security.om.InternalUserPrincipal#getRolePrincipals()
080: */
081: public Collection getRolePrincipals() {
082: return this .rolePrincipals;
083: }
084:
085: /**
086: * @see org.apache.jetspeed.security.om.InternalUserPrincipal#setRolePrincipals(java.util.Collection)
087: */
088: public void setRolePrincipals(Collection rolePrincipals) {
089: this .rolePrincipals = rolePrincipals;
090: }
091:
092: /**
093: * @see org.apache.jetspeed.security.om.InternalUserPrincipal#getGroupPrincipals()
094: */
095: public Collection getGroupPrincipals() {
096: return this .groupPrincipals;
097: }
098:
099: /**
100: * @see org.apache.jetspeed.security.om.InternalUserPrincipal#setGroupPrincipals(java.util.Collection)
101: */
102: public void setGroupPrincipals(Collection groupPrincipals) {
103: this .groupPrincipals = groupPrincipals;
104: }
105:
106: /**
107: * <p>Compares this {@link InternalUserPrincipal} to the provided user principal
108: * and check if they are equal.</p>
109: * return Whether the {@link InternalUserPrincipal} are equal.
110: */
111: public boolean equals(Object object) {
112: if (!(object instanceof InternalUserPrincipal))
113: return false;
114:
115: InternalUserPrincipal r = (InternalUserPrincipal) object;
116: boolean isEqual = (r.getFullPath().equals(this.getFullPath()));
117: return isEqual;
118: }
119:
120: }
|