You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kw...@apache.org on 2016/10/31 17:14:27 UTC

svn commit: r1767334 - in /qpid/java/branches/6.1.x: ./ broker-core/src/main/java/org/apache/qpid/server/model/preferences/GenericPrincipal.java broker-core/src/test/java/org/apache/qpid/server/model/preferences/GenericPrincipalTest.java

Author: kwall
Date: Mon Oct 31 17:14:27 2016
New Revision: 1767334

URL: http://svn.apache.org/viewvc?rev=1767334&view=rev
Log:
QPID-7352: [Java Broker] Make parsing of GenericPrincipal more lenient and allow dashes in originType

Merged from trunk with command:

svn merge -c 1767332 ^/qpid/java/trunk

Modified:
    qpid/java/branches/6.1.x/   (props changed)
    qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/preferences/GenericPrincipal.java
    qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/model/preferences/GenericPrincipalTest.java

Propchange: qpid/java/branches/6.1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 31 17:14:27 2016
@@ -9,5 +9,5 @@
 /qpid/branches/java-broker-vhost-refactor/java:1493674-1494547
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/branches/qpid-2935/qpid/java:1061302-1072333
-/qpid/java/trunk:1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310
+/qpid/java/trunk:1766796-1766797,1766806,1767251,1767267-1767268,1767275,1767310,1767332
 /qpid/trunk/qpid:796646-796653

Modified: qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/preferences/GenericPrincipal.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/preferences/GenericPrincipal.java?rev=1767334&r1=1767333&r2=1767334&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/preferences/GenericPrincipal.java (original)
+++ qpid/java/branches/6.1.x/broker-core/src/main/java/org/apache/qpid/server/model/preferences/GenericPrincipal.java Mon Oct 31 17:14:27 2016
@@ -33,7 +33,7 @@ import org.apache.qpid.server.security.Q
 
 public class GenericPrincipal implements Principal
 {
-    private static final Pattern PATTERN = Pattern.compile("([a-zA-Z_0-9.%~-]+)@(\\w*)\\('([a-zA-Z_0-9.%~-]*)'\\)");
+    private static final Pattern PATTERN = Pattern.compile("([a-zA-Z_0-9.%~-]+)@([^('@]*)\\('([a-zA-Z_0-9.%~-]*)'\\)");
     public static final String UTF8 = StandardCharsets.UTF_8.name();
 
     private final String _name;

Modified: qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/model/preferences/GenericPrincipalTest.java
URL: http://svn.apache.org/viewvc/qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/model/preferences/GenericPrincipalTest.java?rev=1767334&r1=1767333&r2=1767334&view=diff
==============================================================================
--- qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/model/preferences/GenericPrincipalTest.java (original)
+++ qpid/java/branches/6.1.x/broker-core/src/test/java/org/apache/qpid/server/model/preferences/GenericPrincipalTest.java Mon Oct 31 17:14:27 2016
@@ -61,6 +61,17 @@ public class GenericPrincipalTest extend
         }
     }
 
+    public void testParseWithDash() throws Exception
+    {
+        String username = "user-name";
+        String originType = "origin-type";
+        String originName = "origin-name";
+        GenericPrincipal p = new GenericPrincipal(String.format("%s@%s('%s')", username, originType, originName));
+        assertEquals("unexpected principal name", username, p.getName());
+        assertEquals("unexpected origin type", originType, p.getOriginType());
+        assertEquals("unexpected origin name", originName, p.getOriginName());
+    }
+
     public void testRejectQuotes() throws Exception
     {
         final String usernameWithQuote = "_username'withQuote";
@@ -91,6 +102,41 @@ public class GenericPrincipalTest extend
         }
         catch (IllegalArgumentException e)
         {
+            // pass
+        }
+
+    }
+
+    public void testRejectParenthesis() throws Exception
+    {
+        final String usernameWithParenthesis = "username(withParenthesis";
+        final String originTypeWithParenthesis = "authType(withParenthesis";
+        final String originNameWithParenthesis = "authName(withParenthesis";
+        try
+        {
+            new GenericPrincipal(String.format("%s@%s('%s')", usernameWithParenthesis, _originType, _originName));
+            fail("GenericPricinpal should reject _username with parenthesis");
+        }
+        catch (IllegalArgumentException e)
+        {
+            // pass
+        }
+        try
+        {
+            new GenericPrincipal(String.format("%s@%s('%s')", _username, originTypeWithParenthesis, _originName));
+            fail("GenericPricinpal should reject origin type with parenthesis");
+        }
+        catch (IllegalArgumentException e)
+        {
+            // pass
+        }
+        try
+        {
+            new GenericPrincipal(String.format("%s@%s('%s')", _username, _originType, originNameWithParenthesis));
+            fail("GenericPricinpal should reject origin name with parenthesis");
+        }
+        catch (IllegalArgumentException e)
+        {
             // pass
         }
 



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