Search in sources :

Example 11 with Role

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;
}
Also used : Role(org.osgi.service.useradmin.Role) TabularDataSupport(javax.management.openmbean.TabularDataSupport) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData)

Example 12 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 13 with Role

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;
}
Also used : Role(org.osgi.service.useradmin.Role) Group(org.osgi.service.useradmin.Group) IOException(java.io.IOException)

Example 14 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)

Example 15 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)

Aggregations

Role (org.osgi.service.useradmin.Role)16 IOException (java.io.IOException)15 Group (org.osgi.service.useradmin.Group)7 User (org.osgi.service.useradmin.User)3 TabularData (javax.management.openmbean.TabularData)2 TabularDataSupport (javax.management.openmbean.TabularDataSupport)2 GroupData (org.apache.aries.jmx.codec.GroupData)2 Authorization (org.osgi.service.useradmin.Authorization)2 CompositeData (javax.management.openmbean.CompositeData)1 AuthorizationData (org.apache.aries.jmx.codec.AuthorizationData)1 UserData (org.apache.aries.jmx.codec.UserData)1 Test (org.junit.Test)1