You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@cxf.apache.org by cxfuser cxf <cx...@yahoo.com> on 2014/06/24 18:36:18 UTC

Help with the CallbackHandler

Hi All,
Below is the client i created that sends the password through the following callbackhandler. I am trying to catch the exception with invalid username/password as a response from the server. This comes back as a xml object with the description saying invalid credentials. Can someone tell me how to handle this xml response from the server on the client side? My pssword is in  PasswordText format.

public class PasswordClient implements CallbackHandler {
    private String password;
    private username;
  
    public void setPassword(String password) {
    this.password = password;
    }

    public void handle(Callback[] callbacks) throws IOException  
    {
        
    WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
    if (pc.getIdentifier().equals(this.username)) {
        pc.setPassword(this.password);
        }
    else{
        throw new IOException("Invalid Identifier");
    }
    }
}