
org.ow2.bonita.identity.impl.UserImpl Maven / Gradle / Ivy
/**
* Copyright (C) 2007 Bull S. A. S.
* Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.ow2.bonita.identity.impl;
import java.security.Permission;
import java.util.Collections;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import org.ow2.bonita.identity.GroupOp;
import org.ow2.bonita.identity.Membership;
import org.ow2.bonita.identity.UserOp;
/**
* @author "Pierre Vigneras"
* @date Nov 23, 2007
*/
public class UserImpl implements UserOp {
// private static final Preferences GLOBAL_PREFERENCES =
// Preferences.userNodeForPackage(UserImpl.class);
/**
*
*/
private static final long serialVersionUID = 6946111461077651764L;
private String id;
private Set memberships;
private Properties properties;
// private Preferences preferences;
private Set permissions;
protected UserImpl() {
init();
}
/**
* @param string
* @param string2
*/
public UserImpl(final String id) {
init();
setId(id);
}
private void init() {
setMemberships(new HashSet());
setProperties(new Properties());
setPermissions(new HashSet());
}
protected void setMemberships(Set memberships) {
if (memberships == null) {
throw new IllegalArgumentException("Memberships is null!");
}
this.memberships = memberships;
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserOp#getId()
*/
public String getId() {
return id;
}
protected void setId(String id) {
if (id == null) {
throw new IllegalArgumentException("Null id!");
}
this.id = id;
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserOp#getMemberShips()
*/
public Set getMemberships() {
return Collections.unmodifiableSet(memberships);
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserOp#getPermissions()
*/
public Set getPermissions() {
return new HashSet(permissions);
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserOp#getPreferences()
*/
// public Preferences getPreferences() {
// // TODO Auto-generated method stub
// return preferences;
// }
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserOp#getProperties()
*/
public Properties getProperties() {
final Properties result = new Properties();
result.putAll(properties);
return result;
}
public void setPermissions(Set permissions) {
if (permissions == null) {
throw new IllegalArgumentException("Permissions is null!");
}
this.permissions = permissions;
}
public void setProperties(final Properties properties) {
if (properties == null) {
throw new IllegalArgumentException("Properties is null!");
}
this.properties = properties;
}
/*
* (non-Javadoc)
*
* @see
* org.ow2.bonita.identity.UserOp#isMember(org.ow2.bonita.identity.GroupOp)
*/
public boolean isMember(GroupOp groupOp) {
return memberships.contains(new MembershipImpl(this, groupOp));
}
public String toString() {
return this.getClass().getName() + "(" + getId() + ")" + "[properties: "
+ properties + "]";
}
public int hashcode() {
return id.hashCode();
}
public boolean equals(Object o) {
if (!(o instanceof UserImpl)) {
return false;
}
return id.equals(((UserImpl) o).getId());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy