/** * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws * an {@code UnsupportedCallbackException} for others. * * @throws UnsupportedCallbackException when the callback is not supported */ @Override protected final void handleInternal(Callback callback) throws UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { validationCallback.setValidator(new JaasPlainTextPasswordValidator()); return; } } throw new UnsupportedCallbackException(callback); }
public boolean authenticateUser( Map context, String username, String passwordDigest, String nonce, String created) throws XWSSecurityException { PasswordValidationCallback.DigestPasswordRequest request = new PasswordValidationCallback.DigestPasswordRequest( username, passwordDigest, nonce, created); PasswordValidationCallback passwordValidationCallback = new PasswordValidationCallback(request); if (!isDefaultHandler) { ProcessingContext.copy(passwordValidationCallback.getRuntimeProperties(), context); } Callback[] callbacks = new Callback[]{passwordValidationCallback}; try { callbackHandler.handle(callbacks); } catch (Exception e) { log.log(Level.SEVERE, "WSS0225.error.PasswordValidationCallback", e); throw new XWSSecurityException(e); } if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "Username Authentication done for " + username); } return passwordValidationCallback.getResult(); }
private void handlePasswordValidation(PasswordValidationCallback cb) throws IOException, UnsupportedCallbackException { if (cb.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { if (pwValidator != null) { cb.setValidator(pwValidator); } else { if (usernameAuthenticator != null) { cb.setRealmAuthentcationAdapter(usernameAuthenticator); } else { cb.setRealmAuthentcationAdapter(defRealmAuthenticator); } } } else if (cb.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { log.log(Level.SEVERE, "WSS1502.unsupported.digestAuth"); throw new UnsupportedCallbackException(null, "Digest Authentication for Passwords Not Supported"); } else { log.log(Level.SEVERE, "WSS1503.unsupported.requesttype"); throw new UnsupportedCallbackException(null, "Unsupported Request Type for Password Validation"); } }
public boolean authenticateUser(Map context, String username, String password) throws XWSSecurityException { PasswordValidationCallback.PlainTextPasswordRequest request = new PasswordValidationCallback.PlainTextPasswordRequest(username, password); PasswordValidationCallback passwordValidationCallback = new PasswordValidationCallback(request); if (!isDefaultHandler) { ProcessingContext.copy(passwordValidationCallback.getRuntimeProperties(), context); } Callback[] callbacks = new Callback[]{passwordValidationCallback}; boolean result = false; try { callbackHandler.handle(callbacks); RealmAuthenticationAdapter adapter = passwordValidationCallback.getRealmAuthenticationAdapter(); if (passwordValidationCallback.getValidator() != null) { result = passwordValidationCallback.getResult(); updateUsernameInSubject(getSubject(context), username, password); } else if (adapter != null) { result = adapter.authenticate(getSubject(context), username, password); } else { log.log(Level.SEVERE, "WSS0295.password.val.not.config.username.val"); throw new XWSSecurityException("Error: No PasswordValidator Configured for UsernameToken Validation"); } } catch (Exception e) { log.log(Level.SEVERE, "WSS0225.error.PasswordValidationCallback", e); throw new XWSSecurityException(e); } return result; }
private void handlePasswordValidationCallback(PasswordValidationCallback callback) { callback.setValidator(new PasswordValidatorChain(callback)); }
@Override public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { boolean allUnsupported = true; for (int i = 0; i < getCallbackHandlers().length; i++) { CallbackHandler callbackHandler = getCallbackHandlers()[i]; try { callbackHandler.handle(new Callback[]{callback}); allUnsupported = false; if (!callback.getResult()) { return false; } } catch (IOException e) { throw new PasswordValidationCallback.PasswordValidationException(e); } catch (UnsupportedCallbackException e) { // ignore } } return !allUnsupported; } }
private void handlePasswordValidationCallback(PasswordValidationCallback callback) { callback.setValidator(new PasswordValidatorChain(callback)); }
@Override public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { boolean allUnsupported = true; for (int i = 0; i < getCallbackHandlers().length; i++) { CallbackHandler callbackHandler = getCallbackHandlers()[i]; try { callbackHandler.handle(new Callback[]{callback}); allUnsupported = false; if (!callback.getResult()) { return false; } } catch (IOException e) { throw new PasswordValidationCallback.PasswordValidationException(e); } catch (UnsupportedCallbackException e) { // ignore } } return !allUnsupported; } }
/** * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws * an {@code UnsupportedCallbackException} for others. * * @throws UnsupportedCallbackException when the callback is not supported */ @Override protected final void handleInternal(Callback callback) throws UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { validationCallback.setValidator(new JaasPlainTextPasswordValidator()); return; } } throw new UnsupportedCallbackException(callback); }
private void handlePasswordValidationCallback(PasswordValidationCallback callback) { callback.setValidator(new PasswordValidatorChain(callback)); }
@Override public boolean validate(PasswordValidationCallback.Request request) throws PasswordValidationCallback.PasswordValidationException { boolean allUnsupported = true; for (int i = 0; i < getCallbackHandlers().length; i++) { CallbackHandler callbackHandler = getCallbackHandlers()[i]; try { callbackHandler.handle(new Callback[]{callback}); allUnsupported = false; if (!callback.getResult()) { return false; } } catch (IOException e) { throw new PasswordValidationCallback.PasswordValidationException(e); } catch (UnsupportedCallbackException e) { // ignore } } return !allUnsupported; } }
/** * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws * an {@code UnsupportedCallbackException} for others. * * @throws UnsupportedCallbackException when the callback is not supported */ @Override protected final void handleInternal(Callback callback) throws UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { validationCallback.setValidator(new JaasPlainTextPasswordValidator()); return; } } throw new UnsupportedCallbackException(callback); }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { CertificateValidationCallback validationCallback = (CertificateValidationCallback) callback; validationCallback.setValidator(new MockCertificateValidator()); } else if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; validationCallback.setValidator(new MockPasswordValidator()); } else { throw new UnsupportedCallbackException(callback); } }
/** * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws * an {@code UnsupportedCallbackException} for others. * * @throws javax.security.auth.callback.UnsupportedCallbackException * when the callback is not supported */ @Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { validationCallback.setValidator(new SpringSecurityPlainTextPasswordValidator()); return; } } else if (callback instanceof CleanupCallback) { SecurityContextHolder.clearContext(); return; } throw new UnsupportedCallbackException(callback); }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { CertificateValidationCallback validationCallback = (CertificateValidationCallback) callback; validationCallback.setValidator(new MockCertificateValidator()); } else if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; validationCallback.setValidator(new MockPasswordValidator()); } else { throw new UnsupportedCallbackException(callback); } }
/** * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws * an {@code UnsupportedCallbackException} for others. * * @throws javax.security.auth.callback.UnsupportedCallbackException * when the callback is not supported */ @Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { validationCallback.setValidator(new SpringSecurityPlainTextPasswordValidator()); return; } } else if (callback instanceof CleanupCallback) { SecurityContextHolder.clearContext(); return; } throw new UnsupportedCallbackException(callback); }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof CertificateValidationCallback) { CertificateValidationCallback validationCallback = (CertificateValidationCallback) callback; validationCallback.setValidator(new MockCertificateValidator()); } else if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; validationCallback.setValidator(new MockPasswordValidator()); } else { throw new UnsupportedCallbackException(callback); } }
/** * Handles {@code PasswordValidationCallback}s that contain a {@code PlainTextPasswordRequest}, and throws * an {@code UnsupportedCallbackException} for others. * * @throws javax.security.auth.callback.UnsupportedCallbackException * when the callback is not supported */ @Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback validationCallback = (PasswordValidationCallback) callback; if (validationCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { validationCallback.setValidator(new SpringSecurityPlainTextPasswordValidator()); return; } } else if (callback instanceof CleanupCallback) { SecurityContextHolder.clearContext(); return; } throw new UnsupportedCallbackException(callback); }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback passwordCallback = (PasswordValidationCallback) callback; if (passwordCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { passwordCallback.setValidator(new SimplePlainTextPasswordValidator()); } else if (passwordCallback.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { PasswordValidationCallback.DigestPasswordRequest digestPasswordRequest = (PasswordValidationCallback.DigestPasswordRequest) passwordCallback.getRequest(); String password = users.get(digestPasswordRequest.getUsername()); digestPasswordRequest.setPassword(password); passwordCallback.setValidator(new PasswordValidationCallback.DigestPasswordValidator()); } } else if (callback instanceof TimestampValidationCallback) { TimestampValidationCallback timestampCallback = (TimestampValidationCallback) callback; timestampCallback.setValidator(new DefaultTimestampValidator()); } else { throw new UnsupportedCallbackException(callback); } }
@Override protected void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof PasswordValidationCallback) { PasswordValidationCallback passwordCallback = (PasswordValidationCallback) callback; if (passwordCallback.getRequest() instanceof PasswordValidationCallback.PlainTextPasswordRequest) { passwordCallback.setValidator(new SimplePlainTextPasswordValidator()); } else if (passwordCallback.getRequest() instanceof PasswordValidationCallback.DigestPasswordRequest) { PasswordValidationCallback.DigestPasswordRequest digestPasswordRequest = (PasswordValidationCallback.DigestPasswordRequest) passwordCallback.getRequest(); String password = users.get(digestPasswordRequest.getUsername()); digestPasswordRequest.setPassword(password); passwordCallback.setValidator(new PasswordValidationCallback.DigestPasswordValidator()); } } else if (callback instanceof TimestampValidationCallback) { TimestampValidationCallback timestampCallback = (TimestampValidationCallback) callback; timestampCallback.setValidator(new DefaultTimestampValidator()); } else { throw new UnsupportedCallbackException(callback); } }