public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
System.out.println("*** Calling Server User/Passwd Handler....");
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
System.out.println("User Id = " + pwcb.getIdentifer());
System.out.println("Password = " + pwcb.getPassword());
System.out.println("Usage = " + pwcb.getUsage());
if ( pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN ) {
if ( pwcb.getIdentifer().equals("CalculatorUser") &&
pwcb.getPassword().equals("CalculatorUserPasswd") ){
return;
} else {
throw new UnsupportedCallbackException(pwcb, "Authentication Failed : UserId - Password mismatch");
}
} else if ( pwcb.getUsage() == WSPasswordCallback.SIGNATURE ) {
if ( pwcb.getIdentifer().equals("CalculatorUser")) {
pwcb.setPassword("CalculatorUserPasswd");
} else {
pwcb.setPassword("CalculatorAdmin");
}
}
}
}