Search in sources :

Example 1 with SubjectUserInfo

use of org.jboss.as.core.security.SubjectUserInfo 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)

Aggregations

IOException (java.io.IOException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Principal (java.security.Principal)1 Group (java.security.acl.Group)1 HashSet (java.util.HashSet)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 LoginException (javax.security.auth.login.LoginException)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 SimpleGroup (org.jboss.security.SimpleGroup)1