THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
The password callback class allows you to retrieve to retrieve the password for a given user so that WS-Security can determine if they're authorized. Here is a small example:
Code Block | ||||
---|---|---|---|---|
| ||||
import java.io.IOException; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.UnsupportedCallbackException; import org.apache.ws.security.WSPasswordCallback; public class ServerPasswordCallback implements CallbackHandler { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; if (pc.getIdgetIdentity().equals("joe") { // set the password on the callback. This will be compared to the // password which was sent from the client. pc.setPassword("password"); } } } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
public class ServerPasswordCallback implements CallbackHandler { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; if (pc.getIdgetIdentity().equals("joe") { if (!pc.getPassword().equals("password")) { throw new SecurityException("wrong password"); } } } } |
...