public boolean getResult() { try { if (validator != null) result = validator.validate(request); } catch (Exception e) { return false; } return result; }
private void handleTimestampValidation(TimestampValidationCallback cb) throws IOException, UnsupportedCallbackException { if (tsValidator != null) { cb.setValidator(tsValidator); } else { // this is for BC reasons, but will be enabled later cb.setValidator(defaultTSValidator); } }
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for(int i=0;i<callbacks.length;i++) { if(callbacks[i] instanceof UsernameCallback) { UsernameCallback cb = (UsernameCallback)callbacks[i]; cb.setUsername(login); } else if(callbacks[i] instanceof PasswordCallback) { PasswordCallback cb = (PasswordCallback)callbacks[i]; cb.setPassword(password); } else if(callbacks[i] instanceof com.sun.xml.wss.impl.callback.TimestampValidationCallback) { com.sun.xml.wss.impl.callback.TimestampValidationCallback timecb = (com.sun.xml.wss.impl.callback.TimestampValidationCallback)callbacks[i]; timecb.setValidator(this); } } }
@Override public void validate(TimestampValidationCallback.Request request) throws TimestampValidationCallback.TimestampValidationException { if (request instanceof TimestampValidationCallback.UTCTimestampRequest) { TimestampValidationCallback.UTCTimestampRequest utcRequest = (TimestampValidationCallback.UTCTimestampRequest) request; Date created = parseDate(utcRequest.getCreated()); validateCreationTime(created, utcRequest.getMaxClockSkew(), utcRequest.getTimestampFreshnessLimit()); if (utcRequest.getExpired() != null) { Date expired = parseDate(utcRequest.getExpired()); validateExpirationTime(expired, utcRequest.getMaxClockSkew()); } } else { throw new TimestampValidationCallback.TimestampValidationException("Unsupport request: [" + request + "]"); } }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof UsernameCallback) { UsernameCallback usernameCallback = (UsernameCallback) callback; usernameCallback.setUsername(username); } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(password); } else { throw new UnsupportedCallbackException(callback); } } }
@Override protected final void handleX509IssuerSerialBasedRequest(DecryptionKeyCallback callback, DecryptionKeyCallback.X509IssuerSerialBasedRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getIssuerName(), request.getSerialNumber()); request.setPrivateKey(key); }
@Override protected final void handleX509IssuerSerialBasedRequest(SignatureVerificationKeyCallback callback, SignatureVerificationKeyCallback.X509IssuerSerialBasedRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getIssuerName(), request.getSerialNumber()); request.setX509Certificate(certificate); }
@Override protected final void handleX509CertificateBasedRequest(DecryptionKeyCallback callback, DecryptionKeyCallback.X509CertificateBasedRequest request) throws IOException { PrivateKey privKey = getPrivateKey(request.getX509Certificate()); request.setPrivateKey(privKey); }
@Override protected final void handleX509SubjectKeyIdentifierBasedRequest(DecryptionKeyCallback callback, DecryptionKeyCallback.X509SubjectKeyIdentifierBasedRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getSubjectKeyIdentifier()); request.setPrivateKey(key); }
@Override protected final void handlePublicKeyBasedPrivKeyRequest(DecryptionKeyCallback callback, DecryptionKeyCallback.PublicKeyBasedPrivKeyRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getPublicKey()); request.setPrivateKey(key); }
@Override protected final void handleX509SubjectKeyIdentifierBasedRequest(SignatureVerificationKeyCallback callback, SignatureVerificationKeyCallback.X509SubjectKeyIdentifierBasedRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(request.getSubjectKeyIdentifier()); request.setX509Certificate(certificate); }
@Override protected final void handleDefaultPrivKeyCertRequest(SignatureKeyCallback callback, SignatureKeyCallback.DefaultPrivKeyCertRequest request) throws IOException { PrivateKey privateKey = getPrivateKey(defaultAlias); X509Certificate certificate = getCertificate(defaultAlias); request.setPrivateKey(privateKey); request.setX509Certificate(certificate); }
@Override protected final void handleAliasSymmetricKeyRequest(DecryptionKeyCallback callback, DecryptionKeyCallback.AliasSymmetricKeyRequest request) throws IOException { SecretKey secretKey = getSymmetricKey(request.getAlias()); request.setSymmetricKey(secretKey); }
@Override protected final void handleAliasSymmetricKeyRequest(EncryptionKeyCallback callback, EncryptionKeyCallback.AliasSymmetricKeyRequest request) throws IOException { SecretKey secretKey = getSymmetricKey(request.getAlias()); request.setSymmetricKey(secretKey); }
public boolean getResult() { try { if (validator != null) result = validator.validate(certificate); } catch (CertificateValidationCallback.CertificateValidationException ex) { throw SOAPUtil.newSOAPFaultException(MessageConstants.WSSE_INVALID_SECURITY_TOKEN, ex.getMessage(), ex); } catch (Exception e) { throw SOAPUtil.newSOAPFaultException(MessageConstants.WSSE_INVALID_SECURITY_TOKEN, e.getMessage(), e); } return result; }
@Override protected final void handleDefaultX509CertificateRequest(EncryptionKeyCallback callback, EncryptionKeyCallback.DefaultX509CertificateRequest request) throws IOException { X509Certificate certificate = getCertificateFromTrustStore(defaultAlias); request.setX509Certificate(certificate); }
public void getResult() throws TimestampValidationException { validator.validate(request); }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof UsernameCallback) { UsernameCallback usernameCallback = (UsernameCallback) callback; usernameCallback.setUsername(username); } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(password); } else { throw new UnsupportedCallbackException(callback); } } }
@Override protected final void handleX509IssuerSerialBasedRequest(DecryptionKeyCallback callback, DecryptionKeyCallback.X509IssuerSerialBasedRequest request) throws IOException { PrivateKey key = getPrivateKey(request.getIssuerName(), request.getSerialNumber()); request.setPrivateKey(key); }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof UsernameCallback) { UsernameCallback usernameCallback = (UsernameCallback) callback; usernameCallback.setUsername(username); } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(password); } else { throw new UnsupportedCallbackException(callback); } } }