You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bu...@apache.org on 2020/02/27 18:20:10 UTC

[cxf] branch master updated (67643a4 -> 49a3be1)

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

buhhunyx pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 67643a4  CXF-8220: The tag http.status_code is always 200 in server side tracing span, no matter what situation
     new c598ecf  cxf-rt-rs-security-oauth: use MessageDigestUtils
     new 49a3be1  cxf-rt-transports-jms: update JMSUtil.createCorrelationId

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:
 .../oauth/provider/MD5SequenceGenerator.java         | 20 ++------------------
 .../org/apache/cxf/transport/jms/util/JMSUtil.java   | 12 +++---------
 .../security/oauth/MemoryOAuthDataProvider.java      |  4 +---
 3 files changed, 6 insertions(+), 30 deletions(-)


[cxf] 01/02: cxf-rt-rs-security-oauth: use MessageDigestUtils

Posted by bu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c598ecf38e4d796ffb35288de39827a609d035be
Author: Alexey Markevich <bu...@gmail.com>
AuthorDate: Thu Feb 27 20:57:05 2020 +0300

    cxf-rt-rs-security-oauth: use MessageDigestUtils
---
 .../oauth/provider/MD5SequenceGenerator.java         | 20 ++------------------
 .../security/oauth/MemoryOAuthDataProvider.java      |  4 +---
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/provider/MD5SequenceGenerator.java b/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/provider/MD5SequenceGenerator.java
index 0896988..5e5a192 100644
--- a/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/provider/MD5SequenceGenerator.java
+++ b/rt/rs/security/oauth-parent/oauth/src/main/java/org/apache/cxf/rs/security/oauth/provider/MD5SequenceGenerator.java
@@ -18,10 +18,8 @@
  */
 package org.apache.cxf.rs.security.oauth.provider;
 
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
 import net.oauth.OAuthException;
+import org.apache.cxf.rt.security.crypto.MessageDigestUtils;
 
 /**
  * The utility MD5 sequence generator which can be used for generating
@@ -33,20 +31,6 @@ public class MD5SequenceGenerator {
         if (input == null) {
             throw new OAuthException("You have to pass input to Token Generator");
         }
-
-        try {
-            MessageDigest algorithm = MessageDigest.getInstance("MD5");
-            algorithm.reset();
-            algorithm.update(input);
-            byte[] messageDigest = algorithm.digest();
-            StringBuilder hexString = new StringBuilder();
-            for (int i = 0; i < messageDigest.length; i++) {
-                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
-            }
-
-            return hexString.toString();
-        } catch (NoSuchAlgorithmException e) {
-            throw new OAuthException(e);
-        }
+        return MessageDigestUtils.generate(input, MessageDigestUtils.ALGO_MD5);
     }
 }
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth/MemoryOAuthDataProvider.java b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth/MemoryOAuthDataProvider.java
index 8bd17c3..2e57342 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth/MemoryOAuthDataProvider.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/oauth/MemoryOAuthDataProvider.java
@@ -155,13 +155,11 @@ public class MemoryOAuthDataProvider implements OAuthDataProvider {
     }
 
     protected String generateToken() throws OAuthServiceException {
-        String token;
         try {
-            token = tokenGenerator.generate(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
+            return tokenGenerator.generate(UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
         } catch (Exception e) {
             throw new OAuthServiceException("Unable to create token ", e.getCause());
         }
-        return token;
     }
 
     public void setClientAuthInfo(Map<String, Client> clientAuthInfo) {


[cxf] 02/02: cxf-rt-transports-jms: update JMSUtil.createCorrelationId

Posted by bu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 49a3be1484462eec124524805e7439906fb18a33
Author: Alexey Markevich <bu...@gmail.com>
AuthorDate: Thu Feb 27 21:18:41 2020 +0300

    cxf-rt-transports-jms: update JMSUtil.createCorrelationId
---
 .../main/java/org/apache/cxf/transport/jms/util/JMSUtil.java | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
index 2ac8c4d..a444199 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/util/JMSUtil.java
@@ -28,6 +28,7 @@ import javax.jms.ObjectMessage;
 import javax.jms.Queue;
 import javax.jms.Session;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.transport.jms.JMSConstants;
 
@@ -35,9 +36,6 @@ public final class JMSUtil {
 
     public static final String JMS_MESSAGE_CONSUMER = "jms_message_consumer";
     public static final String JMS_IGNORE_TIMEOUT = "jms_ignore_timeout";
-    private static final char[] CORRELATTION_ID_PADDING = {
-        '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'
-    };
 
     private JMSUtil() {
     }
@@ -95,12 +93,8 @@ public final class JMSUtil {
         return new RuntimeException(e.getMessage(), e);
     }
 
-    public static String createCorrelationId(final String prefix, long sequenceNUm) {
-        String index = Long.toHexString(sequenceNUm);
-        StringBuilder id = new StringBuilder(prefix);
-        id.append(CORRELATTION_ID_PADDING, 0, 16 - index.length());
-        id.append(index);
-        return id.toString();
+    public static String createCorrelationId(final String prefix, long sequenceNum) {
+        return prefix + StringUtils.toHexString(java.nio.ByteBuffer.allocate(Long.BYTES).putLong(sequenceNum).array());
     }
 
     /**