You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/04/19 18:55:19 UTC

svn commit: r1739961 - /qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java

Author: orudyy
Date: Tue Apr 19 16:55:19 2016
New Revision: 1739961

URL: http://svn.apache.org/viewvc?rev=1739961&view=rev
Log:
QPID-7174: Add base64 encoding detection into certificate value converter

Modified:
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java?rev=1739961&r1=1739960&r2=1739961&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java (original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/AttributeValueConverter.java Tue Apr 19 16:55:19 2016
@@ -45,6 +45,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.regex.Pattern;
 
 import javax.xml.bind.DatatypeConverter;
 
@@ -169,7 +170,7 @@ abstract class AttributeValueConverter<T
         }
     };
 
-    public static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----";
+    public static final Pattern BASE64_PATTERN = Pattern.compile("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$");
 
     static final AttributeValueConverter<Certificate> CERTIFICATE_CONVERTER = new AttributeValueConverter<Certificate>()
     {
@@ -207,14 +208,14 @@ abstract class AttributeValueConverter<T
             else if(value instanceof String)
             {
                 String strValue = AbstractConfiguredObject.interpolate(object, (String) value);
-                if (strValue.startsWith(BEGIN_CERTIFICATE))
+                if (BASE64_PATTERN.matcher(strValue).matches())
                 {
-                    return convert(strValue.getBytes(StandardCharsets.UTF_8), object);
+                    byte[] certificateBytes = BINARY_CONVERTER.convert(strValue, object);
+                    return convert(certificateBytes, object);
                 }
                 else
                 {
-                    byte[] certificateBytes = BINARY_CONVERTER.convert(strValue, object);
-                    return convert(certificateBytes, object);
+                    return convert(strValue.getBytes(StandardCharsets.UTF_8), object);
                 }
             }
             else if(value == null)



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org