Search in sources :

Example 1 with SimpleGroup

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

the class ExternalLoginModule method getRoleSets.

@Override
protected Group[] getRoleSets() throws LoginException {
    Group roles = new SimpleGroup("Roles");
    Group[] groups = { roles };
    //group mapping would go here
    if (getIdentity().getName().equals("anil")) {
        roles.addMember(new SimplePrincipal("gooduser"));
    }
    roles.addMember(getIdentity());
    return groups;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 2 with SimpleGroup

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

the class AdempiereLoginModule method commit.

/**
	 * commit/complete the authentication project, add identity and roles to subject.
	 */
public boolean commit() throws LoginException {
    //note that jboss require all user role to be put under the group Roles
    if (roles == null || roles.length == 0) {
        //not authenticated or authentication failed
        subject.getPrincipals().add(new SimplePrincipal(unauthenticatedIdentity));
        SimpleGroup roleGroup = new SimpleGroup("Roles");
        subject.getPrincipals().add(roleGroup);
    } else {
        subject.getPrincipals().add(new SimplePrincipal(name));
        SimpleGroup roleGroup = new SimpleGroup("Roles");
        //fixed role use in ejb deployment descriptor
        roleGroup.addMember(new SimplePrincipal("adempiereUsers"));
        //additional security check
        for (int i = 0; i < roles.length; i++) {
            roleGroup.addMember(new SimplePrincipal(roles[i].getName()));
        }
        subject.getPrincipals().add(roleGroup);
    }
    return true;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 3 with SimpleGroup

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

the class CustomEjbAccessingLoginModule method commit.

public boolean commit() throws LoginException {
    Set<Principal> principals = subject.getPrincipals();
    Group callerPrincipal = new SimpleGroup("CallerPrincipal");
    callerPrincipal.addMember(new SimplePrincipal(username));
    principals.add(callerPrincipal);
    Group roles = new SimpleGroup("Roles");
    if (username.equals("anil")) {
        roles.addMember(new SimplePrincipal("gooduser"));
    }
    if (username.equals("marcus")) {
        roles.addMember(new SimplePrincipal("superuser"));
    }
    principals.add(roles);
    return true;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 4 with SimpleGroup

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

the class CustomTestLoginModule method commit.

@Override
public boolean commit() throws LoginException {
    Set<Principal> principals = subject.getPrincipals();
    Group callerPrincipal = new SimpleGroup("CallerPrincipal");
    callerPrincipal.addMember(new SimplePrincipal(username));
    principals.add(callerPrincipal);
    Group roles = new SimpleGroup("Roles");
    if (username.equals("anil")) {
        roles.addMember(new SimplePrincipal("gooduser"));
    }
    if (username.equals("marcus")) {
        roles.addMember(new SimplePrincipal("superuser"));
    }
    principals.add(roles);
    return true;
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) Group(java.security.acl.Group) SimpleGroup(org.jboss.security.SimpleGroup) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal) SimplePrincipal(org.jboss.security.SimplePrincipal)

Example 5 with SimpleGroup

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

the class JWTLoginModule method commit.

@Override
public boolean commit() throws LoginException {
    subject.getPrincipals().add(jwtPrincipal);
    SimpleGroup roles = new SimpleGroup("Roles");
    for (String name : jwtPrincipal.getGroups()) {
        roles.addMember(new SimplePrincipal(name));
    }
    subject.getPrincipals().add(roles);
    sharedState.put("JsonWebToken", jwtPrincipal);
    return super.commit();
}
Also used : SimpleGroup(org.jboss.security.SimpleGroup) SimplePrincipal(org.jboss.security.SimplePrincipal)

Aggregations

SimpleGroup (org.jboss.security.SimpleGroup)12 Group (java.security.acl.Group)10 SimplePrincipal (org.jboss.security.SimplePrincipal)8 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