1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.ksb.config.wss4j; |
18 | |
|
19 | |
import org.apache.ws.security.WSPasswordCallback; |
20 | |
import org.kuali.rice.core.api.config.ConfigurationException; |
21 | |
import org.kuali.rice.core.api.config.property.Config; |
22 | |
import org.kuali.rice.core.api.config.property.ConfigContext; |
23 | |
|
24 | |
import javax.security.auth.callback.Callback; |
25 | |
import javax.security.auth.callback.CallbackHandler; |
26 | |
import javax.security.auth.callback.UnsupportedCallbackException; |
27 | |
import java.io.IOException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class CryptoPasswordCallbackHandler implements CallbackHandler { |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { |
42 | 0 | for (int i = 0; i < callbacks.length; i++) { |
43 | 0 | if (callbacks[i] instanceof WSPasswordCallback) { |
44 | 0 | WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; |
45 | 0 | String password = ConfigContext.getCurrentContextConfig().getKeystorePassword(); |
46 | 0 | if (password == null) { |
47 | 0 | throw new ConfigurationException("Could not locate the webservice password. Should be configured as the '" + Config.KEYSTORE_PASSWORD + "' property."); |
48 | |
} |
49 | 0 | pc.setPassword(password); |
50 | 0 | } else { |
51 | 0 | throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); |
52 | |
} |
53 | |
} |
54 | 0 | } |
55 | |
} |