Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public X509Certificate getCertificate(Map context, String alias, boolean forSigning) throws XWSSecurityException {
- X509Certificate cert = null;
- if (alias != null && (!"".equals(alias) || !forSigning)) {
- Callback[] callbacks;
- if (forSigning) {
- PrivKeyCertRequest certRequest = new AliasPrivKeyCertRequest(alias);
- SignatureKeyCallback sigKeyCallback = new SignatureKeyCallback(certRequest);
- ProcessingContext.copy(sigKeyCallback.getRuntimeProperties(), context);
- callbacks = new Callback[]{sigKeyCallback};
- try {
- this.callbackHandler.handle(callbacks);
- } catch (Exception var10) {
- log.log(Level.SEVERE, "WSS0216.callbackhandler.handle.exception", new Object[]{"SignatureKeyCallback.AliasPrivKeyCertRequest"});
- log.log(Level.SEVERE, "WSS0217.callbackhandler.handle.exception.log", var10);
- throw new XWSSecurityException(var10);
- }
- cert = certRequest.getX509Certificate();
- } else {
- X509CertificateRequest certRequest = new AliasX509CertificateRequest(alias);
- EncryptionKeyCallback encKeyCallback = new EncryptionKeyCallback(certRequest);
- ProcessingContext.copy(encKeyCallback.getRuntimeProperties(), context);
- callbacks = new Callback[]{encKeyCallback};
- try {
- this.callbackHandler.handle(callbacks);
- } catch (Exception var9) {
- log.log(Level.SEVERE, "WSS0216.callbackhandler.handle.exception", new Object[]{"EncryptionKeyCallback.AliasX509CertificateRequest"});
- log.log(Level.SEVERE, "WSS0217.callbackhandler.handle.exception.log", var9);
- throw new XWSSecurityException(var9);
- }
- cert = certRequest.getX509Certificate();
- }
- if (cert == null) {
- String val = forSigning ? "Signature" : "Key Encryption";
- log.log(Level.SEVERE, "WSS0221.cannot.locate.cert", new Object[]{val});
- throw new XWSSecurityException("Unable to locate certificate for the alias '" + alias + "'");
- } else {
- return cert;
- }
- } else {
- return this.getDefaultCertificate(context);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement