public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
&& "alice".equals(pc.getIdentifier())) {
pc.setPassword("verySecret");
} else if (pc.getUsage() == WSPasswordCallback.SIGNATURE
&& "wss40".equals(pc.getIdentifier())) {
pc.setPassword("security");
} else {
throw new IOException("Authentication failed");
}
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");