1 18 19 package org.apache.activemq.jaas; 20 21 22 import javax.security.auth.callback.Callback ; 23 import javax.security.auth.callback.CallbackHandler ; 24 import javax.security.auth.callback.NameCallback ; 25 import javax.security.auth.callback.PasswordCallback ; 26 import javax.security.auth.callback.UnsupportedCallbackException ; 27 28 import java.io.IOException ; 29 import java.security.cert.X509Certificate ; 30 31 39 public class JaasCertificateCallbackHandler implements CallbackHandler { 40 final X509Certificate certificates[]; 41 42 47 public JaasCertificateCallbackHandler(X509Certificate certs[]) { 48 certificates = certs; 49 } 50 51 58 public void handle(Callback [] callbacks) throws IOException , UnsupportedCallbackException { 59 for (int i = 0; i < callbacks.length; i++) { 60 Callback callback = callbacks[i]; 61 if (callback instanceof CertificateCallback) { 62 CertificateCallback certCallback = (CertificateCallback) callback; 63 64 certCallback.setCertificates(certificates); 65 66 } else { 67 throw new UnsupportedCallbackException (callback); 68 } 69 } 70 } 71 } 72 | Popular Tags |