Search in sources :

Example 96 with Role

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

the class UserAdmin method getGroup.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getGroup(java.lang.String)
 */
public CompositeData getGroup(String groupname) throws IOException {
    if (groupname == null) {
        throw new IOException("Group name cannot be null");
    }
    Role role = userAdmin.getRole(groupname);
    if (role == null) {
        return null;
    }
    validateRoleType(role, Role.GROUP);
    return new GroupData((Group) role).toCompositeData();
}
Also used : Role(org.osgi.service.useradmin.Role) Group(org.osgi.service.useradmin.Group) IOException(java.io.IOException) GroupData(org.apache.aries.jmx.codec.GroupData)

Example 97 with Role

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

the class UserAdmin method getMembers.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getMembers(java.lang.String)
 */
public String[] getMembers(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).getMembers();
        if (roles != null) {
            String[] members = new String[roles.length];
            for (int i = 0; i < roles.length; i++) {
                members[i] = roles[i].getName();
            }
            return members;
        }
    }
    return null;
}
Also used : Role(org.osgi.service.useradmin.Role) Group(org.osgi.service.useradmin.Group) IOException(java.io.IOException)

Example 98 with Role

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

the class UserAdmin method getAuthorization.

/**
 * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getAuthorization(java.lang.String)
 */
public CompositeData getAuthorization(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);
    Authorization auth = userAdmin.getAuthorization((User) role);
    if (auth == null) {
        return null;
    }
    return new AuthorizationData(auth).toCompositeData();
}
Also used : Role(org.osgi.service.useradmin.Role) Authorization(org.osgi.service.useradmin.Authorization) AuthorizationData(org.apache.aries.jmx.codec.AuthorizationData) 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