use of org.osgi.service.useradmin.Role in project aries by apache.
the class UserAdmin method addRoleProperty.
/**
* @see UserAdminMBean#addProperty(String, byte[], String)
* @see UserAdminMBean#addProperty(String, String, String)
*/
private void addRoleProperty(String key, Object value, String rolename) throws IOException {
if (rolename == null) {
throw new IOException("Role name cannot be null");
}
if (key == null) {
throw new IOException("Property key cannot be null");
}
Role role = userAdmin.getRole(rolename);
if (role == null) {
throw new IOException("Operation fails role with provided rolename = [" + rolename + "] doesn't exist");
}
Dictionary<String, Object> properties = role.getProperties();
if (properties != null) {
properties.put(key, value);
}
}
use of org.osgi.service.useradmin.Role in project aries by apache.
the class UserAdmin method getCredentials.
/**
* @see org.osgi.jmx.service.useradmin.UserAdminMBean#getCredentials(java.lang.String)
*/
public TabularData getCredentials(String username) throws IOException {
if (username == null) {
throw new IOException("User name cannot be null");
}
Role role = userAdmin.getRole(username);
if (role == null) {
return null;
}
validateRoleType(role, Role.USER);
Dictionary<String, Object> credentials = ((User) role).getCredentials();
if (credentials == null) {
return null;
}
TabularData data = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE);
for (Enumeration<String> keys = credentials.keys(); keys.hasMoreElements(); ) {
String key = keys.nextElement();
data.put(PropertyData.newInstance(key, credentials.get(key)).toCompositeData());
}
return data;
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class RoleRepositoryMemoryStore method getRoles.
public Role[] getRoles(String filterValue) throws InvalidSyntaxException {
Collection roles = m_entries.values();
Filter filter = null;
if (filterValue != null) {
filter = FrameworkUtil.createFilter(filterValue);
}
List matchingRoles = new ArrayList();
Iterator rolesIter = roles.iterator();
while (rolesIter.hasNext()) {
Role role = (Role) rolesIter.next();
if ((filter == null) || filter.match(role.getProperties())) {
matchingRoles.add(role);
}
}
Role[] result = new Role[matchingRoles.size()];
return (Role[]) matchingRoles.toArray(result);
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class RoleRepositoryMemoryStore method removeRole.
public Role removeRole(String roleName) {
if (roleName == null) {
throw new IllegalArgumentException("Name cannot be null!");
}
Role role = getRoleByName(roleName);
boolean result = m_entries.remove(roleName, role);
return result ? role : null;
}
use of org.osgi.service.useradmin.Role in project felix by apache.
the class RoleRepositorySerializer method readRole.
/**
* Reads a role from the given input stream.
*
* @param dis the input stream to read the data from, cannot be <code>null</code>.
* @return the read role, never <code>null</code>.
* @throws IOException in case of I/O problems.
*/
private Role readRole(DataInputStream dis) throws IOException {
Role role = RoleFactory.createRole(Role.ROLE, dis.readUTF());
readDictionary(role.getProperties(), dis);
return role;
}
Aggregations