Search in sources :

Example 1 with AuthorizingCallbackHandler

use of org.jboss.as.domain.management.AuthorizingCallbackHandler in project wildfly by wildfly.

the class RealmDirectLoginModule method handle.

private void handle(final Callback[] callbacks) throws LoginException {
    try {
        AuthorizingCallbackHandler callbackHandler = getCallbackHandler();
        callbackHandler.handle(callbacks);
    } catch (IOException e) {
        throw SecurityLogger.ROOT_LOGGER.failureCallingSecurityRealm(e.getMessage());
    } catch (UnsupportedCallbackException e) {
        throw SecurityLogger.ROOT_LOGGER.failureCallingSecurityRealm(e.getMessage());
    }
}
Also used : AuthorizingCallbackHandler(org.jboss.as.domain.management.AuthorizingCallbackHandler) IOException(java.io.IOException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException)

Example 2 with AuthorizingCallbackHandler

use of org.jboss.as.domain.management.AuthorizingCallbackHandler 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)2 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)2 AuthorizingCallbackHandler (org.jboss.as.domain.management.AuthorizingCallbackHandler)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Principal (java.security.Principal)1 Group (java.security.acl.Group)1 HashSet (java.util.HashSet)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 SimpleGroup (org.jboss.security.SimpleGroup)1