public class X509ConsumeCallbackHandler
extends java.lang.Object
implements javax.security.auth.callback.CallbackHandler, java.io.Serializable
// generate certStore
String certpath = "intca2.cer";// The location of the X509 certificate file
X509Certificate x509cert = null;
try {
InputStream is = new FileInputStream(certpath);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
x509cert = (X509Certificate)cf.generateCertificate(is);
} catch(FileNotFoundException e1){
e1.printStackTrace();
} catch (CertificateException e2) {
e2.printStackTrace();
}
Set<Object> eeCerts = new HashSet<Object>();
eeCerts.add(x509cert);
// generate certStore
java.util.List<CertStore> certList = new java.util.ArrayList<CertStore>();
CollectionCertStoreParameters certparam = new CollectionCertStoreParameters(eeCerts);
CertStore cert = null;
try {
cert = CertStore.getInstance("Collection", certparam, "IBMCertPath");
} catch (NoSuchProviderException e1) {
e1.printStackTrace();
} catch (InvalidAlgorithmParameterException e2) {
e2.printStackTrace();
} catch (NoSuchAlgorithmException e3) {
e3.printStackTrace();
}
if(certList != null ){
certList.add(cert);
}
// generate the callback handler object
X509ConsumeCallbackHandler callbackhandler = new X509ConsumeCallbackHandler(
"dsig-receiver.ks", // keystore
"jks", // keystore type
"server".toCharArray(), // keystore password
certList, // certificate list
java.security.Security.getProvider("IBMCertPath") //provider
);
X509ConsumeCallbackHandler callbackhandler = new X509ConsumeCallbackHandler(
"", // cert list
"enc-sender.jceks", // keystore
"jceks", // keystore type
"storepass".toCharArray(), // store password
"alice", // alias
"keypass".toCharArray(), // key password
"CN=Alice, O=IBM, C=US" // subject name
);
| Constructor and Description |
|---|
X509ConsumeCallbackHandler()
Class constructor.
|
X509ConsumeCallbackHandler(java.util.Map<java.lang.Object,java.lang.Object> properties)
Class constructor.
|
X509ConsumeCallbackHandler(java.lang.String trustAnchorPath,
java.lang.String trustAnchorType,
char[] trustAnchorPassword,
java.util.List certStores,
java.security.Provider provider)
Class constructor.
|
X509ConsumeCallbackHandler(java.lang.String keyStoreRef,
java.lang.String keyStorePath,
java.lang.String keyStoreType,
char[] keyStorePassword,
java.lang.String alias,
char[] keyPassword,
java.lang.String keyName)
Class constructor.
|
X509ConsumeCallbackHandler(java.lang.String keyStoreRef,
java.lang.String keyStorePath,
java.lang.String keyStoreType,
char[] keyStorePassword,
java.lang.String alias,
char[] keyPassword,
java.lang.String keyName,
java.lang.String trustAnchorPath,
java.lang.String trustAnchorType,
char[] trustAnchorPassword,
java.util.List certStores,
java.security.Provider provider)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
handle(javax.security.auth.callback.Callback[] callbacks)
Sets necessary information to a
X509ConsumeCallback object. |
public X509ConsumeCallbackHandler(java.util.Map<java.lang.Object,java.lang.Object> properties)
properties - map including key-value pairspublic X509ConsumeCallbackHandler(java.lang.String keyStoreRef,
java.lang.String keyStorePath,
java.lang.String keyStoreType,
char[] keyStorePassword,
java.lang.String alias,
char[] keyPassword,
java.lang.String keyName,
java.lang.String trustAnchorPath,
java.lang.String trustAnchorType,
char[] trustAnchorPassword,
java.util.List certStores,
java.security.Provider provider)
keyStoreRef - reference name of the keystore used for key locatorkeyStorePath - file path from which the keystore used for key
locator is loadedkeyStorePassword - password used to check the integrity of the
keystore used for key locator or the password used to unlock the
keystorekeyStoreType - type of the keystore used for key locatoralias - alias namekeyPassword - password for recovering the keykeyName - name of the keytrustAnchorPath - file path from which the trust anchor is loadedtrustAnchorType - type of the trust anchortrustAnchorPassword - password used to check the integrity of the
trust anchor or the password used to unlock the keystorecertStores - list of certificate storesprovider - ecurity providerpublic X509ConsumeCallbackHandler(java.lang.String keyStoreRef,
java.lang.String keyStorePath,
java.lang.String keyStoreType,
char[] keyStorePassword,
java.lang.String alias,
char[] keyPassword,
java.lang.String keyName)
keyStoreRef - reference name of the keystore used for key locatorkeyStorePath - file path from which the keystore used for key
locator is loadedkeyStorePassword - password used to check the integrity of the
keystore used for key locator or the password used to unlock the
keystorekeyStoreType - type of the keystore used for key locatoralias - alias namekeyPassword - password for recovering the keykeyName - name of the keypublic X509ConsumeCallbackHandler(java.lang.String trustAnchorPath,
java.lang.String trustAnchorType,
char[] trustAnchorPassword,
java.util.List certStores,
java.security.Provider provider)
trustAnchorPath - file path from which the trust anchor is loadedtrustAnchorPassword - password used to check the integrity of the
trust anchor or the password used to unlock the keystoretrustAnchorType - type of the trust anchorpublic X509ConsumeCallbackHandler()
public void handle(javax.security.auth.callback.Callback[] callbacks)
throws java.io.IOException,
javax.security.auth.callback.UnsupportedCallbackException
X509ConsumeCallback object.handle in interface javax.security.auth.callback.CallbackHandlercallbacks - array of Callback objects provided by the
underlying security service which contains the information requested
to be retrieved or displayed.java.io.IOException - if an input or output error occurs.javax.security.auth.callback.UnsupportedCallbackException - if the implementation of this method does not support one or more
of the Callbacks specified in the callbacks parameter.CallbackHandler.handle(javax.security.auth.callback.Callback[])