View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.cxf.wssec;
8   
9   import java.io.IOException;
10  
11  import javax.security.auth.callback.Callback;
12  import javax.security.auth.callback.CallbackHandler;
13  import javax.security.auth.callback.UnsupportedCallbackException;
14  
15  import org.apache.ws.security.WSPasswordCallback;
16  
17  /**
18   * Trivial security which simply returns the password for user "joe".
19   */
20  public class ServerPasswordCallback implements CallbackHandler
21  {
22      public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
23  
24          WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
25  
26          if (pc.getIdentifier().equals("joe")) 
27          {
28              // set the password on the callback. This will be compared to the
29              // password which was sent from the client.
30              pc.setPassword("secret");
31          }
32      }
33  }
34  
35  
36