Skip to content

Commit 5f57898

Browse files
committed
Add support for configuring extra WSS4J options
Closes gh-1093
1 parent fa46f47 commit 5f57898

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,26 @@ public void setSecurementActions(String securementActions) {
231231
this.securementActions = securementActions;
232232
}
233233

234+
/**
235+
* Set a WSS4J option.
236+
* @param key the id of the option as defined in {@link WSHandlerConstants}
237+
* @param value the value of the option
238+
* @since 4.1.0
239+
*/
240+
public void setOption(String key, String value) {
241+
this.handler.setOption(key, value);
242+
}
243+
244+
/**
245+
* Set a WSS4J flag option.
246+
* @param key the id of the option as defined in {@link WSHandlerConstants}
247+
* @param value whether the option is enabled
248+
* @since 4.1.0
249+
*/
250+
public void setOption(String key, boolean value) {
251+
this.handler.setOption(key, value);
252+
}
253+
234254
/**
235255
* The actor name of the {@code wsse:Security} header.
236256
* <p>
@@ -240,7 +260,7 @@ public void setSecurementActions(String securementActions) {
240260
* standard values.
241261
*/
242262
public void setSecurementActor(String securementActor) {
243-
this.handler.setOption(WSHandlerConstants.ACTOR, securementActor);
263+
setOption(WSHandlerConstants.ACTOR, securementActor);
244264
}
245265

