use of org.osgi.service.useradmin.Role in project felix by apache.
the class UserManager method getProperties.
public Hashtable getProperties(String rolename) {
try {
Role role = ac.getUserAdmin().getRole(rolename);
Dictionary dic = role.getProperties();
Hashtable props = new Hashtable();
Enumeration keys = dic.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
props.put(key, dic.get(key));
}
return props;
} catch (NullPointerException npe) {
ac.debug("UserAdmin not available. ");
return null;
}
}
use of org.osgi.service.useradmin.Role in project aries by apache.
the class UserAdmin method addCredential.
private void addCredential(String key, Object value, String username) throws IOException {
if (username == null) {
throw new IOException("User name cannot be null");
}
if (key == null) {
throw new IOException("Credential key cannot be null");
}
Role role = userAdmin.getRole(username);
if (role == null) {
throw new IOException("Operation fails user with provided username = [" + username + "] doesn't exist");
}
validateRoleType(role, Role.USER);
Dictionary<String, Object> credentials = ((User) role).getCredentials();
if (credentials != null) {
credentials.put(key, value);
}
}
use of org.osgi.service.useradmin.Role in project aries by apache.
the class UserAdmin method removeProperty.
/**
* @see org.osgi.jmx.service.useradmin.UserAdminMBean#removeProperty(java.lang.String, java.lang.String)
*/
public void removeProperty(String key, String rolename) throws IOException {
if (rolename == null) {
throw new IOException("Role name cannot be null");
}
Role role = userAdmin.getRole(rolename);
if (role == null) {
throw new IOException("Operation fails role with provided rolename = [" + rolename + "] doesn't exist");
}
role.getProperties().remove(key);
}
use of org.osgi.service.useradmin.Role in project aries by apache.
the class UserAdmin method getRequiredMembers.
/**
* @see org.osgi.jmx.service.useradmin.UserAdminMBean#getRequiredMembers(java.lang.String)
*/
public String[] getRequiredMembers(String groupname) throws IOException {
if (groupname == null) {
throw new IOException("Group name cannot be null");
}
Role role = userAdmin.getRole(groupname);
if (role != null) {
validateRoleType(role, Role.GROUP);
Role[] roles = ((Group) role).getRequiredMembers();
if (roles != null) {
String[] reqMembers = new String[roles.length];
for (int i = 0; i < roles.length; i++) {
reqMembers[i] = roles[i].getName();
}
return reqMembers;
}
}
return null;
}
use of org.osgi.service.useradmin.Role in project aries by apache.
the class UserAdmin method getProperties.
/**
* @see org.osgi.jmx.service.useradmin.UserAdminMBean#getProperties(java.lang.String)
*/
public TabularData getProperties(String rolename) throws IOException {
if (rolename == null) {
throw new IOException("Role name cannot be null");
}
Role role = userAdmin.getRole(rolename);
if (role == null) {
return null;
}
Dictionary<String, Object> properties = role.getProperties();
if (properties == null) {
return null;
}
TabularData data = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE);
for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements(); ) {
String key = keys.nextElement();
data.put(PropertyData.newInstance(key, properties.get(key)).toCompositeData());
}
return data;
}
Aggregations