Search in sources :

Example 1 with JassCredentialCallbackHandler

use of org.apache.activemq.jaas.JassCredentialCallbackHandler in project opennms by OpenNMS.

the class OpenNMSJaasAuthenticationBroker method authenticate.

@Override
public SecurityContext authenticate(String username, String password, X509Certificate[] certificates) throws SecurityException {
    SecurityContext result = null;
    JassCredentialCallbackHandler callback = new JassCredentialCallbackHandler(username, password);
    try {
        LoginContext lc = new LoginContext(JAAS_CONTEXT_NAME, callback);
        lc.login();
        Subject subject = lc.getSubject();
        result = new JaasSecurityContext(username, subject);
    } catch (Exception ex) {
        throw new SecurityException("User name [" + username + "] or password is invalid.", ex);
    }
    return result;
}
Also used : JassCredentialCallbackHandler(org.apache.activemq.jaas.JassCredentialCallbackHandler) LoginContext(javax.security.auth.login.LoginContext) SecurityContext(org.apache.activemq.security.SecurityContext) Subject(javax.security.auth.Subject) LoginException(javax.security.auth.login.LoginException) UnknownHostException(java.net.UnknownHostException)

Aggregations

UnknownHostException (java.net.UnknownHostException)1 Subject (javax.security.auth.Subject)1 LoginContext (javax.security.auth.login.LoginContext)1 LoginException (javax.security.auth.login.LoginException)1 JassCredentialCallbackHandler (org.apache.activemq.jaas.JassCredentialCallbackHandler)1 SecurityContext (org.apache.activemq.security.SecurityContext)1