クラス Wss4jSecurityInterceptor

java.lang.ObjectSE
org.springframework.ws.soap.security.AbstractWsSecurityInterceptor
org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor
実装されたすべてのインターフェース:
org.springframework.beans.factory.InitializingBeanClientInterceptorEndpointInterceptorSoapEndpointInterceptor

public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor implements org.springframework.beans.factory.InitializingBean
Apache の WSS4J に基づく WS-Security エンドポイントインターセプター。このインターセプターは、org.springframework.ws.soap.axiom.AxiomSoapMessageFactory および SaajSoapMessageFactory によって作成されたメッセージをサポートします。

このインターセプターによって実行される検証アクションと保護アクションは、それぞれ validationActions プロパティと securementActions プロパティを介して構成されます。アクションは、スペースで区切られた文字列として渡す必要があります。

有効な検証アクションは次のとおりです。

検証アクション 説明
UsernameToken ユーザー名トークンを検証します
Timestamp タイムスタンプを検証します
Encrypt メッセージを復号化します
Signature 署名を検証します
NoSecurity アクションは実行されません

保護アクションは次のとおりです。

固定アクション 説明
UsernameToken ユーザー名トークンを追加します
UsernameTokenSignature ユーザー名トークンと署名ユーザー名トークン秘密鍵を追加します
Timestamp タイムスタンプを追加します
Encrypt レスポンスを暗号化します
Signature レスポンスに署名します
NoSecurity アクションは実行されません

メッセージを保護するためにクライアントが実行したアクションの順序は重要であり、インターセプターによって強制されます。

