Search in sources :

Example 1 with ExternalCredential

use of io.undertow.security.idm.ExternalCredential in project wildfly by wildfly.

the class ExternalLoginModule method login.

// Public methods --------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public boolean login() throws LoginException {
    if (super.login()) {
        log.debug("super.login()==true");
        return true;
    }
    // Time to see if this is a delegation request.
    NameCallback ncb = new NameCallback("Username:");
    ObjectCallback ocb = new ObjectCallback("Credential:");
    try {
        callbackHandler.handle(new Callback[] { ncb, ocb });
    } catch (Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        }
        // If the CallbackHandler can not handle the required callbacks then no chance.
        return false;
    }
    String name = ncb.getName();
    Object credential = ocb.getCredential();
    if (credential instanceof ExternalCredential) {
        identity = new SimplePrincipal(name);
        loginOk = true;
        return true;
    }
    // Attempted login but not successful.
    return false;
}
Also used : NameCallback(javax.security.auth.callback.NameCallback) ObjectCallback(org.jboss.security.auth.callback.ObjectCallback) LoginException(javax.security.auth.login.LoginException) ExternalCredential(io.undertow.security.idm.ExternalCredential) SimplePrincipal(org.jboss.security.SimplePrincipal)

Aggregations

ExternalCredential (io.undertow.security.idm.ExternalCredential)1 NameCallback (javax.security.auth.callback.NameCallback)1 LoginException (javax.security.auth.login.LoginException)1 SimplePrincipal (org.jboss.security.SimplePrincipal)1 ObjectCallback (org.jboss.security.auth.callback.ObjectCallback)1