Apache CXFを使用してWebサービスを構築しています。 Apache WSS4Jを使用してWS-Security機能を提供します。私はSOAPリクエストを作成する必要があり、署名が必要です。WSS4Jがコールストアからキーストアのパスワードをロードする方法を教えてください。
これは、プロパティの内容ですが、私はWSS4Jに渡すファイル:
org.apache.ws.security.crypto.provider = org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type = PKCS12
org.apache.ws.security.crypto.merlin.keystore.provider = BC
org.apache.ws.security.crypto.merlin.keystore.password = 12345678
org.apache.ws.security.crypto.merlin.keystore.alias = my-alias
org.apache.ws.security.crypto.merlin.keystore.file = my_certificate.p12
私は自分のパスワードプレーンテキストとして書いたと、その行を取り除きたいです。私は、その行を削除し、上記のコードのように、私のWSS4JOutInterceptorにパスワードコールバックハンドラを提供:
public SoapInterceptor newSignerInterceptor() {
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put(WSHandlerConstants.ACTION, "Signature");
outProps.put(WSHandlerConstants.USER, config.getKeyAlias());
outProps.put(WSHandlerConstants.SIG_KEY_ID, "DirectReference");
outProps.put(WSHandlerConstants.USE_REQ_SIG_CERT, WSHandlerConstants.SIGNATURE_USER);
outProps.put(WSHandlerConstants.USE_SINGLE_CERTIFICATE, "false");
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, this.getClass().getName());
outProps.put(WSHandlerConstants.SIG_PROP_FILE, config.getPropertiesFileName());
return new WSS4JOutInterceptor(outProps);
}
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
((WSPasswordCallback) callbacks[i]).setPassword(password);
}
}
}
しかし、それは動作しませんでした。プロパティー・ファイルでパスワードを検出せず、デフォルトのパスワード「セキュリティー」を使用します。
パスワードを取得するコールバックを使用するにはどうすればいいですか?