2016-05-13 3 views
-1

CXFを使用して、署名された部分的に暗号化されたSOAPメッセージをIRSに送信しようとしています。私たちはすべての指示に従っていると思っていますが、あいまいさがあります。 SignatureとEncryptionのプロパティのいくつかはいくつかの方法で設定できますが、私が試した順列のどれもが恐ろしい "TPE1122"エラー(WS Security Header invalid)を克服できません。誰かがこれをうまくやったなら、私たちが設定しようとしていない不動産はありますか?私は特に、暗号化アルゴリズムの設定と、要素全体を暗号化するのか、その中の3つのヘッダー要素だけを暗号化するのかは不明です。ありがとう。これらのcxf/ws-securityプロパティは正しく設定されていますか? (TPE1122エラー「WS Security Header invalid」)

BulkRequestTransmitterService ss = new BulkRequestTransmitterService(wsdlURL, SERVICE_NAME); 
    BulkRequestTransmitterPortType port = ss.getBulkRequestTransmitterPort(); 

    org.apache.cxf.endpoint.Client client = ClientProxy.getClient(port); 

    // set up MTOM 
    Binding binding = ((BindingProvider)port).getBinding(); 
    ((SOAPBinding)binding).setMTOMEnabled(true); 

    // set output properties 
    Map<String, Object> outProps = new HashMap<String, Object>(); 
    outProps.put("action", "Timestamp Signature Encrypt"); 
    outProps.put("passwordType", "PasswordDigest"); 
    outProps.put("signatureUser", "[REDACTED]"; 
    outProps.put(WSHandlerConstants.SIG_KEY_ID, "X509KeyIdentifier"); 
    outProps.put("passwordCallbackClass", "UTPasswordCallback"); 
    outProps.put("encryptionUser", "irs"); 
    outProps.put("encryptionPropFile", "encryption.properties"); 
    outProps.put("encryptionKeyIdentifier", "DirectReference"); 
    outProps.put("encryptionKeyTransportAlgorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"); 

    // ENC_SYM_ALGO: what is the default? what should correct value be? and are these two lines equivalent? 
    outProps.put(WSHandlerConstants.ENC_SYM_ALGO, WSConstants.TRIPLE_DES); 
    outProps.put("encryptionSymAlgorithm", "http://www.w3.org/2001/04/xmlenc#tripledes-cbc"); 

    // do we encrypt each of the three signed headers, or entire Signature element? have tried it both ways 
    outProps.put("encryptionParts", 
     //"{Element}{" + WSU_NS + "}Timestamp;" 
     //+"{Element}{urn:us:gov:treasury:irs:ext:aca:air:7.0}ACATransmitterManifestReqDtl;" 
     //+"{Element}{urn:us:gov:treasury:irs:ext:aca:air:7.0}ACABusinessHeader;"); 
     "{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;"); 

    outProps.put("signaturePropFile", "signature.properties"); 
    outProps.put("signatureAlgorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1"); 
    outProps.put("signatureParts", 
      "{Element}{" + WSU_NS + "}Timestamp;" 
      + "{Element}{urn:us:gov:treasury:irs:ext:aca:air:7.0}ACATransmitterManifestReqDtl;" 
      + "{Element}{urn:us:gov:treasury:irs:ext:aca:air:7.0}ACABusinessHeader;"); 
    outProps.put(WSHandlerConstants.SIG_C14N_ALGO, "http://www.w3.org/2001/10/xml-exc-c14n#WithComments"); 

    // is "Direct Reference" preferable? have tried it both ways 
    outProps.put(WSHandlerConstants.ENC_KEY_ID, "X509KeyIdentifier"); 

    outProps.put("timeToLive", "600"); // = 10 min 
    outProps.put(WSHandlerConstants.MUST_UNDERSTAND, "false"); 

    WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); 
    client.getOutInterceptors().add(wssOut); 

    // add gzip interceptor 
    GZIPOutInterceptor gz = new GZIPOutInterceptor(); 
    gz.setForce(true); 
    client.getOutInterceptors().add(gz); 

    [ create & populate Manifest Detail here] 

    Header detailHeader = new Header(new QName("urn:us:gov:treasury:irs:ext:aca:air:7.0", "ACATransmitterManifestReqDtl"), aCATrnsmtManifestReqDtlType, 
      new JAXBDataBinding(ACATrnsmtManifestReqDtlType.class)); 
    headers.add(detailHeader); 

    Header businessHeader = new Header(new QName("urn:us:gov:treasury:irs:ext:aca:air:7.0", "ACABusinessHeader"), aCABulkBusinessHeaderRequestType, 
            new JAXBDataBinding(ACABulkBusinessHeaderRequestType.class)); 
    headers.add(businessHeader); 

    // add headers to Request 
    client.getRequestContext().put(Header.HEADER_LIST, headers); 

    // add namespaces: 
    Map<String, String> nsMap = new HashMap<>(); 
    nsMap.put("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); 
    nsMap.put("urn", "urn:us:gov:treasury:irs:ext:aca:air:7.0"); 
    nsMap.put("urn1", "urn:us:gov:treasury:irs:common");   
    nsMap.put("urn2", "urn:us:gov:treasury:irs:msg:acabusinessheader"); 
    nsMap.put("urn3", "urn:us:gov:treasury:irs:msg:irsacabulkrequesttransmitter"); 
    nsMap.put("urn4", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); 
    client.getRequestContext().put("soap.env.ns.map", nsMap); 

    // then transmit, get TPE1122 error in Response 
+0

IRSのACAサービスと接続する場合は、非常に注意する必要があります。あなたが提供したスキーマは、よく知られているws-securityスキーマを上書きしたものであるため、そのスキーマを調べる必要があります。多くのランタイムはあなたにそれをさせません、そして、あなたはあなた自身をロールバックしなければならなくなるでしょう。あなたは、私たちが慣れ親しんだものとは必ずしも一致しない、書き直されたwssecスキーマと正確に一致するように、すべて正しい順序で確実にすべてを持っていることを確かめなければなりません。それ以上のものはありません。私が働いている人は誰でも、それを正しく得るにはたくさんの作業が必要です。 –

答えて

1

IRS提出では、CXFセキュリティのBulitは機能しません。 IRSの要件を満たすためにインターセプタをコーディングする必要があります。

私は、提出およびステータス要求を行うことができるサンプルプロジェクトを用意しています。これは何のことではありません生産コードを意味するが、出発点

https://github.com/sangramjadhav/irsclient

することができapplication.ymlファイルを参照してください。 IRSへの提出のためにキーストアやその他の設定を提供する必要があります

0

フィードバックに感謝します。私たちは現在これを動作させていますが、主な問題は暗号化を使用しないことでした。投稿したサンプル内のすべてがうまくいきました(ヘッダーの特定の部分に署名するためにCXFを使用することを含む)が、暗号化を取り除かなければなりませんでした。

IRS AIRシステムに送信するときは、すべてを正しく取得することは実際には非常に困難です。次のハードルは、wsdlで生成されたファイルの名前空間を変更することで解決されました。その後、Linuxシステムのファイルサイズの値は、Windowsシステムの値より2文字小さくなりました - 原因は末尾のCRLFでした。

Java、Apache-CXF、Windowsを使用している人なら誰でもこれをやろうとしているなら、具体的な質問にお答えできます。

関連する問題