Review checkstyle rules of spring-ws-security

See gh-1479
This commit is contained in:
Stéphane Nicoll
2025-03-07 14:35:25 +01:00
parent 15d28812b1
commit 37504f00f5
8 changed files with 40 additions and 23 deletions

View File

@@ -27,11 +27,11 @@ import javax.xml.namespace.QName;
@SuppressWarnings("serial")
public abstract class WsSecurityFaultException extends WsSecurityException {
private QName faultCode;
private final QName faultCode;
private String faultString;
private final String faultString;
private String faultActor;
private final String faultActor;
/**
* Construct a new {@code WsSecurityFaultException} with the given fault code, string,

View File

@@ -23,7 +23,7 @@ import org.springframework.security.authentication.LockedException;
import org.springframework.security.core.userdetails.UserDetails;
/**
* Generic utility methods for Spring Security
* Generic utility methods for Spring Security.
*
* @author Tareq Abedrabbo
* @since 1.5.8

View File

@@ -31,9 +31,9 @@ import org.w3c.dom.Document;
import org.springframework.util.StringUtils;
import org.springframework.ws.context.MessageContext;
import static org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor.SECUREMENT_PASSWORD_PROPERTY_NAME;
/**
* {@link WSHandler} implementation.
*
* @author Tareq Abed Rabbo
* @author Arjen Poutsma
* @author Jamin Hitchcock
@@ -95,7 +95,8 @@ class Wss4jHandler extends WSHandler {
@Override
public String getPassword(Object msgContext) {
String contextPassword = (String) getProperty(msgContext, SECUREMENT_PASSWORD_PROPERTY_NAME);
String contextPassword = (String) getProperty(msgContext,
Wss4jSecurityInterceptor.SECUREMENT_PASSWORD_PROPERTY_NAME);
if (StringUtils.hasLength(contextPassword)) {
return contextPassword;
}

View File

@@ -147,8 +147,14 @@ import org.springframework.ws.soap.security.wss4j2.callback.UsernameTokenPrincip
*/
public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor implements InitializingBean {
/**
* Property name for securement user.
*/
public static final String SECUREMENT_USER_PROPERTY_NAME = "Wss4jSecurityInterceptor.securementUser";
/**
* Property name for securement password.
*/
public static final String SECUREMENT_PASSWORD_PROPERTY_NAME = "Wss4jSecurityInterceptor.securementPassword";
private String securementActions;
@@ -419,13 +425,15 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
/**
* Sets the username for securement username token or/and the alias of the private key
* for securement signature
* for securement signature.
*/
public void setSecurementUsername(String securementUsername) {
this.securementUsername = securementUsername;
}
/** Sets the time to live on the outgoing message */
/**
* Sets the time to live on the outgoing message.
*/
public void setSecurementTimeToLive(int securementTimeToLive) {
if (securementTimeToLive <= 0) {
@@ -450,7 +458,9 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
this.samlCallbackHandler = samlCallbackHandler;
}
/** Sets the server-side time to live */
/**
* Sets the server-side time to live.
*/
public void setValidationTimeToLive(int validationTimeToLive) {
if (validationTimeToLive <= 0) {
@@ -491,12 +501,16 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
this.validationCallbackHandler = new CallbackHandlerChain(callbackHandler);
}
/** Sets the Crypto to use to decrypt incoming messages */
/**
* Sets the Crypto to use to decrypt incoming messages.
*/
public void setValidationDecryptionCrypto(Crypto decryptionCrypto) {
this.validationDecryptionCrypto = decryptionCrypto;
}
/** Sets the Crypto to use to verify the signature of incoming messages */
/**
* Sets the Crypto to use to verify the signature of incoming messages.
*/
public void setValidationSignatureCrypto(Crypto signatureCrypto) {
this.validationSignatureCrypto = signatureCrypto;
}
@@ -511,13 +525,15 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
this.enableSignatureConfirmation = enableSignatureConfirmation;
}
/** Sets if the generated timestamp header's precision is in milliseconds. */
/**
* Sets if the generated timestamp header's precision is in milliseconds.
*/
public void setTimestampPrecisionInMilliseconds(boolean timestampPrecisionInMilliseconds) {
this.handler.setOption(WSHandlerConstants.TIMESTAMP_PRECISION, timestampPrecisionInMilliseconds);
}
/**
* Sets whether timestamp verification is done with the server-side time to live
* Sets whether timestamp verification is done with the server-side time to live.
*/
public void setTimestampStrict(boolean timestampStrict) {
this.timestampStrict = timestampStrict;
@@ -817,9 +833,9 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl
@SuppressWarnings("unchecked")
private void updateContextWithResults(MessageContext messageContext, List<WSSecurityEngineResult> results) {
List<WSHandlerResult> handlerResults;
if ((handlerResults = (List<WSHandlerResult>) messageContext
.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
List<WSHandlerResult> handlerResults = (List<WSHandlerResult>) messageContext
.getProperty(WSHandlerConstants.RECV_RESULTS);
if (handlerResults == null) {
handlerResults = new ArrayList<>();
messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults);
}

View File

@@ -74,11 +74,11 @@ public class KeyStoreCallbackHandler extends AbstractWsPasswordCallbackHandler i
Key key;
try {
key = this.keyStore.getKey(id, this.symmetricKeyPassword != null ? this.symmetricKeyPassword
key = this.keyStore.getKey(id, (this.symmetricKeyPassword != null) ? this.symmetricKeyPassword
: this.privateKeyPassword.toCharArray());
}
catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) {
throw new IOException("Could not get key", e);
catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException ex) {
throw new IOException("Could not get key", ex);
}
callback.setKey(key.getEncoded());

View File

@@ -17,4 +17,4 @@
/**
* Caching support for X.509 client certificates.
*/
package org.springframework.ws.soap.security.x509.cache;
package org.springframework.ws.soap.security.x509.cache;

View File

@@ -17,4 +17,4 @@
/**
* X.509 client-certificate authentication support.
*/
package org.springframework.ws.soap.security.x509;
package org.springframework.ws.soap.security.x509;

View File

@@ -17,4 +17,4 @@
/**
* User details popular for X.509 client certificates.
*/
package org.springframework.ws.soap.security.x509.populator;
package org.springframework.ws.soap.security.x509.populator;