servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1348718 - in /servicemix/smx4/nmr/trunk/nmr/core/src: main/java/org/apache/servicemix/nmr/core/ main/java/org/apache/servicemix/nmr/core/security/ test/java/org/apache/servicemix/nmr/core/security/
Date Mon, 11 Jun 2012 04:05:27 GMT
Author: ffang
Date: Mon Jun 11 04:05:27 2012
New Revision: 1348718

URL: http://svn.apache.org/viewvc?rev=1348718&view=rev
Log:
[SMX4NMR-291]NMR FlowRegistryImpl should use endpoint name but not a UUID to retrieve related
AuthorizationEntry

Modified:
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java
    servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationServiceTest.java

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java?rev=1348718&r1=1348717&r2=1348718&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
(original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/FlowRegistryImpl.java
Mon Jun 11 04:05:27 2012
@@ -90,7 +90,13 @@ public class FlowRegistryImpl extends Se
                     }
                     match = true;
                     if (authorizationService != null) {
-                        Set<GroupPrincipal> acls = authorizationService.getAcls(endpoint.getId(),
exchange.getOperation());
+                    	String endpointName = (String) endpoint.getMetaData().get(Endpoint.ENDPOINT_NAME);
+                    	String uniqueName = endpoint.getId();
+                    	if (endpointName != null && endpointName.length() != 0) {
+                    		uniqueName = uniqueName + "|" + endpointName;  
+                    	}
+                        Set<GroupPrincipal> acls = authorizationService.getAcls(uniqueName,

+                        		exchange.getOperation());
                         if (!acls.contains(GroupPrincipal.ANY)) {
                             Subject subject = exchange.getIn().getSecuritySubject();
                             if (subject == null) {

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java?rev=1348718&r1=1348717&r2=1348718&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java
(original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationService.java
Mon Jun 11 04:05:27 2012
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Map;
+import java.util.StringTokenizer;
 import java.util.WeakHashMap;
 import java.util.regex.Pattern;
 
@@ -70,7 +71,12 @@ public class DefaultAuthorizationService
     }
 
     public Set<GroupPrincipal> getAcls(String endpoint, QName operation) {
-        String key = endpoint + "|" + (operation != null ? operation.toString() : "");
+    	StringTokenizer token = new StringTokenizer(endpoint, "|");
+    	endpoint = token.nextToken();
+    	String key = endpoint + "|" + (operation != null ? operation.toString() : "");
+        if (token.hasMoreTokens()) {
+        	endpoint = token.nextToken();
+        }
         Set<GroupPrincipal> acls = cache.get(key);
         if (acls == null) {
             acls = new HashSet<GroupPrincipal>();

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationServiceTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationServiceTest.java?rev=1348718&r1=1348717&r2=1348718&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationServiceTest.java
(original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/security/DefaultAuthorizationServiceTest.java
Mon Jun 11 04:05:27 2012
@@ -23,6 +23,7 @@ import javax.xml.namespace.QName;
 import junit.framework.TestCase;
 import org.apache.servicemix.nmr.api.security.AuthorizationEntry;
 import org.apache.servicemix.nmr.api.security.GroupPrincipal;
+import org.apache.servicemix.nmr.core.util.UuidGenerator;
 
 public class DefaultAuthorizationServiceTest extends TestCase {
 
@@ -36,7 +37,7 @@ public class DefaultAuthorizationService
         addEntry("*", null, "*", AuthorizationEntry.Type.Add);
         addEntry("ep1", null, "role1", AuthorizationEntry.Type.Set);
 
-        Set<GroupPrincipal> acls = service.getAcls("ep1", null);
+        Set<GroupPrincipal> acls = service.getAcls(UuidGenerator.getUUID() + "|ep1",
null);
         assertNotNull(acls);
         assertEquals(1, acls.size());
         assertTrue(acls.contains(new GroupPrincipal("role1")));



Mime
View raw message