導入:
2.3.0
作成者:
Tareq Abed Rabbo, Arjen Poutsma, Greg Turnquist, Jamin Hitchcock, Rob Leland
関連事項:
  • フィールドの詳細

  • コンストラクターの詳細

    • Wss4jSecurityInterceptor

      public Wss4jSecurityInterceptor()
      デフォルトで WSSecurityEngine を作成します。
    • Wss4jSecurityInterceptor

      public Wss4jSecurityInterceptor(org.apache.wss4j.dom.engine.WSSecurityEngine securityEngine)
      カスタマイズした WSSecurityEngine を挿入します。
      パラメーター:
      securityEngine -
  • メソッドの詳細

    • setSecurementActions

      public void setSecurementActions(StringSE securementActions)
    • setSecurementActor

      public void setSecurementActor(StringSE securementActor)
      wsse:Security ヘッダーのアクター名。

      このパラメーターを省略すると、アクター名は設定されません。

      アクターまたはロールの値は、レシーバーの設定と一致する必要があります。または、標準値が含まれている場合があります。

    • setSecurementEncryptionCrypto

      public void setSecurementEncryptionCrypto(org.apache.wss4j.common.crypto.Crypto securementEncryptionCrypto)
    • setSecurementEncryptionKeyIdentifier

      public void setSecurementEncryptionKeyIdentifier(StringSE securementEncryptionKeyIdentifier)
      使用するキー識別子の型を定義します。WS-Security 仕様では、識別子型 IssuerSerial の使用を推奨しています。可能な暗号化キー識別子型については、org.apache.ws.security.handler.WSHandlerConstants#keyIdentifier を参照してください。暗号化の場合、IssuerSerialX509KeyIdentifierDirectReferenceThumbprintSKIKeyIdentifierEmbeddedKeyName はのみ有効です。
    • setSecurementEncryptionKeyTransportAlgorithm

      public void setSecurementEncryptionKeyTransportAlgorithm(StringSE securementEncryptionKeyTransportAlgorithm)
      生成された対称鍵の暗号化に使用するアルゴリズムを定義します。現在、WSS4J は WSS4JConstants.KEYTRANSPORT_RSA15 および WSConstants#KEYTRANSPORT_RSAOEP をサポートしています。
    • setSecurementEncryptionParts

      public void setSecurementEncryptionParts(StringSE securementEncryptionParts)
      リクエストのどの部分を暗号化するかを定義するプロパティ。

      このプロパティの値は、暗号化する要素を識別するセミコロンで区切られた要素名のリストです。暗号化モード指定子と名前空間 ID は、それぞれカーリー括弧のペア内にあり、各要素名の前に付けることができます。

      暗号化モード指定子は、{Content} または {Element} のいずれかです。要素暗号化とコンテンツ暗号化の違いについては、W3CXML 暗号化仕様を参照してください。暗号化モードを省略すると、デフォルトで Content になります。リストの例:

       <property name="securementEncryptionParts"
               value="{Content}{http://example.org/paymentv2}CreditCard;
                                 {Element}{}UserName" />
       
      リストの最初のエントリは、名前空間 http://example.org/paymentv2 内の要素 CreditCard を識別し、そのコンテンツを暗号化します。要素名、名前空間識別子、暗号化修飾子では大文字と小文字が区別されることに注意してください。

      暗号化修飾子と名前空間識別子は省略できます。この場合、暗号化モードはデフォルトで Content に設定され、名前空間は SOAP 名前空間に設定されます。

      空の暗号化モードはデフォルトで Content になり、空の名前空間識別子はデフォルトで SOAP 名前空間になります。例の 2 行目では、Element を SOAP 名前空間の UserName 要素の暗号化モードとして定義しています。

      名前空間のない要素を指定するには、名前空間名として文字列 Null を使用します (これは大文字と小文字を区別する文字列です)

      リストが指定されていない場合、ハンドラーはデフォルトで Content モードで SOAP 本体を暗号化します。

    • setSecurementEncryptionSymAlgorithm

      public void setSecurementEncryptionSymAlgorithm(StringSE securementEncryptionSymAlgorithm)
      使用する対称暗号化アルゴリズムを定義します。WSS4J は、次のアルゴリズムをサポートしています: WSS4JConstants.TRIPLE_DESWSS4JConstants.AES_128WSS4JConstants.AES_256WSS4JConstants.AES_192. AES 192 を除いて、これらのアルゴリズムはすべて XML 暗号化仕様で要求されています。
    • setSecurementEncryptionUser

      public void setSecurementEncryptionUser(StringSE securementEncryptionUser)
      暗号化のためのユーザーの名前。

      暗号化機能は、このユーザーの証明書の公開鍵を使用して、生成された対称鍵を暗号化します。

      このパラメーターが設定されていない場合、暗号化機能は org.apache.ws.security.handler.WSHandlerConstants#USER パラメーターにフォールバックして証明書を取得します。

      SOAP 本体データの暗号化のみがリクエストされる場合は、このパラメーターを使用してユーザー名を定義することをお勧めします。その後、アプリケーションは標準のユーザーおよびパスワード機能を使用できます(HTTP 認証機能を有効にするには org.apache.ws.security.handler.WSHandlerConstants#USER の例を参照してください)。

      暗号化はユーザー / 送信者を認証するだけではないため、パスワードは必要ありません。

      暗号化証明書のユーザー名を構成ファイルに配置しても、その証明書の公開鍵のみが使用されるため、セキュリティ上のリスクはありません。

    • setSecurementPassword

      public void setSecurementPassword(StringSE securementPassword)
    • setSecurementPasswordType

      public void setSecurementPasswordType(StringSE securementUsernameTokenPasswordType)
      passowrd のエンコーディングを定義するための UsernameToken アクションの特定のパラメーター。

      パラメーターは、WSS4JConstants.PW_DIGEST または WSS4JConstants.PW_TEXT のいずれかに設定できます。

      デフォルト設定は PW_DIGEST です。

    • setSecurementSignatureAlgorithm

      public void setSecurementSignatureAlgorithm(StringSE securementSignatureAlgorithm)
      使用する署名アルゴリズムを定義します。
      関連事項:
      • WSS4JConstants.RSA
      • WSS4JConstants.DSA
    • setSecurementSignatureDigestAlgorithm

      public void setSecurementSignatureDigestAlgorithm(StringSE digestAlgorithm)
      使用するシグニチャダイジェストアルゴリズムを定義します。
    • setSecurementSignatureCrypto

      public void setSecurementSignatureCrypto(org.apache.wss4j.common.crypto.Crypto securementSignatureCrypto)
    • setSecurementSignatureKeyIdentifier

      public void setSecurementSignatureKeyIdentifier(StringSE securementSignatureKeyIdentifier)
      使用するキー識別子の型を定義します。WS-Security 仕様では、識別子型 IssuerSerial の使用を推奨しています。可能な署名キー識別子型については、org.apache.ws.security.handler.WSHandlerConstants#keyIdentifier を参照してください。署名の場合、IssuerSerial および DirectReference はのみ有効です。
    • setSecurementSignatureParts

      public void setSecurementSignatureParts(StringSE securementSignatureParts)
      リクエストのどの部分に署名するかを定義するプロパティ。

      値の文字列の形式の詳細については、setSecurementEncryptionParts(String) を参照してください。

      このプロパティが指定されていない場合、ハンドラーはデフォルトで SOAP 本体に署名します。

      WS Security 仕様では、署名トークン(証明書)またはこれらのトークンへの参照を転送するためのいくつかの形式が定義されています。プレーン要素名 Token はトークンに署名し、さまざまな形式を処理します。

      SOAP 本体と 署名トークンに署名するには、このパラメーターの値に次のものが含まれている必要があります。

       <property name="securementSignatureParts"
               value="{}{http://schemas.xmlsoap.org/soap/envelope/}Body; Token" />
       
      名前空間のない要素を指定するには、名前空間名として文字列 Null を使用します (これは大文字と小文字を区別する文字列です)

      ローカル名が Body の要素がリクエストに他にない場合は、SOAP 名前空間識別子を空にすることができます({})。

    • setSecurementSignatureUser

      public void setSecurementSignatureUser(StringSE securementSignatureUser)
      署名用のユーザー名。

      この名前は、署名を実行するためのユーザーの証明書と秘密鍵を取得するためのキーストアのエイリアス名として使用されます。

      このパラメーターが設定されていない場合、署名機能は setSecurementUsername(String) で指定された別名にフォールバックします。

    • setSecurementUsername

      public void setSecurementUsername(StringSE securementUsername)
      保護ユーザー名トークンのユーザー名または / および保護署名の秘密鍵のエイリアスを設定します
    • setSecurementTimeToLive

      public void setSecurementTimeToLive(int securementTimeToLive)
      送信メッセージの存続時間を設定します
    • setSecurementUseDerivedKey

      public void setSecurementUseDerivedKey(boolean securementUseDerivedKey)
      UsernameTokenProfile 1.1 仕様に従ってキーの派生を有効にします。デフォルトは true です。
    • setSecurementSamlCallbackHandler

      public void setSecurementSamlCallbackHandler(CallbackHandlerSE samlCallbackHandler)
      SAML トークンの生成に使用される SAML コールバックを設定します。
      パラメーター:
      samlCallback -
    • setValidationTimeToLive

      public void setValidationTimeToLive(int validationTimeToLive)
      サーバー側の存続時間を設定します
    • setValidationActions

      public void setValidationActions(StringSE actions)
      インターセプターによって実行される検証アクションを設定します。
    • setValidationActor

      public void setValidationActor(StringSE validationActor)
    • setValidationCallbackHandler

      public void setValidationCallbackHandler(CallbackHandlerSE callbackHandler)
      メッセージの検証時に使用する CallbackHandlerSE を設定します。
      関連事項:
    • setValidationCallbackHandlers

      public void setValidationCallbackHandlers(CallbackHandlerSE[] callbackHandler)
      メッセージの検証時に使用する CallbackHandlerSE を設定します。
      関連事項:
    • setValidationDecryptionCrypto

      public void setValidationDecryptionCrypto(org.apache.wss4j.common.crypto.Crypto decryptionCrypto)
      受信メッセージの復号化に使用する暗号を設定します
    • setValidationSignatureCrypto

      public void setValidationSignatureCrypto(org.apache.wss4j.common.crypto.Crypto signatureCrypto)
      受信メッセージの署名を検証するために使用する暗号を設定します
    • setEnableSignatureConfirmation

      public void setEnableSignatureConfirmation(boolean enableSignatureConfirmation)
      signatureConfirmation を有効にするかどうか。デフォルトでは signatureConfirmation が有効になっています
    • setTimestampPrecisionInMilliseconds

      public void setTimestampPrecisionInMilliseconds(boolean timestampPrecisionInMilliseconds)
      生成されたタイムスタンプヘッダーの精度がミリ秒単位であるかどうかを設定します。
    • setTimestampStrict

      public void setTimestampStrict(boolean timestampStrict)
      サーバー側の存続時間でタイムスタンプ検証を実行するかどうかを設定します
    • setSecurementMustUnderstand

      public void setSecurementMustUnderstand(boolean securementMustUnderstand)
      送信メッセージの WS-Security ヘッダーで mustUnderstand 属性を有効にします。デフォルトは true です。
    • setSecurementUsernameTokenNonce

      public void setSecurementUsernameTokenNonce(boolean securementUsernameTokenNonce)
      Nonce 要素を UsernameToken に追加するかどうかを設定します。デフォルトは false です。
    • setSecurementUsernameTokenCreated

      public void setSecurementUsernameTokenCreated(boolean securementUsernameTokenCreated)
      Created 要素を UsernameToken に追加するかどうかを設定します。デフォルトは false です。
    • setWssConfig

      public void setWssConfig(org.apache.wss4j.dom.engine.WSSConfig config)
      Web サービス仕様の設定を行います。

      デフォルト設定は最新の OASIS に従い、何かを変更すると OASIS 仕様に違反する可能性があります。

      パラメーター:
      config - デフォルト設定を使用するための Web サービスセキュリティ構成または null 
    • setEnableRevocation

      public void setEnableRevocation(boolean enableRevocation)
      証明書の信頼を確認するときに CRL チェックを有効にするかどうかを設定します。
    • setBspCompliant

      public void setBspCompliant(boolean bspCompliant)
      WS-I 基本セキュリティプロファイルコンプライアンスモードを設定します。デフォルトは true です。
    • setAddInclusivePrefixes

      public void setAddInclusivePrefixes(boolean addInclusivePrefixes)
      WSConstants.C14N_EXCL_OMIT_COMMENTS を使用して署名を生成するときに , InclusiveNamespaces PrefixList を CanonicalizationMethod の子として追加するかどうかを設定します。デフォルトは true です。
    • setAllowRSA15KeyTransportAlgorithm

      public void setAllowRSA15KeyTransportAlgorithm(boolean allow)
      RSA 1.5 キートランスポートアルゴリズムを許可するかどうかを設定します。
    • setFutureTimeToLive

      public void setFutureTimeToLive(int futureTimeToLive)
      受信タイムスタンプの作成時刻が有効になる将来の時刻を秒単位で設定します。デフォルトは 60 秒です。
    • getRemoveSecurityHeader

      public boolean getRemoveSecurityHeader()
    • setRemoveSecurityHeader

      public void setRemoveSecurityHeader(boolean removeSecurityHeader)
    • afterPropertiesSet

      public void afterPropertiesSet() throws ExceptionSE
      次で指定:
      インターフェース org.springframework.beans.factory.InitializingBeanafterPropertiesSet 
      例外:
      ExceptionSE
    • secureMessage

      protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext) throws WsSecuritySecurementException
      クラスからコピーされた説明: AbstractWsSecurityInterceptor
      抽象テンプレートメソッド。指定された SoapMessage に含まれるレスポンスを保護し、元のレスポンスを保護されたバージョンに置き換えるには、サブクラスが必要です。
      次で指定:
      クラス AbstractWsSecurityInterceptorsecureMessage 
      パラメーター:
      soapMessage - 保護する SOAP メッセージ
      例外:
      WsSecuritySecurementException - 保護エラーの場合
    • initializeRequestData

      protected org.apache.wss4j.dom.handler.RequestData initializeRequestData(MessageContext messageContext)
      指定されたメッセージコンテキストのリクエストデータを作成して初期化します。
      パラメーター:
      messageContext - メッセージコンテキスト
      戻り値:
      リクエストデータ
    • initializeValidationRequestData

      protected org.apache.wss4j.dom.handler.RequestData initializeValidationRequestData(MessageContext messageContext)
      指定されたメッセージコンテキストのリクエストデータを作成して初期化します。
      パラメーター:
      messageContext - メッセージコンテキスト
      戻り値:
      リクエストデータ
    • validateMessage

      protected void validateMessage(SoapMessage soapMessage, MessageContext messageContext) throws WsSecurityValidationException
      クラスからコピーされた説明: AbstractWsSecurityInterceptor
      抽象テンプレートメソッド。指定された SoapMessage に含まれるリクエストを検証し、元のリクエストを検証済みのバージョンに置き換えるには、サブクラスが必要です。
      次で指定:
      クラス AbstractWsSecurityInterceptorvalidateMessage 
      パラメーター:
      soapMessage - 検証する SOAP メッセージ
      例外:
      WsSecurityValidationException - 検証エラーの場合
    • checkResults

      protected void checkResults(ListSE<org.apache.wss4j.dom.engine.WSSecurityEngineResult> results, ListSE<IntegerSE> validationActions) throws Wss4jSecurityValidationException
      受信したヘッダーが構成済みの検証アクションと一致するかどうかを確認します。サブクラスは、カスタム検証動作のためにこのメソッドをオーバーライドできます。
      パラメーター:
      results - 検証機能の結果
      validationActions - デコードされた検証アクション
      例外:
      Wss4jSecurityValidationException - 結果が無効と見なされた場合
    • verifyCertificateTrust

      protected void verifyCertificateTrust(org.apache.wss4j.dom.handler.WSHandlerResult result) throws org.apache.wss4j.common.ext.WSSecurityException
      証明書の信頼性を検証します。
      パラメーター:
      result -
      例外:
      org.apache.wss4j.common.ext.WSSecurityException
    • verifyTimestamp

      protected void verifyTimestamp(org.apache.wss4j.dom.handler.WSHandlerResult result) throws org.apache.wss4j.common.ext.WSSecurityException
      タイムスタンプを確認します。
      パラメーター:
      result -
      例外:
      org.apache.wss4j.common.ext.WSSecurityException
    • cleanUp

      protected void cleanUp()
      次で指定:
      クラス AbstractWsSecurityInterceptorcleanUp