public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; if (pc.getIdentifier().equals("smx")) { pc.setPassword("smx"); } }
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } }
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof WSPasswordCallback) { // CXF WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; if ("myclientkey".equals(pc.getIdentifier())) { pc.setPassword("ckpass"); break; } else if ("myservicekey".equals(pc.getIdentifier())) { pc.setPassword("skpass"); break; } else if ("alice".equals(pc.getIdentifier())) { pc.setPassword("security"); break; } else if ("bob".equals(pc.getIdentifier())) { pc.setPassword("security"); break; } } } }
/** * Handles {@link WSPasswordCallback} callbacks. Inspects the callback {@link * WSPasswordCallback#getUsage() usage} code, and calls the various {@code handle*} template * methods. * * @param callback the callback * @throws IOException in case of I/O errors * @throws UnsupportedCallbackException when the callback is not supported */ @Override protected final void handleInternal(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof WSPasswordCallback) { WSPasswordCallback passwordCallback = (WSPasswordCallback) callback; switch (passwordCallback.getUsage()) { case WSPasswordCallback.DECRYPT: handleDecrypt(passwordCallback); break; case WSPasswordCallback.USERNAME_TOKEN: handleUsernameToken(passwordCallback); break; case WSPasswordCallback.SIGNATURE: handleSignature(passwordCallback); break; case WSPasswordCallback.SECURITY_CONTEXT_TOKEN: handleSecurityContextToken(passwordCallback); break; case WSPasswordCallback.CUSTOM_TOKEN: handleCustomToken(passwordCallback); break; case WSPasswordCallback.SECRET_KEY: handleSecretKey(passwordCallback); break; default: throw new UnsupportedCallbackException( callback, "Unknown usage [" + passwordCallback.getUsage() + "]"); } } else if (callback instanceof CleanupCallback) { handleCleanup((CleanupCallback) callback); } else if (callback instanceof UsernameTokenPrincipalCallback) { handleUsernameTokenPrincipal((UsernameTokenPrincipalCallback) callback); } else { throw new UnsupportedCallbackException(callback); } }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; String username = pc.getIdentifier(); pc.setPassword(password); }