
org.ow2.bonita.identity.User 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;
import java.security.Permission;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
/**
* @author "Pierre Vigneras"
* @date Dec 6, 2007
*/
public class User implements UserMBean {
private final UserOp user;
private final IdentityServiceOp service;
User(final UserOp user, final IdentityServiceOp service) {
this.user = user;
this.service = service;
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserMBean#getGroups()
*/
public Set getGroups() {
final Set memberships = user.getMemberships();
final Set groupsId = new HashSet();
for (Membership m : memberships) {
groupsId.add(m.getGroup().getId());
}
return groupsId;
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserMBean#getId()
*/
public String getId() {
return user.getId();
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserMBean#getPermissions()
*/
public Set getPermissions() {
return user.getPermissions();
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserMBean#getProperties()
*/
public Properties getProperties() {
return user.getProperties();
}
/*
* (non-Javadoc)
*
* @see org.ow2.bonita.identity.UserMBean#setProperty(java.lang.String,
* java.lang.String)
*/
public void setProperty(String key, String value) throws CommitException {
final Properties properties = user.getProperties();
properties.setProperty(key, value);
user.setProperties(properties);
try {
service.modifyUser(user);
} catch (UserNotFoundException unfe) {
throw new RuntimeException(unfe);
}
service.commit();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy