This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new 5de5c79b4b [CXF-8837] check algorithm instead of class instance type 
(#1239)
5de5c79b4b is described below

commit 5de5c79b4b969105893f05adf50dd1ecf4dc0470
Author: Jan Bernhardt <[email protected]>
AuthorDate: Wed Apr 19 09:00:06 2023 +0200

    [CXF-8837] check algorithm instead of class instance type (#1239)
---
 .../java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java     | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
 
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
index cf45d0603f..a3699acee4 100644
--- 
a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
+++ 
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
@@ -114,12 +114,12 @@ public final class JwsUtils {
             LOG.warning("No signature algorithm was defined");
             throw new JwsException(JwsException.Error.ALGORITHM_NOT_SET);
         }
-        if (key instanceof ECPrivateKey) {
+        if (JsonWebKey.KEY_TYPE_ELLIPTIC.equals(key.getAlgorithm())) {
             return new EcDsaJwsSignatureProvider((ECPrivateKey)key, algo);
-        } else if (key instanceof RSAPrivateKey) {
+        } else if (JsonWebKey.KEY_TYPE_RSA.equals(key.getAlgorithm())) {
             return new PrivateKeyJwsSignatureProvider(key, algo);
         }
-
+        
         return null;
     }
     public static JwsSignatureProvider getHmacSignatureProvider(String 
encodedKey, SignatureAlgorithm algo) {
@@ -178,9 +178,9 @@ public final class JwsUtils {
             throw new JwsException(JwsException.Error.ALGORITHM_NOT_SET);
         }
 
-        if (key instanceof RSAPublicKey) {
+        if (JsonWebKey.KEY_TYPE_RSA.equals(key.getAlgorithm())) {
             return new PublicKeyJwsSignatureVerifier(key, algo);
-        } else if (key instanceof ECPublicKey) {
+        } else if (JsonWebKey.KEY_TYPE_ELLIPTIC.equals(key.getAlgorithm())) {
             return new EcDsaJwsSignatureVerifier(key, algo);
         }
 

Reply via email to