Search in sources :

Example 1 with CertificateCallback

use of org.apache.activemq.artemis.spi.core.security.jaas.CertificateCallback in project activemq-artemis by apache.

the class TextFileCertificateLoginModuleTest method getJaasCertificateCallbackHandler.

private JaasCallbackHandler getJaasCertificateCallbackHandler(String user) {
    JMXPrincipal principal = new JMXPrincipal(user);
    X509Certificate cert = new StubX509Certificate(principal);
    return new JaasCallbackHandler(null, null, null) {

        @Override
        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (Callback callback : callbacks) {
                if (callback instanceof CertificateCallback) {
                    CertificateCallback certCallback = (CertificateCallback) callback;
                    certCallback.setCertificates(new X509Certificate[] { cert });
                } else {
                    throw new UnsupportedCallbackException(callback);
                }
            }
        }
    };
}
Also used : CertificateCallback(org.apache.activemq.artemis.spi.core.security.jaas.CertificateCallback) Callback(javax.security.auth.callback.Callback) JMXPrincipal(javax.management.remote.JMXPrincipal) CertificateCallback(org.apache.activemq.artemis.spi.core.security.jaas.CertificateCallback) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) X509Certificate(javax.security.cert.X509Certificate) JaasCallbackHandler(org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler)

Aggregations

JMXPrincipal (javax.management.remote.JMXPrincipal)1 Callback (javax.security.auth.callback.Callback)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 X509Certificate (javax.security.cert.X509Certificate)1 CertificateCallback (org.apache.activemq.artemis.spi.core.security.jaas.CertificateCallback)1 JaasCallbackHandler (org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler)1