Search in sources :

Example 21 with SimpleGroup

use of org.jboss.security.SimpleGroup in project teiid by teiid.

the class SimpleLoginModule method getRoleSets.

@Override
protected Group[] getRoleSets() throws LoginException {
    // $NON-NLS-1$
    SimpleGroup roles = new SimpleGroup("Roles");
    Group[] roleSets = { roles };
    return roleSets;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup)

Example 22 with SimpleGroup

use of org.jboss.security.SimpleGroup in project keycloak by keycloak.

the class JBossWebPrincipalFactory method createGroup.

protected Group createGroup(String name, Set<Principal> principals) {
    Group roles = null;
    Iterator<Principal> iter = principals.iterator();
    while (iter.hasNext()) {
        Object next = iter.next();
        if (!(next instanceof Group))
            continue;
        Group grp = (Group) next;
        if (grp.getName().equals(name)) {
            roles = grp;
            break;
        }
    }
    // If we did not find a group create one
    if (roles == null) {
        roles = new SimpleGroup(name);
        principals.add(roles);
    }
    return roles;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) NestableGroup(org.jboss.security.NestableGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) JBossGenericPrincipal(org.jboss.as.web.security.JBossGenericPrincipal) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 23 with SimpleGroup

use of org.jboss.security.SimpleGroup in project keycloak by keycloak.

the class WildflyRequestAuthenticator method createGroup.

protected Group createGroup(String name, Set<Principal> principals) {
    Group roles = null;
    Iterator<Principal> iter = principals.iterator();
    while (iter.hasNext()) {
        Object next = iter.next();
        if (!(next instanceof Group))
            continue;
        Group grp = (Group) next;
        if (grp.getName().equals(name)) {
            roles = grp;
            break;
        }
    }
    // If we did not find a group create one
    if (roles == null) {
        roles = new SimpleGroup(name);
        principals.add(roles);
    }
    return roles;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) RoleGroup(org.jboss.security.identity.RoleGroup) NestableGroup(org.jboss.security.NestableGroup) Group(java.security.acl.Group) SimpleRoleGroup(org.jboss.security.identity.plugins.SimpleRoleGroup) SimpleGroup(org.jboss.security.SimpleGroup) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 24 with SimpleGroup

use of org.jboss.security.SimpleGroup in project keycloak by keycloak.

the class SecurityInfoHelper method propagateSessionInfo.

public static void propagateSessionInfo(KeycloakAccount account) {
    Subject subject = new Subject();
    Set<Principal> principals = subject.getPrincipals();
    principals.add(account.getPrincipal());
    Group[] roleSets = getRoleSets(account.getRoles());
    for (int g = 0; g < roleSets.length; g++) {
        Group group = roleSets[g];
        String name = group.getName();
        Group subjectGroup = createGroup(name, principals);
        if (subjectGroup instanceof NestableGroup) {
            /* A NestableGroup only allows Groups to be added to it so we
                need to add a SimpleGroup to subjectRoles to contain the roles
                */
            SimpleGroup tmp = new SimpleGroup("Roles");
            subjectGroup.addMember(tmp);
            subjectGroup = tmp;
        }
        // Copy the group members to the Subject group
        Enumeration<? extends Principal> members = group.members();
        while (members.hasMoreElements()) {
            Principal role = (Principal) members.nextElement();
            subjectGroup.addMember(role);
        }
    }
    // add the CallerPrincipal group if none has been added in getRoleSets
    Group callerGroup = new SimpleGroup(SecurityConstants.CALLER_PRINCIPAL_GROUP);
    callerGroup.addMember(account.getPrincipal());
    principals.add(callerGroup);
    org.jboss.security.SecurityContext sc = SecurityContextAssociation.getSecurityContext();
    Principal userPrincipal = getPrincipal(subject);
    sc.getUtil().createSubjectInfo(userPrincipal, account, subject);
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) NestableGroup(org.jboss.security.NestableGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) Subject(javax.security.auth.Subject) NestableGroup(org.jboss.security.NestableGroup) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 25 with SimpleGroup

use of org.jboss.security.SimpleGroup in project keycloak by keycloak.

the class SecurityInfoHelper method propagateSessionInfo.

public static void propagateSessionInfo(KeycloakAccount account) {
    Subject subject = new Subject();
    Set<Principal> principals = subject.getPrincipals();
    principals.add(account.getPrincipal());
    Group[] roleSets = getRoleSets(account.getRoles());
    for (int g = 0; g < roleSets.length; g++) {
        Group group = roleSets[g];
        String name = group.getName();
        Group subjectGroup = createGroup(name, principals);
        if (subjectGroup instanceof NestableGroup) {
            /* A NestableGroup only allows Groups to be added to it so we
                need to add a SimpleGroup to subjectRoles to contain the roles
                */
            SimpleGroup tmp = new SimpleGroup("Roles");
            subjectGroup.addMember(tmp);
            subjectGroup = tmp;
        }
        // Copy the group members to the Subject group
        Enumeration<? extends Principal> members = group.members();
        while (members.hasMoreElements()) {
            Principal role = (Principal) members.nextElement();
            subjectGroup.addMember(role);
        }
    }
    // add the CallerPrincipal group if none has been added in getRoleSets
    Group callerGroup = new SimpleGroup(SecurityConstants.CALLER_PRINCIPAL_GROUP);
    callerGroup.addMember(account.getPrincipal());
    principals.add(callerGroup);
    org.jboss.security.SecurityContext sc = SecurityContextAssociation.getSecurityContext();
    Principal userPrincipal = getPrincipal(subject);
    sc.getUtil().createSubjectInfo(userPrincipal, account, subject);
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) NestableGroup(org.jboss.security.NestableGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) Subject(javax.security.auth.Subject) NestableGroup(org.jboss.security.NestableGroup) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal)

Aggregations

SimpleGroup (org.jboss.security.SimpleGroup)25 Group (java.security.acl.Group)22 SimplePrincipal (org.jboss.security.SimplePrincipal)21 Principal (java.security.Principal)12 NestableGroup (org.jboss.security.NestableGroup)12 Subject (javax.security.auth.Subject)5 RoleGroup (org.jboss.security.identity.RoleGroup)4 SimpleRoleGroup (org.jboss.security.identity.plugins.SimpleRoleGroup)4 LoginException (javax.security.auth.login.LoginException)2 GenericPrincipal (org.apache.catalina.realm.GenericPrincipal)2 JBossGenericPrincipal (org.jboss.as.web.security.JBossGenericPrincipal)2 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 RealmRole (org.jboss.as.core.security.RealmRole)1 RealmUser (org.jboss.as.core.security.RealmUser)1 SubjectUserInfo (org.jboss.as.core.security.SubjectUserInfo)1 AuthorizingCallbackHandler (org.jboss.as.domain.management.AuthorizingCallbackHandler)1