Search in sources :

Example 36 with Role

use of org.osgi.service.useradmin.Role in project aries by apache.

the class UserAdmin method getUser.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getUser(java.lang.String)
 */
public CompositeData getUser(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);
    return new UserData((User) role).toCompositeData();
}
Also used : Role(org.osgi.service.useradmin.Role) User(org.osgi.service.useradmin.User) UserData(org.apache.aries.jmx.codec.UserData) IOException(java.io.IOException)

Example 37 with Role

use of org.osgi.service.useradmin.Role in project aries by apache.

the class UserAdmin method removeCredential.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#removeCredential(java.lang.String, java.lang.String)
 */
public void removeCredential(String key, 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 can't find user with username = [" + username + "] doesn't exist");
    }
    validateRoleType(role, Role.USER);
    ((User) role).getCredentials().remove(key);
}
Also used : Role(org.osgi.service.useradmin.Role) IOException(java.io.IOException)

Example 38 with Role

use of org.osgi.service.useradmin.Role in project aries by apache.

the class UserAdmin method addRequiredMember.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#addRequiredMember(java.lang.String, java.lang.String)
 */
public boolean addRequiredMember(String groupname, String rolename) throws IOException {
    if (groupname == null) {
        throw new IOException("Group name cannot be null");
    }
    if (rolename == null) {
        throw new IOException("Role name cannot be null");
    }
    Role group = userAdmin.getRole(groupname);
    Role member = userAdmin.getRole(rolename);
    if (group == null) {
        throw new IOException("Operation fails role with provided groupname = [" + groupname + "] doesn't exist");
    }
    validateRoleType(group, Role.GROUP);
    return ((Group) group).addRequiredMember(member);
}
Also used : Role(org.osgi.service.useradmin.Role) Group(org.osgi.service.useradmin.Group) IOException(java.io.IOException)

Example 39 with Role

use of org.osgi.service.useradmin.Role in project aries by apache.

the class UserAdmin method addMember.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#addMember(java.lang.String, java.lang.String)
 */
public boolean addMember(String groupname, String rolename) throws IOException {
    if (groupname == null) {
        throw new IOException("Group name cannot be null");
    }
    if (rolename == null) {
        throw new IOException("Role name cannot be null");
    }
    Role group = userAdmin.getRole(groupname);
    Role member = userAdmin.getRole(rolename);
    if (group == null) {
        throw new IOException("Operation fails role with provided groupname = [" + groupname + "] doesn't exist");
    }
    validateRoleType(group, Role.GROUP);
    return ((Group) group).addMember(member);
}
Also used : Role(org.osgi.service.useradmin.Role) Group(org.osgi.service.useradmin.Group) IOException(java.io.IOException)

Example 40 with Role

use of org.osgi.service.useradmin.Role in project aries by apache.

the class UserAdmin method getImpliedRoles.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getImpliedRoles(java.lang.String)
 */
public String[] getImpliedRoles(String username) throws IOException {
    if (username == null) {
        throw new IOException("User name cannot be null");
    }
    Role role = userAdmin.getRole(username);
    if (role != null) {
        validateRoleType(role, Role.USER);
        Authorization auth = userAdmin.getAuthorization((User) role);
        if (auth != null) {
            return auth.getRoles();
        }
    }
    return null;
}
Also used : Role(org.osgi.service.useradmin.Role) Authorization(org.osgi.service.useradmin.Authorization) IOException(java.io.IOException)

Aggregations

Role (org.osgi.service.useradmin.Role)98 Group (org.osgi.service.useradmin.Group)29 IOException (java.io.IOException)17 CountDownLatch (java.util.concurrent.CountDownLatch)13 List (java.util.List)9 User (org.osgi.service.useradmin.User)9 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 Collection (java.util.Collection)5 UserAdmin (org.osgi.service.useradmin.UserAdmin)5 DBCollection (com.mongodb.DBCollection)4 Iterator (java.util.Iterator)4 BackendException (org.apache.felix.useradmin.BackendException)4 ObservableRole (org.apache.felix.useradmin.impl.role.ObservableRole)4 Authorization (org.osgi.service.useradmin.Authorization)4 WriteResult (com.mongodb.WriteResult)3 Filter (org.osgi.framework.Filter)3 BasicDBObject (com.mongodb.BasicDBObject)2 DBObject (com.mongodb.DBObject)2 Dictionary (java.util.Dictionary)2