[cxf] branch dependabot/maven/cxf.aspectj.version-1.9.20 created (now 279880851c)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/cxf.aspectj.version-1.9.20 in repository https://gitbox.apache.org/repos/asf/cxf.git at 279880851c Bump cxf.aspectj.version from 1.9.19 to 1.9.20 No new revisions were added by this update.
[cxf] branch 3.6.x-fixes updated (8556309856 -> fe6a12297b)
This is an automated email from the ASF dual-hosted git repository. reta pushed a change to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git from 8556309856 [CXF-8837] Avoid instanceof checking completely (#1386) new f614f30bc9 CXF-8872: Get rid of EasyMock in cxf-rt-rs-security-oauth2 (#1369) new fe6a12297b Recording .gitmergeinfo Changes The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .gitmergeinfo | 3 +++ rt/rs/security/oauth-parent/oauth2/pom.xml | 5 +++-- .../oauth2/client/OAuthClientUtilsTest.java| 20 ++- .../oauth2/grants/jwt/AbstractJwtHandlerTest.java | 19 +++--- .../tokens/hawk/HawkAccessTokenValidatorTest.java | 23 +++--- .../oauth2/tokens/hawk/NonceVerifierImplTest.java | 15 ++ 6 files changed, 36 insertions(+), 49 deletions(-)
[cxf] 01/02: CXF-8872: Get rid of EasyMock in cxf-rt-rs-security-oauth2 (#1369)
This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git commit f614f30bc9f1570e55c5f395e4698b7d5b2c102e Author: Andriy Redko AuthorDate: Wed Aug 16 16:23:32 2023 -0400 CXF-8872: Get rid of EasyMock in cxf-rt-rs-security-oauth2 (#1369) (cherry picked from commit d77449d78c6aa0b110b0f4c326ed78dc628ed101) --- rt/rs/security/oauth-parent/oauth2/pom.xml | 5 +++-- .../oauth2/client/OAuthClientUtilsTest.java| 20 ++- .../oauth2/grants/jwt/AbstractJwtHandlerTest.java | 19 +++--- .../tokens/hawk/HawkAccessTokenValidatorTest.java | 23 +++--- .../oauth2/tokens/hawk/NonceVerifierImplTest.java | 15 ++ 5 files changed, 33 insertions(+), 49 deletions(-) diff --git a/rt/rs/security/oauth-parent/oauth2/pom.xml b/rt/rs/security/oauth-parent/oauth2/pom.xml index a3375c7123..24f4b25ef9 100644 --- a/rt/rs/security/oauth-parent/oauth2/pom.xml +++ b/rt/rs/security/oauth-parent/oauth2/pom.xml @@ -93,8 +93,9 @@ test - org.easymock - easymock + org.mockito + mockito-core + ${cxf.mockito.version} test diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java index a35ae24497..67295cd741 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java +++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java @@ -37,14 +37,12 @@ import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; import org.junit.Test; -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.mock; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class OAuthClientUtilsTest { @@ -53,32 +51,26 @@ public class OAuthClientUtilsTest { WebClient accessTokenService = mock(WebClient.class); String tokenKey = "tokenKey"; String response = "{\"" + OAuthConstants.ACCESS_TOKEN + "\":\"" + tokenKey + "\"}"; -expect(accessTokenService.form(anyObject(Form.class))).andReturn( +when(accessTokenService.form(any(Form.class))).thenReturn( Response.ok(new ByteArrayInputStream(response.getBytes()), MediaType.APPLICATION_JSON).build()); -replay(accessTokenService); ClientAccessToken cat = OAuthClientUtils.getAccessToken(accessTokenService, null, new RefreshTokenGrant(""), null, "defaultTokenType", false); assertEquals(tokenKey, cat.getTokenKey()); - -verify(accessTokenService); } @Test public void getAccessTokenInternalServerError() { WebClient accessTokenService = mock(WebClient.class); -expect(accessTokenService.form(anyObject(Form.class))) -.andReturn(Response.serverError().type(MediaType.TEXT_PLAIN) +when(accessTokenService.form(any(Form.class))) +.thenReturn(Response.serverError().type(MediaType.TEXT_PLAIN) .entity(new ByteArrayInputStream("Unrecoverable error in the server.".getBytes())).build()); -replay(accessTokenService); try { OAuthClientUtils.getAccessToken(accessTokenService, null, new RefreshTokenGrant(""), null, null, false); fail(); } catch (OAuthServiceException e) { assertEquals(OAuthConstants.SERVER_ERROR, e.getMessage()); -} finally { -verify(accessTokenService); } } diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java index 77681c24f5..1c940c665a 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java +++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java @@ -28,23 +28,22 @@ import org.apache.cxf.rs.security.oauth2.common.Client; import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken; import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException; -import org.easymock.EasyMockRule; -import
[cxf] 02/02: Recording .gitmergeinfo Changes
This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git commit fe6a12297b48e818c3bf5c665b1a283d320ca569 Author: Andriy Redko AuthorDate: Wed Aug 16 20:47:33 2023 -0400 Recording .gitmergeinfo Changes --- .gitmergeinfo | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitmergeinfo b/.gitmergeinfo index e9c705f96f..4130c934de 100644 --- a/.gitmergeinfo +++ b/.gitmergeinfo @@ -252,6 +252,7 @@ M 2534e01ee84f47d5fd75af56c811b041d24b5234 M 254586ce54966d15dffd9933f76c6d7581142c18 M 27813a0523e1b4ab7cccd980ef63d7249627f4e8 M 278431e8adc631b7089f979d455fc54a721c7ab0 +M 27c684af98a2cc3e6a530a19aee5b1412df9eab1 M 27f756d64a3267c0865d6498824bd9c32b959391 M 28299173fd75fc86823cd6517bc2893aff1ecb32 M 285c671de7cc1a3edf9de481cdd5d58e01cb5e7a @@ -472,6 +473,7 @@ M 9ede4a76d78ffe913c593607ed28d523ba548ba3 M 9fdf22dfd1ed21a776d935754f1dd02aef67ce95 M a25da60afef8051cab6b8b0a733346dad718f65a M a293a80333443ac39c960aea695e65fc260d8bdd +M a2b22ff1cb5e3d00ece68733ca8d72b67fd023d6 M a2d821e682a7c48e7ef1784a0da6218bee003cd1 M a2e3ce536bc9403895c18a7322e78555e1f44bf6 M a43799c83305ad33905d757011cb9c7cce4ee6b3 @@ -621,6 +623,7 @@ M ec9a65c12886611620d06a402f85d98e7936d66d M ed102a26c22b5376ace2951d508485457f1f606b M edea785abd33bbc363bb3a9af926a1dbf7956cd1 M ee165a313d3f629d3de863d758554eabbe26f8b7 +M eefbb64995c59fea459ee7e2fe324831ebcc10c3 M f00ca03f0852b8be195adbcee20c164a189e8b6e M f03c3b0f9dccf7ebec8e1016247091cb363344ea M f05bdcfeafebdbe93c6d189514e084ae1d40cac0
[cxf] branch main updated: CXF-8872: Get rid of EasyMock in cxf-rt-rs-security-oauth2 (#1369)
This is an automated email from the ASF dual-hosted git repository. reta 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 d77449d78c CXF-8872: Get rid of EasyMock in cxf-rt-rs-security-oauth2 (#1369) d77449d78c is described below commit d77449d78c6aa0b110b0f4c326ed78dc628ed101 Author: Andriy Redko AuthorDate: Wed Aug 16 16:23:32 2023 -0400 CXF-8872: Get rid of EasyMock in cxf-rt-rs-security-oauth2 (#1369) --- rt/rs/security/oauth-parent/oauth2/pom.xml | 5 +++-- .../oauth2/client/OAuthClientUtilsTest.java| 20 ++- .../oauth2/grants/jwt/AbstractJwtHandlerTest.java | 19 +++--- .../tokens/hawk/HawkAccessTokenValidatorTest.java | 23 +++--- .../oauth2/tokens/hawk/NonceVerifierImplTest.java | 15 ++ 5 files changed, 33 insertions(+), 49 deletions(-) diff --git a/rt/rs/security/oauth-parent/oauth2/pom.xml b/rt/rs/security/oauth-parent/oauth2/pom.xml index 58021d27bc..bc6f17d619 100644 --- a/rt/rs/security/oauth-parent/oauth2/pom.xml +++ b/rt/rs/security/oauth-parent/oauth2/pom.xml @@ -93,8 +93,9 @@ test - org.easymock - easymock + org.mockito + mockito-core + ${cxf.mockito.version} test diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java index 018a266073..d481317069 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java +++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/client/OAuthClientUtilsTest.java @@ -36,14 +36,12 @@ import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; import org.junit.Test; -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.mock; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class OAuthClientUtilsTest { @@ -52,32 +50,26 @@ public class OAuthClientUtilsTest { WebClient accessTokenService = mock(WebClient.class); String tokenKey = "tokenKey"; String response = "{\"" + OAuthConstants.ACCESS_TOKEN + "\":\"" + tokenKey + "\"}"; -expect(accessTokenService.form(anyObject(Form.class))).andReturn( +when(accessTokenService.form(any(Form.class))).thenReturn( Response.ok(new ByteArrayInputStream(response.getBytes()), MediaType.APPLICATION_JSON).build()); -replay(accessTokenService); ClientAccessToken cat = OAuthClientUtils.getAccessToken(accessTokenService, null, new RefreshTokenGrant(""), null, "defaultTokenType", false); assertEquals(tokenKey, cat.getTokenKey()); - -verify(accessTokenService); } @Test public void getAccessTokenInternalServerError() { WebClient accessTokenService = mock(WebClient.class); -expect(accessTokenService.form(anyObject(Form.class))) -.andReturn(Response.serverError().type(MediaType.TEXT_PLAIN) +when(accessTokenService.form(any(Form.class))) +.thenReturn(Response.serverError().type(MediaType.TEXT_PLAIN) .entity(new ByteArrayInputStream("Unrecoverable error in the server.".getBytes())).build()); -replay(accessTokenService); try { OAuthClientUtils.getAccessToken(accessTokenService, null, new RefreshTokenGrant(""), null, null, false); fail(); } catch (OAuthServiceException e) { assertEquals(OAuthConstants.SERVER_ERROR, e.getMessage()); -} finally { -verify(accessTokenService); } } diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java index 39aa8bb77c..a3579c419c 100644 --- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java +++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/jwt/AbstractJwtHandlerTest.java @@ -27,23 +27,22 @@ import org.apache.cxf.rs.security.oauth2.common.Client; import org.apache.cxf.rs.security.oauth2.common.ServerAccessToken; import
[cxf] branch 3.5.x-fixes updated: [CXF-8837] Avoid instanceof checking completely (#1386)
This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch 3.5.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git The following commit(s) were added to refs/heads/3.5.x-fixes by this push: new 4020f56568 [CXF-8837] Avoid instanceof checking completely (#1386) 4020f56568 is described below commit 4020f56568376e0170063c35bff00ccb2e01d6f8 Author: Jan Bernhardt AuthorDate: Wed Aug 16 15:36:44 2023 +0200 [CXF-8837] Avoid instanceof checking completely (#1386) (cherry picked from commit c23bb8b176f5da88bced93a7eb1cc1a13ec1c72b) (cherry picked from commit 85563098562d3eb51033f2f3615b8688a496a8a8) --- .../apache/cxf/rs/security/jose/jws/JwsUtils.java | 108 +++-- 1 file changed, 76 insertions(+), 32 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 a3699acee4..f9155bf352 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 @@ -23,10 +23,7 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.security.cert.X509Certificate; import java.security.interfaces.ECPrivateKey; -import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAKey; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -58,57 +55,71 @@ public final class JwsUtils { private static final Logger LOG = LogUtils.getL7dLogger(JwsUtils.class); private JwsUtils() { - } + public static String sign(PrivateKey key, SignatureAlgorithm algo, String content) { return sign(key, algo, content, null); } - public static String sign(PrivateKey key, SignatureAlgorithm algo, String content, String ct) { return sign(getPrivateKeySignatureProvider(key, algo), content, ct); } + public static String sign(String encodedKey, SignatureAlgorithm algo, String content) { return sign(JoseUtils.decode(encodedKey), algo, content); } + public static String sign(byte[] key, SignatureAlgorithm algo, String content) { return sign(key, algo, content, null); } + public static String sign(byte[] key, SignatureAlgorithm algo, String content, String ct) { return sign(getHmacSignatureProvider(key, algo), content, ct); } + public static String verify(PublicKey key, SignatureAlgorithm algo, String content) { JwsCompactConsumer jws = verify(getPublicKeySignatureVerifier(key, algo), content); return jws.getDecodedJwsPayload(); } + public static String verify(String encodedKey, SignatureAlgorithm algo, String content) { return verify(JoseUtils.decode(encodedKey), algo, content); } + public static String verify(byte[] key, SignatureAlgorithm algo, String content) { JwsCompactConsumer jws = verify(getHmacSignatureVerifier(key, algo), content); return jws.getDecodedJwsPayload(); } + public static JwsSignatureProvider getSignatureProvider(JsonWebKey jwk) { return getSignatureProvider(jwk, null); } + public static JwsSignatureProvider getSignatureProvider(JsonWebKey jwk, SignatureAlgorithm defaultAlgorithm) { SignatureAlgorithm sigAlgo = jwk.getAlgorithm() == null ? defaultAlgorithm : SignatureAlgorithm.getAlgorithm(jwk.getAlgorithm()); JwsSignatureProvider theSigProvider = null; KeyType keyType = jwk.getKeyType(); -if (KeyType.RSA == keyType) { -theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toRSAPrivateKey(jwk), -sigAlgo); -} else if (KeyType.OCTET == keyType) { -byte[] key = JoseUtils.decode((String)jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE)); -theSigProvider = getHmacSignatureProvider(key, sigAlgo); -} else if (KeyType.EC == jwk.getKeyType()) { -theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toECPrivateKey(jwk), -sigAlgo); +if (keyType != null) { +switch (keyType) { +case RSA: +theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toRSAPrivateKey(jwk), sigAlgo); +break; +case OCTET: +byte[] key = JoseUtils.decode((String)jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE)); +theSigProvider = getHmacSignatureProvider(key, sigAlgo); +break;
[cxf] branch 3.6.x-fixes updated: [CXF-8837] Avoid instanceof checking completely (#1386)
This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git The following commit(s) were added to refs/heads/3.6.x-fixes by this push: new 8556309856 [CXF-8837] Avoid instanceof checking completely (#1386) 8556309856 is described below commit 85563098562d3eb51033f2f3615b8688a496a8a8 Author: Jan Bernhardt AuthorDate: Wed Aug 16 15:36:44 2023 +0200 [CXF-8837] Avoid instanceof checking completely (#1386) (cherry picked from commit c23bb8b176f5da88bced93a7eb1cc1a13ec1c72b) --- .../apache/cxf/rs/security/jose/jws/JwsUtils.java | 108 +++-- 1 file changed, 76 insertions(+), 32 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 a3699acee4..f9155bf352 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 @@ -23,10 +23,7 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.security.cert.X509Certificate; import java.security.interfaces.ECPrivateKey; -import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAKey; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -58,57 +55,71 @@ public final class JwsUtils { private static final Logger LOG = LogUtils.getL7dLogger(JwsUtils.class); private JwsUtils() { - } + public static String sign(PrivateKey key, SignatureAlgorithm algo, String content) { return sign(key, algo, content, null); } - public static String sign(PrivateKey key, SignatureAlgorithm algo, String content, String ct) { return sign(getPrivateKeySignatureProvider(key, algo), content, ct); } + public static String sign(String encodedKey, SignatureAlgorithm algo, String content) { return sign(JoseUtils.decode(encodedKey), algo, content); } + public static String sign(byte[] key, SignatureAlgorithm algo, String content) { return sign(key, algo, content, null); } + public static String sign(byte[] key, SignatureAlgorithm algo, String content, String ct) { return sign(getHmacSignatureProvider(key, algo), content, ct); } + public static String verify(PublicKey key, SignatureAlgorithm algo, String content) { JwsCompactConsumer jws = verify(getPublicKeySignatureVerifier(key, algo), content); return jws.getDecodedJwsPayload(); } + public static String verify(String encodedKey, SignatureAlgorithm algo, String content) { return verify(JoseUtils.decode(encodedKey), algo, content); } + public static String verify(byte[] key, SignatureAlgorithm algo, String content) { JwsCompactConsumer jws = verify(getHmacSignatureVerifier(key, algo), content); return jws.getDecodedJwsPayload(); } + public static JwsSignatureProvider getSignatureProvider(JsonWebKey jwk) { return getSignatureProvider(jwk, null); } + public static JwsSignatureProvider getSignatureProvider(JsonWebKey jwk, SignatureAlgorithm defaultAlgorithm) { SignatureAlgorithm sigAlgo = jwk.getAlgorithm() == null ? defaultAlgorithm : SignatureAlgorithm.getAlgorithm(jwk.getAlgorithm()); JwsSignatureProvider theSigProvider = null; KeyType keyType = jwk.getKeyType(); -if (KeyType.RSA == keyType) { -theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toRSAPrivateKey(jwk), -sigAlgo); -} else if (KeyType.OCTET == keyType) { -byte[] key = JoseUtils.decode((String)jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE)); -theSigProvider = getHmacSignatureProvider(key, sigAlgo); -} else if (KeyType.EC == jwk.getKeyType()) { -theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toECPrivateKey(jwk), -sigAlgo); +if (keyType != null) { +switch (keyType) { +case RSA: +theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toRSAPrivateKey(jwk), sigAlgo); +break; +case OCTET: +byte[] key = JoseUtils.decode((String)jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE)); +theSigProvider = getHmacSignatureProvider(key, sigAlgo); +break; +case EC: +theSigProvider =
[cxf] branch main updated: [CXF-8837] Avoid instanceof checking completely (#1386)
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 c23bb8b176 [CXF-8837] Avoid instanceof checking completely (#1386) c23bb8b176 is described below commit c23bb8b176f5da88bced93a7eb1cc1a13ec1c72b Author: Jan Bernhardt AuthorDate: Wed Aug 16 15:36:44 2023 +0200 [CXF-8837] Avoid instanceof checking completely (#1386) --- .../apache/cxf/rs/security/jose/jws/JwsUtils.java | 108 +++-- 1 file changed, 76 insertions(+), 32 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 a3699acee4..f9155bf352 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 @@ -23,10 +23,7 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.security.cert.X509Certificate; import java.security.interfaces.ECPrivateKey; -import java.security.interfaces.ECPublicKey; import java.security.interfaces.RSAKey; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -58,57 +55,71 @@ public final class JwsUtils { private static final Logger LOG = LogUtils.getL7dLogger(JwsUtils.class); private JwsUtils() { - } + public static String sign(PrivateKey key, SignatureAlgorithm algo, String content) { return sign(key, algo, content, null); } - public static String sign(PrivateKey key, SignatureAlgorithm algo, String content, String ct) { return sign(getPrivateKeySignatureProvider(key, algo), content, ct); } + public static String sign(String encodedKey, SignatureAlgorithm algo, String content) { return sign(JoseUtils.decode(encodedKey), algo, content); } + public static String sign(byte[] key, SignatureAlgorithm algo, String content) { return sign(key, algo, content, null); } + public static String sign(byte[] key, SignatureAlgorithm algo, String content, String ct) { return sign(getHmacSignatureProvider(key, algo), content, ct); } + public static String verify(PublicKey key, SignatureAlgorithm algo, String content) { JwsCompactConsumer jws = verify(getPublicKeySignatureVerifier(key, algo), content); return jws.getDecodedJwsPayload(); } + public static String verify(String encodedKey, SignatureAlgorithm algo, String content) { return verify(JoseUtils.decode(encodedKey), algo, content); } + public static String verify(byte[] key, SignatureAlgorithm algo, String content) { JwsCompactConsumer jws = verify(getHmacSignatureVerifier(key, algo), content); return jws.getDecodedJwsPayload(); } + public static JwsSignatureProvider getSignatureProvider(JsonWebKey jwk) { return getSignatureProvider(jwk, null); } + public static JwsSignatureProvider getSignatureProvider(JsonWebKey jwk, SignatureAlgorithm defaultAlgorithm) { SignatureAlgorithm sigAlgo = jwk.getAlgorithm() == null ? defaultAlgorithm : SignatureAlgorithm.getAlgorithm(jwk.getAlgorithm()); JwsSignatureProvider theSigProvider = null; KeyType keyType = jwk.getKeyType(); -if (KeyType.RSA == keyType) { -theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toRSAPrivateKey(jwk), -sigAlgo); -} else if (KeyType.OCTET == keyType) { -byte[] key = JoseUtils.decode((String)jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE)); -theSigProvider = getHmacSignatureProvider(key, sigAlgo); -} else if (KeyType.EC == jwk.getKeyType()) { -theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toECPrivateKey(jwk), -sigAlgo); +if (keyType != null) { +switch (keyType) { +case RSA: +theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toRSAPrivateKey(jwk), sigAlgo); +break; +case OCTET: +byte[] key = JoseUtils.decode((String)jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE)); +theSigProvider = getHmacSignatureProvider(key, sigAlgo); +break; +case EC: +theSigProvider = getPrivateKeySignatureProvider(JwkUtils.toECPrivateKey(jwk), sigAlgo); +break; +
[cxf] branch 3.5.x-fixes updated (37da95cd82 -> 9eba9301fe)
This is an automated email from the ASF dual-hosted git repository. reta pushed a change to branch 3.5.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git from 37da95cd82 Recording .gitmergeinfo Changes new 9ae2101fe9 Update Project Reactor to 3.4.32 new 9eba9301fe Recording .gitmergeinfo Changes The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .gitmergeinfo | 3 +++ parent/pom.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
[cxf] 01/02: Update Project Reactor to 3.4.32
This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.5.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git commit 9ae2101fe9fdfc8f85000e03b47495d2db744c07 Author: Andriy Redko AuthorDate: Wed Aug 16 09:26:26 2023 -0400 Update Project Reactor to 3.4.32 --- parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent/pom.xml b/parent/pom.xml index c142031f67..76d01886f3 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -192,7 +192,7 @@ 4.8.0 3.5.1 1.0.4 -3.4.31 +3.4.32 1.7.14 1.3.8 2.2.21
[cxf] 02/02: Recording .gitmergeinfo Changes
This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.5.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git commit 9eba9301fe16dfa366e55b82d94b7362957f8c37 Author: Andriy Redko AuthorDate: Wed Aug 16 09:26:58 2023 -0400 Recording .gitmergeinfo Changes --- .gitmergeinfo | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitmergeinfo b/.gitmergeinfo index 39c486f397..c881dd7fdb 100644 --- a/.gitmergeinfo +++ b/.gitmergeinfo @@ -24,6 +24,7 @@ B 10c14830cf25e286917af9dd6f4da67af012dda5 B 1279d3d05b2533365b8e98b0bf211f1424e3f712 B 12a68910220a3af6fe2d0419a3556320b75c3523 B 12b4e3a4d9d2f3d8cc380e998b9e44f43e2a8479 +B 12e00db455819ed1905d093ee4c3fa82a14ea89f B 137df3a5340e0f940ef7e5634468414fdcde4664 B 14fde35cbb22f301217be8e1b56ef405eab70682 B 163b3fe30093c41d605c84df76867a89c5c45443 @@ -400,6 +401,7 @@ M 444f5fd0657b51be9899f5c7949d29705c6dfba5 M 485413b2c2f0f57e13ab4b91940334a5a3bebc01 M 4a28f6cb1c9451dc7bcb62324f19d9c5af216040 M 4aa61e9f22fb328c9f67c60ff20cc5a57be680b8 +M 4b14e146b096e09111e828c132c45ee5ea3e8f40 M 4b51a9540867466a4e966df9f6e15387919da7bc M 4e25650e84daa3293ce20c65b572b8f7de05c8a8 M 4ef710250f5bb21bbcd3c5fd672543b06c1acb73 @@ -433,6 +435,7 @@ M 62cb388e44976da22a5beba8791cc331abcb867a M 62d728e7acdfc213eb461daf4dfb020855b2eb36 M 6492db36e2a282e334e0b5304c1c8348ead826a2 M 656c9459ae97e56039a77e581122e56699ea2127 +M 658738f5a8fe85057a6d48ca4f3a49b172b1f9e4 M 659a083f2ff7e20df40f4e92e3aa2fed93b54ffc M 6618c5404b2a84ae9e40180dffbf90061026dc62 M 66afbe72d25741389d362bfb0c8bec9f5dbb5ee4
[cxf] branch dependabot/maven/org.jboss.arquillian.testng-arquillian-testng-container-1.7.1.Final deleted (was e7752e925b)
This is an automated email from the ASF dual-hosted git repository. github-bot pushed a change to branch dependabot/maven/org.jboss.arquillian.testng-arquillian-testng-container-1.7.1.Final in repository https://gitbox.apache.org/repos/asf/cxf.git was e7752e925b Bump org.jboss.arquillian.testng:arquillian-testng-container The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
[cxf] branch main updated (d35056c92f -> a2b22ff1cb)
This is an automated email from the ASF dual-hosted git repository. reta pushed a change to branch main in repository https://gitbox.apache.org/repos/asf/cxf.git from d35056c92f Update Project Reactor to 3.5.9 add eefbb64995 Update Arquillian to 1.7.1.Final add 27c684af98 Update Apache Tomcat to 10.1.12 add a2b22ff1cb Remove --add-opens java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED command line option No new revisions were added by this update. Summary of changes: distribution/src/main/release/samples/pom.xml | 2 +- parent/pom.xml| 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)