public X509Certificate getCertificate(Map context, String alias, boolean forSigning)
throws XWSSecurityException {
X509Certificate cert = null;
try {
PrivateKeyCallback pkCallback = null;
if (forSigning) {
try {
Subject subject = getSubject(context);
if (subject != null) {
Set set = subject.getPrivateCredentials(X500PrivateCredential.class);
if (set != null) {
Iterator it = set.iterator();
while (it.hasNext()) {
X500PrivateCredential cred = (X500PrivateCredential)it.next();
if (cred.getAlias().equals(alias))
return cred.getCertificate();
}
}
}
PrivateKeyCallback.Request request = new PrivateKeyCallback.AliasRequest(alias);
pkCallback = new PrivateKeyCallback(request);
Callback[] callbacks = new Callback[] { pkCallback };
_handler.handle(callbacks);
} catch (Exception e) {
throw new XWSSecurityException(e);
}
Certificate[] chain = pkCallback.getChain();
if (chain != null)
cert = (X509Certificate)chain[0];
else
;//log
} else {