Search in sources :

Example 16 with GroupPrincipal

use of org.apache.karaf.jaas.boot.principal.GroupPrincipal in project fabric8 by jboss-fuse.

the class ZookeeperBackingEngine method addRole.

/**
 * Add a role to a User.
 */
public void addRole(String username, String role) {
    String userInfos = users.get(username);
    if (userInfos != null) {
        for (RolePrincipal rp : listRoles(username)) {
            if (role.equals(rp.getName())) {
                return;
            }
        }
        for (GroupPrincipal gp : listGroups(username)) {
            if (role.equals(GROUP_PREFIX + gp.getName())) {
                return;
            }
        }
        String newUserInfos = userInfos + "," + role;
        users.put(username, newUserInfos);
    }
    saveUserProperties();
}
Also used : GroupPrincipal(org.apache.karaf.jaas.boot.principal.GroupPrincipal) RolePrincipal(org.apache.karaf.jaas.boot.principal.RolePrincipal)

Aggregations

GroupPrincipal (org.apache.karaf.jaas.boot.principal.GroupPrincipal)16 UserPrincipal (org.apache.karaf.jaas.boot.principal.UserPrincipal)10 RolePrincipal (org.apache.karaf.jaas.boot.principal.RolePrincipal)9 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 LoginException (javax.security.auth.login.LoginException)4 Properties (org.apache.felix.utils.properties.Properties)4 File (java.io.File)3 Callback (javax.security.auth.callback.Callback)3 NameCallback (javax.security.auth.callback.NameCallback)3 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)3 FailedLoginException (javax.security.auth.login.FailedLoginException)3 Test (org.junit.Test)3 PasswordCallback (javax.security.auth.callback.PasswordCallback)2 Field (java.lang.reflect.Field)1 PublicKey (java.security.PublicKey)1 DSAPublicKey (java.security.interfaces.DSAPublicKey)1 RSAPublicKey (java.security.interfaces.RSAPublicKey)1 Connection (java.sql.Connection)1 Subject (javax.security.auth.Subject)1