class SimplePasswordValidationCallbackHandler extends AbstractCallbackHandler implements InitializingBean {

	@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);
		}
	}

}