Search in sources :

Example 6 with SimpleGroup

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

the class GuestDelegationLoginModule method getRoleSets.

@Override
protected Group[] getRoleSets() throws LoginException {
    Group roles = new SimpleGroup("Roles");
    Group callerPrincipal = new SimpleGroup("CallerPrincipal");
    Group[] groups = { roles, callerPrincipal };
    callerPrincipal.addMember(getIdentity());
    return groups;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup)

Example 7 with SimpleGroup

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

the class JASPICAuthenticationMechanism method updateSubjectRoles.

private void updateSubjectRoles(final org.jboss.security.SecurityContext jbossSct) {
    if (jbossSct == null) {
        throw UndertowLogger.ROOT_LOGGER.nullParamter("org.jboss.security.SecurityContext");
    }
    RoleGroup contextRoleGroup = jbossSct.getUtil().getRoles();
    if (contextRoleGroup == null) {
        return;
    }
    Collection<Role> contextRoles = contextRoleGroup.getRoles();
    if (contextRoles.isEmpty()) {
        return;
    }
    Subject subject = jbossSct.getUtil().getSubject();
    Set<Group> groupPrincipals = subject.getPrincipals(Group.class);
    Group subjectRoleGroup = null;
    for (Group candidate : groupPrincipals) {
        if (candidate.getName().equals(ROLES_IDENTIFIER)) {
            subjectRoleGroup = candidate;
            break;
        }
    }
    if (subjectRoleGroup == null) {
        subjectRoleGroup = new SimpleGroup(ROLES_IDENTIFIER);
        subject.getPrincipals().add(subjectRoleGroup);
    }
    for (Role role : contextRoles) {
        Principal rolePrincipal = new SimplePrincipal(role.getRoleName());
        subjectRoleGroup.addMember(rolePrincipal);
    }
}
Also used : SimpleRole(org.jboss.security.identity.plugins.SimpleRole) Role(org.jboss.security.identity.Role) SimpleGroup(org.jboss.security.SimpleGroup) RoleGroup(org.jboss.security.identity.RoleGroup) SimpleRoleGroup(org.jboss.security.identity.plugins.SimpleRoleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) Subject(javax.security.auth.Subject) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal) SimplePrincipal(org.jboss.security.SimplePrincipal) RoleGroup(org.jboss.security.identity.RoleGroup) SimpleRoleGroup(org.jboss.security.identity.plugins.SimpleRoleGroup)

Example 8 with SimpleGroup

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

the class RealmDirectLoginModule method getRoleSets.

@Override
protected Group[] getRoleSets() throws LoginException {
    Collection<Principal> principalCol = new HashSet<Principal>();
    principalCol.add(new RealmUser(getUsername()));
    try {
        AuthorizingCallbackHandler callbackHandler = getCallbackHandler();
        SubjectUserInfo sui = callbackHandler.createSubjectUserInfo(principalCol);
        SimpleGroup sg = new SimpleGroup("Roles");
        Set<RealmRole> roles = sui.getSubject().getPrincipals(RealmRole.class);
        for (RealmRole current : roles) {
            sg.addMember(createIdentity(current.getName()));
        }
        return new Group[] { sg };
    } catch (Exception e) {
        throw SecurityLogger.ROOT_LOGGER.failureCallingSecurityRealm(e.getMessage());
    }
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) RealmRole(org.jboss.as.core.security.RealmRole) RealmUser(org.jboss.as.core.security.RealmUser) SimpleGroup(org.jboss.security.SimpleGroup) AuthorizingCallbackHandler(org.jboss.as.domain.management.AuthorizingCallbackHandler) SubjectUserInfo(org.jboss.as.core.security.SubjectUserInfo) Principal(java.security.Principal) LoginException(javax.security.auth.login.LoginException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) HashSet(java.util.HashSet)

Example 9 with SimpleGroup

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

the class RemotingLoginModule method getRoleSets.

@Override
protected Group[] getRoleSets() throws LoginException {
    Group roles = new SimpleGroup("Roles");
    Group callerPrincipal = new SimpleGroup("CallerPrincipal");
    Group[] groups = { roles, callerPrincipal };
    callerPrincipal.addMember(getIdentity());
    return groups;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup)

Example 10 with SimpleGroup

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

the class AddRoleLoginModule method getRoleSets.

@Override
protected Group[] getRoleSets() throws LoginException {
    Group roles = new SimpleGroup(SecurityConstants.ROLES_IDENTIFIER);
    roles.addMember(new SimplePrincipal(role));
    return new Group[] { roles };
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) SimplePrincipal(org.jboss.security.SimplePrincipal)

Aggregations

SimpleGroup (org.jboss.security.SimpleGroup)10 Group (java.security.acl.Group)9 SimplePrincipal (org.jboss.security.SimplePrincipal)7 Principal (java.security.Principal)4 LoginException (javax.security.auth.login.LoginException)2 IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HashSet (java.util.HashSet)1 Subject (javax.security.auth.Subject)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 Role (org.jboss.security.identity.Role)1 RoleGroup (org.jboss.security.identity.RoleGroup)1 SimpleRole (org.jboss.security.identity.plugins.SimpleRole)1 SimpleRoleGroup (org.jboss.security.identity.plugins.SimpleRoleGroup)1