246266
public void setSecurementEncryptionCrypto(Crypto securementEncryptionCrypto) {
@@ -256,7 +276,7 @@ public void setSecurementEncryptionCrypto(Crypto securementEncryptionCrypto) {
256276
* only.
257277
*/
258278
public void setSecurementEncryptionKeyIdentifier(String securementEncryptionKeyIdentifier) {
259-
this.handler.setOption(WSHandlerConstants.ENC_KEY_ID, securementEncryptionKeyIdentifier);
279+
setOption(WSHandlerConstants.ENC_KEY_ID, securementEncryptionKeyIdentifier);
260280
}
261281

262282
/**
@@ -265,7 +285,7 @@ public void setSecurementEncryptionKeyIdentifier(String securementEncryptionKeyI
265285
* {@link WSConstants#KEYTRANSPORT_RSAOAEP}.
266286
*/
267287
public void setSecurementEncryptionKeyTransportAlgorithm(String securementEncryptionKeyTransportAlgorithm) {
268-
this.handler.setOption(WSHandlerConstants.ENC_KEY_TRANSPORT, securementEncryptionKeyTransportAlgorithm);
288+
setOption(WSHandlerConstants.ENC_KEY_TRANSPORT, securementEncryptionKeyTransportAlgorithm);
269289
}
270290

271291
/**
@@ -282,7 +302,7 @@ public void setSecurementEncryptionKeyTransportAlgorithm(String securementEncryp
282302
* it is omitted. Example of a list: <pre><code class="xml">
283303
* &lt;property name="securementEncryptionParts"
284304
* value="{Content}{http://example.org/paymentv2}CreditCard;
285-
* {Element}{}UserName" /&gt;
305+
* {Element}{}UserName" /&gt;
286306
* </code></pre> The first entry of the list identifies the element {@code CreditCard}
287307
* in the namespace {@code http://example.org/paymentv2}, and will encrypt its
288308
* content. Be aware that the element name, the namespace identifier, and the
@@ -304,7 +324,7 @@ public void setSecurementEncryptionKeyTransportAlgorithm(String securementEncryp
304324
* by default.
305325
*/
306326
public void setSecurementEncryptionParts(String securementEncryptionParts) {
307-
this.handler.setOption(WSHandlerConstants.ENCRYPTION_PARTS, securementEncryptionParts);
327+
setOption(WSHandlerConstants.ENCRYPTION_PARTS, securementEncryptionParts);
308328
}
309329

310330
/**
@@ -314,7 +334,7 @@ public void setSecurementEncryptionParts(String securementEncryptionParts) {
314334
* all of these algorithms are required by the XML Encryption specification.
315335
*/
316336
public void setSecurementEncryptionSymAlgorithm(String securementEncryptionSymAlgorithm) {
317-
this.handler.setOption(WSHandlerConstants.ENC_SYM_ALGO, securementEncryptionSymAlgorithm);
337+
setOption(WSHandlerConstants.ENC_SYM_ALGO, securementEncryptionSymAlgorithm);
318338
}
319339

320340
/**
@@ -338,7 +358,7 @@ public void setSecurementEncryptionSymAlgorithm(String securementEncryptionSymAl
338358
* a security risk, because the public key of that certificate is used only.
339359
*/
340360
public void setSecurementEncryptionUser(String securementEncryptionUser) {
341-
this.handler.setOption(WSHandlerConstants.ENCRYPTION_USER, securementEncryptionUser);
361+
setOption(WSHandlerConstants.ENCRYPTION_USER, securementEncryptionUser);
342362
}
343363

344364
public void setSecurementPassword(String securementPassword) {
@@ -354,7 +374,7 @@ public void setSecurementPassword(String securementPassword) {
354374
* The default setting is PW_DIGEST.
355375
*/
356376
public void setSecurementPasswordType(String securementUsernameTokenPasswordType) {
357-
this.handler.setOption(WSHandlerConstants.PASSWORD_TYPE, securementUsernameTokenPasswordType);
377+
setOption(WSHandlerConstants.PASSWORD_TYPE, securementUsernameTokenPasswordType);
358378
}
359379

360380
/**
@@ -363,14 +383,14 @@ public void setSecurementPasswordType(String securementUsernameTokenPasswordType
363383
* @see WSConstants#DSA
364384
*/
365385
public void setSecurementSignatureAlgorithm(String securementSignatureAlgorithm) {
366-
this.handler.setOption(WSHandlerConstants.SIG_ALGO, securementSignatureAlgorithm);
386+
setOption(WSHandlerConstants.SIG_ALGO, securementSignatureAlgorithm);
367387
}
368388

369389
/**
370390
* Defines which signature digest algorithm to use.
371391
*/
372392
public void setSecurementSignatureDigestAlgorithm(String digestAlgorithm) {
373-
this.handler.setOption(WSHandlerConstants.SIG_DIGEST_ALGO, digestAlgorithm);
393+
setOption(WSHandlerConstants.SIG_DIGEST_ALGO, digestAlgorithm);
374394
}
375395

376396
public void setSecurementSignatureCrypto(Crypto securementSignatureCrypto) {
@@ -384,7 +404,7 @@ public void setSecurementSignatureCrypto(Crypto securementSignatureCrypto) {
384404
* {@code IssuerSerial} and {@code DirectReference} are valid only.
385405
*/
386406
public void setSecurementSignatureKeyIdentifier(String securementSignatureKeyIdentifier) {
387-
this.handler.setOption(WSHandlerConstants.SIG_KEY_ID, securementSignatureKeyIdentifier);
407+
setOption(WSHandlerConstants.SIG_KEY_ID, securementSignatureKeyIdentifier);
388408
}
389409

390410
/**
@@ -414,7 +434,7 @@ public void setSecurementSignatureKeyIdentifier(String securementSignatureKeyIde
414434
* the SOAP namespace identifier can be empty ({@code {}}).
415435
*/
416436
public void setSecurementSignatureParts(String securementSignatureParts) {
417-
this.handler.setOption(WSHandlerConstants.SIGNATURE_PARTS, securementSignatureParts);
437+
setOption(WSHandlerConstants.SIGNATURE_PARTS, securementSignatureParts);
418438
}
419439

420440
/**
@@ -427,7 +447,7 @@ public void setSecurementSignatureParts(String securementSignatureParts) {
427447
* specified by {@link #setSecurementUsername(String)}.
428448
*/
429449
public void setSecurementSignatureUser(String securementSignatureUser) {
430-
this.handler.setOption(WSHandlerConstants.SIGNATURE_USER, securementSignatureUser);
450+
setOption(WSHandlerConstants.SIGNATURE_USER, securementSignatureUser);
431451
}
432452

433453
/**
@@ -548,15 +568,15 @@ public void setValidationSubjectDnConstraints(List<Pattern> patterns) {
548568
*/
549569
public void setEnableSignatureConfirmation(boolean enableSignatureConfirmation) {
550570

551-
this.handler.setOption(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, enableSignatureConfirmation);
571+
setOption(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION, enableSignatureConfirmation);
552572
this.enableSignatureConfirmation = enableSignatureConfirmation;
553573
}
554574

555575
/**
556576
* Sets if the generated timestamp header's precision is in milliseconds.
557577
*/
558578
public void setTimestampPrecisionInMilliseconds(boolean timestampPrecisionInMilliseconds) {
559-
this.handler.setOption(WSHandlerConstants.TIMESTAMP_PRECISION, timestampPrecisionInMilliseconds);
579+
setOption(WSHandlerConstants.TIMESTAMP_PRECISION, timestampPrecisionInMilliseconds);
560580
}
561581

562582
/**
@@ -571,23 +591,23 @@ public void setTimestampStrict(boolean timestampStrict) {
571591
* messages. Default is {@code true}.
572592
*/
573593
public void setSecurementMustUnderstand(boolean securementMustUnderstand) {
574-
this.handler.setOption(WSHandlerConstants.MUST_UNDERSTAND, securementMustUnderstand);
594+
setOption(WSHandlerConstants.MUST_UNDERSTAND, securementMustUnderstand);
575595
}
576596

577597
/**
578598
* Sets whether a {@code Nonce} element is added to the {@code UsernameToken}s.
579599
* Default is {@code false}.
580600
*/
581601
public void setSecurementUsernameTokenNonce(boolean securementUsernameTokenNonce) {
582-
this.handler.setOption(ConfigurationConstants.ADD_USERNAMETOKEN_NONCE, securementUsernameTokenNonce);
602+
setOption(ConfigurationConstants.ADD_USERNAMETOKEN_NONCE, securementUsernameTokenNonce);
583603
}
584604

585605
/**
586606
* Sets whether a {@code Created} element is added to the {@code UsernameToken}s.
587607
* Default is {@code false}.
588608
*/
589609
public void setSecurementUsernameTokenCreated(boolean securementUsernameTokenCreated) {
590-
this.handler.setOption(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, securementUsernameTokenCreated);
610+
setOption(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, securementUsernameTokenCreated);
591611
}
592612

593613
/**
@@ -616,7 +636,7 @@ public void setEnableRevocation(boolean enableRevocation) {
616636
*/
617637
public void setBspCompliant(boolean bspCompliant) {
618638

619-
this.handler.setOption(WSHandlerConstants.IS_BSP_COMPLIANT, bspCompliant);
639+
setOption(WSHandlerConstants.IS_BSP_COMPLIANT, bspCompliant);
620640
this.bspCompliant = bspCompliant;
621641
}
622642

@@ -627,7 +647,7 @@ public void setBspCompliant(boolean bspCompliant) {
627647
*/
628648
public void setAddInclusivePrefixes(boolean addInclusivePrefixes) {
629649

630-
this.handler.setOption(WSHandlerConstants.ADD_INCLUSIVE_PREFIXES, addInclusivePrefixes);
650+
setOption(WSHandlerConstants.ADD_INCLUSIVE_PREFIXES, addInclusivePrefixes);
631651
this.addInclusivePrefixes = addInclusivePrefixes;
632652
}
633653

@@ -640,7 +660,7 @@ public void setAddInclusivePrefixes(boolean addInclusivePrefixes) {
640660
* @see WSHandlerConstants#USE_SINGLE_CERTIFICATE
641661
*/
642662
public void setUseSingleCertificate(boolean useSingleCertificate) {
643-
this.handler.setOption(WSHandlerConstants.USE_SINGLE_CERTIFICATE, useSingleCertificate);
663+
setOption(WSHandlerConstants.USE_SINGLE_CERTIFICATE, useSingleCertificate);
644664
}
645665

646666
/**

0 commit comments

Comments
 (0)