1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.servicehandlers;
17
18 import java.io.IOException;
19
20 import javax.security.auth.callback.Callback;
21 import javax.security.auth.callback.CallbackHandler;
22 import javax.security.auth.callback.UnsupportedCallbackException;
23 import javax.xml.namespace.QName;
24
25 import org.apache.ws.security.WSPasswordCallback;
26 import org.kuali.rice.core.api.exception.RiceRuntimeException;
27 import org.kuali.rice.ksb.service.KSBServiceLocator;
28
29
30
31
32
33
34
35 public class BasicAuthenticationHandler implements CallbackHandler {
36
37 private String serviceNameSpaceURI;
38 private QName localServiceName;
39
40
41
42
43
44
45
46 public BasicAuthenticationHandler(String serviceNameSpaceURI, QName serviceName) {
47 this.serviceNameSpaceURI = serviceNameSpaceURI;
48 this.localServiceName = serviceName;
49 }
50
51
52
53
54
55
56 public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
57 if (callbacks[0] != null && callbacks[0] instanceof WSPasswordCallback) {
58 WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
59 String password = KSBServiceLocator.getBasicAuthenticationService().getPasswordForService(this.serviceNameSpaceURI,
60 this.localServiceName, pc.getIdentifier());
61 pc.setPassword(password);
62 }
63 }
64 }