再回到编辑Web服务属性设定画面﹐刚刚所点击的[使用开发默认值]的复选框如果已经有被勾选了﹐请将勾选取消。然后先离开编辑Web服务属性设定画面。
1.7. 加入CallbackHandler 档案
这里需要加入一个继承CallbackHandler的档案
TrustStoreCallbackHandler.java
public class TrustStoreCallbackHandler implements CallbackHandler {
KeyStore keyStore = null;
String password = "123456"; // keystore的密码
public TrustStoreCallbackHandler() {
System.out.println("Truststore CBH.CTOR Called..........");
InputStream is = null;
try {
keyStore = KeyStore.getInstance("JKS");
String keystoreURL = "C:\\Java\\Certificate\\myTrustStore"; //放置凭证档的keystore
is = new FileInputStream(keystoreURL);
keyStore.load(is, password.toCharArray());
} catch (IOException ex) {
Logger.getLogger(TrustStoreCallbackHandler.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(TrustStoreCallbackHandler.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
} catch (CertificateException ex) {
Logger.getLogger(TrustStoreCallbackHandler.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
} catch (KeyStoreException ex) {
Logger.getLogger(TrustStoreCallbackHandler.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
} finally {
try {
is.close();
} catch (IOException ex) {
Logger.getLogger(TrustStoreCallbackHandler.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
System.out.println("Truststore CBH.handle() Called..........");
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof KeyStoreCallback) {
KeyStoreCallback cb = (KeyStoreCallback) callbacks[i];
print(cb.getRuntimeProperties());
cb.setKeystore(keyStore);
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}
private void print(Map context) {
Iterator it = context.keySet().iterator();
while (it.hasNext()) {
System.out.println("Prop " + it.next());
}
}
}
1.8. 重回编辑 Web 服务属性
重新开启 编辑Web服务属性