クラス Wss4jSecurityInterceptor
- 実装されているすべてのインターフェース:
org.springframework.beans.factory.InitializingBean、ClientInterceptor、EndpointInterceptor、SoapEndpointInterceptor
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
- 関連事項:
フィールドのサマリー
フィールドクラス org.springframework.ws.soap.security.AbstractWsSecurityInterceptor から継承されたフィールド
logger, WS_SECURITY_NAMEコンストラクターの概要
コンストラクターコンストラクター説明デフォルトでWSSecurityEngineを作成します。Wss4jSecurityInterceptor(org.apache.wss4j.dom.engine.WSSecurityEngine securityEngine) カスタマイズしたWSSecurityEngineを挿入します。メソッドのサマリー
修飾子と型メソッド説明voidprotected voidcheckResults(ListSE<org.apache.wss4j.dom.engine.WSSecurityEngineResult> results, ListSE<IntegerSE> validationActions) 受信したヘッダーが構成済みの検証アクションと一致するかどうかを確認します。protected voidcleanUp()booleanprotected org.apache.wss4j.dom.handler.RequestDatainitializeRequestData(MessageContext messageContext) 指定されたメッセージコンテキストのリクエストデータを作成して初期化します。protected org.apache.wss4j.dom.handler.RequestDatainitializeValidationRequestData(MessageContext messageContext) 指定されたメッセージコンテキストのリクエストデータを作成して初期化します。protected voidsecureMessage(SoapMessage soapMessage, MessageContext messageContext) 抽象テンプレートメソッド。voidsetAddInclusivePrefixes(boolean addInclusivePrefixes) WSConstants.C14N_EXCL_OMIT_COMMENTS を使用して署名を生成するときに , InclusiveNamespaces PrefixList を CanonicalizationMethod の子として追加するかどうかを設定します。voidsetAllowRSA15KeyTransportAlgorithm(boolean allow) RSA 1.5 キートランスポートアルゴリズムを許可するかどうかを設定します。voidsetBspCompliant(boolean bspCompliant) WS-I 基本セキュリティプロファイルコンプライアンスモードを設定します。voidsetEnableRevocation(boolean enableRevocation) 証明書の信頼を確認するときに CRL チェックを有効にするかどうかを設定します。voidsetEnableSignatureConfirmation(boolean enableSignatureConfirmation) signatureConfirmation を有効にするかどうか。voidsetFutureTimeToLive(int futureTimeToLive) 受信タイムスタンプの作成時刻が有効になる将来の時刻を秒単位で設定します。voidsetRemoveSecurityHeader(boolean removeSecurityHeader) voidsetSecurementActions(StringSE securementActions) voidsetSecurementActor(StringSE securementActor) wsse:Securityヘッダーのアクター名。voidsetSecurementEncryptionCrypto(org.apache.wss4j.common.crypto.Crypto securementEncryptionCrypto) voidsetSecurementEncryptionKeyIdentifier(StringSE securementEncryptionKeyIdentifier) 使用するキー識別子の型を定義します。voidsetSecurementEncryptionKeyTransportAlgorithm(StringSE securementEncryptionKeyTransportAlgorithm) 生成された対称鍵の暗号化に使用するアルゴリズムを定義します。voidsetSecurementEncryptionParts(StringSE securementEncryptionParts) リクエストのどの部分を暗号化するかを定義するプロパティ。voidsetSecurementEncryptionSymAlgorithm(StringSE securementEncryptionSymAlgorithm) 使用する対称暗号化アルゴリズムを定義します。voidsetSecurementEncryptionUser(StringSE securementEncryptionUser) 暗号化のためのユーザーの名前。voidsetSecurementMustUnderstand(boolean securementMustUnderstand) 送信メッセージの WS-Security ヘッダーでmustUnderstand属性を有効にします。voidsetSecurementPassword(StringSE securementPassword) voidsetSecurementPasswordType(StringSE securementUsernameTokenPasswordType) passowrd のエンコーディングを定義するための UsernameToken アクションの特定のパラメーター。voidsetSecurementSamlCallbackHandler(CallbackHandlerSE samlCallbackHandler) SAML トークンの生成に使用される SAML コールバックを設定します。voidsetSecurementSignatureAlgorithm(StringSE securementSignatureAlgorithm) 使用する署名アルゴリズムを定義します。voidsetSecurementSignatureCrypto(org.apache.wss4j.common.crypto.Crypto securementSignatureCrypto) voidsetSecurementSignatureDigestAlgorithm(StringSE digestAlgorithm) 使用するシグニチャダイジェストアルゴリズムを定義します。voidsetSecurementSignatureKeyIdentifier(StringSE securementSignatureKeyIdentifier) 使用するキー識別子の型を定義します。voidsetSecurementSignatureParts(StringSE securementSignatureParts) リクエストのどの部分に署名するかを定義するプロパティ。voidsetSecurementSignatureUser(StringSE securementSignatureUser) 署名用のユーザー名。voidsetSecurementTimeToLive(int securementTimeToLive) 送信メッセージの存続時間を設定しますvoidsetSecurementUseDerivedKey(boolean securementUseDerivedKey) UsernameTokenProfile 1.1 仕様に従ってキーの派生を有効にします。voidsetSecurementUsername(StringSE securementUsername) 保護ユーザー名トークンのユーザー名または / および保護署名の秘密鍵のエイリアスを設定しますvoidsetSecurementUsernameTokenCreated(boolean securementUsernameTokenCreated) Created要素をUsernameTokenに追加するかどうかを設定します。voidsetSecurementUsernameTokenNonce(boolean securementUsernameTokenNonce) Nonce要素をUsernameTokenに追加するかどうかを設定します。voidsetTimestampPrecisionInMilliseconds(boolean timestampPrecisionInMilliseconds) 生成されたタイムスタンプヘッダーの精度がミリ秒単位であるかどうかを設定します。voidsetTimestampStrict(boolean timestampStrict) サーバー側の存続時間でタイムスタンプ検証を実行するかどうかを設定しますvoidsetValidationActions(StringSE actions) インターセプターによって実行される検証アクションを設定します。voidsetValidationActor(StringSE validationActor) voidsetValidationCallbackHandler(CallbackHandlerSE callbackHandler) メッセージの検証時に使用するCallbackHandlerSE を設定します。voidsetValidationCallbackHandlers(CallbackHandlerSE[] callbackHandler) メッセージの検証時に使用するCallbackHandlerSE を設定します。voidsetValidationDecryptionCrypto(org.apache.wss4j.common.crypto.Crypto decryptionCrypto) 受信メッセージの復号化に使用する暗号を設定しますvoidsetValidationSignatureCrypto(org.apache.wss4j.common.crypto.Crypto signatureCrypto) 受信メッセージの署名を検証するために使用する暗号を設定しますvoidsetValidationTimeToLive(int validationTimeToLive) サーバー側の存続時間を設定しますvoidsetWssConfig(org.apache.wss4j.dom.engine.WSSConfig config) Web サービス仕様の設定を行います。protected voidvalidateMessage(SoapMessage soapMessage, MessageContext messageContext) 抽象テンプレートメソッド。protected voidverifyCertificateTrust(org.apache.wss4j.dom.handler.WSHandlerResult result) 証明書の信頼性を検証します。protected voidverifyTimestamp(org.apache.wss4j.dom.handler.WSHandlerResult result) タイムスタンプを確認します。クラス org.springframework.ws.soap.security.AbstractWsSecurityInterceptor から継承されたメソッド
afterCompletion, afterCompletion, handleFault, handleFault, handleFaultException, handleRequest, handleRequest, handleResponse, handleResponse, handleSecurementException, handleValidationException, setExceptionResolver, setSecureRequest, setSecureResponse, setSkipValidationIfNoHeaderPresent, setValidateRequest, setValidateResponse, understands
フィールドの詳細
SECUREMENT_USER_PROPERTY_NAME
- 関連事項:
コンストラクターの詳細
Wss4jSecurityInterceptor
public Wss4jSecurityInterceptor()デフォルトでWSSecurityEngineを作成します。Wss4jSecurityInterceptor
public Wss4jSecurityInterceptor(org.apache.wss4j.dom.engine.WSSecurityEngine securityEngine) カスタマイズしたWSSecurityEngineを挿入します。- パラメーター:
securityEngine-
メソッドの詳細
setSecurementActions
setSecurementActor
wsse:Securityヘッダーのアクター名。このパラメーターを省略すると、アクター名は設定されません。
アクターまたはロールの値は、レシーバーの設定と一致する必要があります。または、標準値が含まれている場合があります。
setSecurementEncryptionCrypto
public void setSecurementEncryptionCrypto(org.apache.wss4j.common.crypto.Crypto securementEncryptionCrypto) setSecurementEncryptionKeyIdentifier
使用するキー識別子の型を定義します。WS-Security 仕様では、識別子型IssuerSerialの使用を推奨しています。可能な暗号化キー識別子型については、org.apache.ws.security.handler.WSHandlerConstants#keyIdentifierを参照してください。暗号化の場合、IssuerSerial、X509KeyIdentifier、DirectReference、Thumbprint、SKIKeyIdentifier、EmbeddedKeyNameはのみ有効です。setSecurementEncryptionKeyTransportAlgorithm
public void setSecurementEncryptionKeyTransportAlgorithm(StringSE securementEncryptionKeyTransportAlgorithm) 生成された対称鍵の暗号化に使用するアルゴリズムを定義します。現在、WSS4J はWSS4JConstants.KEYTRANSPORT_RSA15およびWSConstants#KEYTRANSPORT_RSAOEPをサポートしています。setSecurementEncryptionParts
リクエストのどの部分を暗号化するかを定義するプロパティ。このプロパティの値は、暗号化する要素を識別するセミコロンで区切られた要素名のリストです。暗号化モード指定子と名前空間 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
使用する対称暗号化アルゴリズムを定義します。WSS4J は、次のアルゴリズムをサポートしています:WSS4JConstants.TRIPLE_DES、WSS4JConstants.AES_128、WSS4JConstants.AES_256、WSS4JConstants.AES_192. AES 192 を除いて、これらのアルゴリズムはすべて XML 暗号化仕様で要求されています。setSecurementEncryptionUser
暗号化のためのユーザーの名前。暗号化機能は、このユーザーの証明書の公開鍵を使用して、生成された対称鍵を暗号化します。
このパラメーターが設定されていない場合、暗号化機能は
org.apache.ws.security.handler.WSHandlerConstants#USERパラメーターにフォールバックして証明書を取得します。SOAP 本体データの暗号化のみがリクエストされる場合は、このパラメーターを使用してユーザー名を定義することをお勧めします。その後、アプリケーションは標準のユーザーおよびパスワード機能を使用できます(HTTP 認証機能を有効にするには
org.apache.ws.security.handler.WSHandlerConstants#USERの例を参照してください)。暗号化はユーザー / 送信者を認証するだけではないため、パスワードは必要ありません。
暗号化証明書のユーザー名を構成ファイルに配置しても、その証明書の公開鍵のみが使用されるため、セキュリティ上のリスクはありません。
setSecurementPassword
setSecurementPasswordType
passowrd のエンコーディングを定義するための UsernameToken アクションの特定のパラメーター。パラメーターは、
WSS4JConstants.PW_DIGESTまたはWSS4JConstants.PW_TEXTのいずれかに設定できます。デフォルト設定は PW_DIGEST です。
setSecurementSignatureAlgorithm
使用する署名アルゴリズムを定義します。- 関連事項:
WSS4JConstants.RSAWSS4JConstants.DSA
setSecurementSignatureDigestAlgorithm
使用するシグニチャダイジェストアルゴリズムを定義します。setSecurementSignatureCrypto
public void setSecurementSignatureCrypto(org.apache.wss4j.common.crypto.Crypto securementSignatureCrypto) setSecurementSignatureKeyIdentifier
使用するキー識別子の型を定義します。WS-Security 仕様では、識別子型IssuerSerialの使用を推奨しています。可能な署名キー識別子型については、org.apache.ws.security.handler.WSHandlerConstants#keyIdentifierを参照してください。署名の場合、IssuerSerialおよびDirectReferenceはのみ有効です。setSecurementSignatureParts
リクエストのどの部分に署名するかを定義するプロパティ。値の文字列の形式の詳細については、
setSecurementEncryptionParts(String)を参照してください。このプロパティが指定されていない場合、ハンドラーはデフォルトで SOAP 本体に署名します。
WS Security 仕様では、署名トークン(証明書)またはこれらのトークンへの参照を転送するためのいくつかの形式が定義されています。プレーン要素名
Tokenはトークンに署名し、さまざまな形式を処理します。SOAP 本体と 署名トークンに署名するには、このパラメーターの値に次のものが含まれている必要があります。
<property name="securementSignatureParts" value="{}{http://schemas.xmlsoap.org/soap/envelope/}Body; Token" />名前空間のない要素を指定するには、名前空間名として文字列Nullを使用します (これは大文字と小文字を区別する文字列です)ローカル名が
Bodyの要素がリクエストに他にない場合は、SOAP 名前空間識別子を空にすることができます({})。setSecurementSignatureUser
署名用のユーザー名。この名前は、署名を実行するためのユーザーの証明書と秘密鍵を取得するためのキーストアのエイリアス名として使用されます。
このパラメーターが設定されていない場合、署名機能は
setSecurementUsername(String)で指定された別名にフォールバックします。setSecurementUsername
保護ユーザー名トークンのユーザー名または / および保護署名の秘密鍵のエイリアスを設定しますsetSecurementTimeToLive
public void setSecurementTimeToLive(int securementTimeToLive) 送信メッセージの存続時間を設定しますsetSecurementUseDerivedKey
public void setSecurementUseDerivedKey(boolean securementUseDerivedKey) UsernameTokenProfile 1.1 仕様に従ってキーの派生を有効にします。デフォルトはtrueです。setSecurementSamlCallbackHandler
SAML トークンの生成に使用される SAML コールバックを設定します。- パラメーター:
samlCallback-
setValidationTimeToLive
public void setValidationTimeToLive(int validationTimeToLive) サーバー側の存続時間を設定しますsetValidationActions
インターセプターによって実行される検証アクションを設定します。setValidationActor
setValidationCallbackHandler
メッセージの検証時に使用するCallbackHandlerSE を設定します。setValidationCallbackHandlers
メッセージの検証時に使用する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
- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBeanのafterPropertiesSet - 例外:
ExceptionSE
secureMessage
protected void secureMessage(SoapMessage soapMessage, MessageContext messageContext) throws WsSecuritySecurementException クラスからコピーされた説明:AbstractWsSecurityInterceptor抽象テンプレートメソッド。指定されたSoapMessageに含まれるレスポンスを保護し、元のレスポンスを保護されたバージョンに置き換えるには、サブクラスが必要です。- 次で指定:
- クラス
AbstractWsSecurityInterceptorのsecureMessage - パラメーター:
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に含まれるリクエストを検証し、元のリクエストを検証済みのバージョンに置き換えるには、サブクラスが必要です。- 次で指定:
- クラス
AbstractWsSecurityInterceptorのvalidateMessage - パラメーター:
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()- 次で指定:
- クラス
AbstractWsSecurityInterceptorのcleanUp