You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2024/01/25 14:30:29 UTC
(ws-wss4j) 02/02: Fix for JDK11 compilation
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3_0_x-fixes
in repository https://gitbox.apache.org/repos/asf/ws-wss4j.git
commit 394eba9db7d4c2890c328364bbccf8c7235bd650
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Thu Jan 25 14:30:09 2024 +0000
Fix for JDK11 compilation
---
.../common/crypto/AlgorithmSuiteValidator.java | 23 +++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/AlgorithmSuiteValidator.java b/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/AlgorithmSuiteValidator.java
index d193819fc..923ea7c37 100644
--- a/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/AlgorithmSuiteValidator.java
+++ b/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/AlgorithmSuiteValidator.java
@@ -250,7 +250,7 @@ public class AlgorithmSuiteValidator {
* @return the key length in bits
* @throws WSSecurityException if the key is not EdEC or XDH or if length can not be determined
*/
- private int getEdECndXDHKeyLength(PublicKey publicKey) throws WSSecurityException {
+ private int getEdECndXDHKeyLength(PublicKey publicKey) throws WSSecurityException {
String keyAlgorithmOId;
try {
keyAlgorithmOId = DERDecoderUtils.getAlgorithmIdFromPublicKey(publicKey);
@@ -264,16 +264,17 @@ public class AlgorithmSuiteValidator {
throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
}
- return switch (keyType) {
- case ED25519, X25519 -> 256;
- case ED448, X448 -> 456;
- default -> {
- LOG.warn(
- "An unknown public key was provided"
- );
- throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
- }
- };
+ int keyLength;
+ if (keyType == KeyUtils.KeyType.ED25519 || keyType == KeyUtils.KeyType.X25519) {
+ keyLength = 256;
+ } else if (keyType == KeyUtils.KeyType.ED448 || keyType == KeyUtils.KeyType.X448) {
+ keyLength = 456;
+ } else {
+ LOG.warn("An unknown public key was provided");
+ throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
+ }
+
+ return keyLength;
}
/**