cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r933721 - in /cxf/branches/2.2.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/interceptor/security/ rt/core/src/test/java/org/apache/cxf/interceptor/security/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/ rt/ws/security/s...
Date Tue, 13 Apr 2010 17:57:07 GMT
Author: sergeyb
Date: Tue Apr 13 17:57:07 2010
New Revision: 933721

URL: http://svn.apache.org/viewvc?rev=933721&view=rev
Log:
Merged revisions 933716 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r933716 | sergeyb | 2010-04-13 18:41:12 +0100 (Tue, 13 Apr 2010) | 1 line
  
  CXF-2754,CXF-2755: simplifying the way SimpleAuthorizingInterceptor can be configured
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
    cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
    cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JSecurityContextProvidingInterceptor.java
    cxf/branches/2.2.x-fixes/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/UserNameTokenAuthorizationTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 13 17:57:07 2010
@@ -1 +1 @@
-/cxf/trunk:933326
+/cxf/trunk:933326,933716

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java?rev=933721&r1=933720&r2=933721&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptor.java
Tue Apr 13 17:57:07 2010
@@ -19,7 +19,9 @@
 package org.apache.cxf.interceptor.security;
 
 import java.lang.reflect.Method;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -41,12 +43,15 @@ public class SimpleAuthorizingIntercepto
 
 
 
-    public void setMethodRolesMap(Map<String, List<String>> rolesMap) {
-        this.methodRolesMap = rolesMap;
+    public void setMethodRolesMap(Map<String, String> rolesMap) {
+        methodRolesMap = new HashMap<String, List<String>>();
+        for (Map.Entry<String, String> entry : rolesMap.entrySet()) {
+            methodRolesMap.put(entry.getKey(), Arrays.asList(entry.getValue().split(" ")));
+        }
     }
     
-    public void setGlobalRoles(List<String> roles) {
-        globalRoles = roles;
+    public void setGlobalRoles(String roles) {
+        globalRoles = Arrays.asList(roles.split(" "));
     }
 
 

Modified: cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java?rev=933721&r1=933720&r2=933721&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/interceptor/security/SimpleAuthorizingInterceptorTest.java
Tue Apr 13 17:57:07 2010
@@ -20,7 +20,6 @@ package org.apache.cxf.interceptor.secur
 
 import java.lang.reflect.Method;
 import java.security.Principal;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -71,49 +70,35 @@ public class SimpleAuthorizingIntercepto
     @Test
     public void testPermitWithMethodRoles() {
         SimpleAuthorizingInterceptor in = new SimpleAuthorizingInterceptor();
-        List<String> roles = new ArrayList<String>();
-        roles.add("role1");
-        roles.add("testRole");
-        in.setMethodRolesMap(Collections.singletonMap("echo", roles));
+        in.setMethodRolesMap(Collections.singletonMap("echo", "role1 testRole"));
         in.handleMessage(message);    
     }
     
     @Test
     public void testPermitAll() {
         SimpleAuthorizingInterceptor in = new SimpleAuthorizingInterceptor();
-        List<String> roles = new ArrayList<String>();
-        roles.add("*");
-        in.setMethodRolesMap(Collections.singletonMap("echo", roles));
+        in.setMethodRolesMap(Collections.singletonMap("echo", "*"));
         in.handleMessage(message);    
     }
     
     @Test
     public void testPermitWithClassRoles() {
         SimpleAuthorizingInterceptor in = new SimpleAuthorizingInterceptor();
-        List<String> roles = new ArrayList<String>();
-        roles.add("role1");
-        roles.add("testRole");
-        in.setGlobalRoles(roles);
+        in.setGlobalRoles("role1 testRole");
         in.handleMessage(message);    
     }
     
     @Test(expected = AccessDeniedException.class)
     public void testDenyWithMethodRoles() {
         SimpleAuthorizingInterceptor in = new SimpleAuthorizingInterceptor();
-        List<String> roles = new ArrayList<String>();
-        roles.add("role1");
-        roles.add("role2");
-        in.setMethodRolesMap(Collections.singletonMap("echo", roles));
+        in.setMethodRolesMap(Collections.singletonMap("echo", "role1 role2"));
         in.handleMessage(message);    
     }
     
     @Test(expected = AccessDeniedException.class)
     public void testDenyWithClassRoles() {
         SimpleAuthorizingInterceptor in = new SimpleAuthorizingInterceptor();
-        List<String> roles = new ArrayList<String>();
-        roles.add("role1");
-        roles.add("role2");
-        in.setGlobalRoles(roles);
+        in.setGlobalRoles("role1 role2");
         in.handleMessage(message);    
     }
     

Modified: cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JSecurityContextProvidingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JSecurityContextProvidingInterceptor.java?rev=933721&r1=933720&r2=933721&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JSecurityContextProvidingInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JSecurityContextProvidingInterceptor.java
Tue Apr 13 17:57:07 2010
@@ -128,12 +128,11 @@ public abstract class AbstractWSS4JSecur
         try {
             subject = createSubject(name, password, isDigest, nonce, created);
         } catch (Exception ex) {
-            throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION, 
-                                          "Subject has not been created", null, ex);
+            throw new WSSecurityException("Failed Authentication : Subject has not been created",
ex);
         }
         if (subject == null || subject.getPrincipals().size() == 0
             || !subject.getPrincipals().iterator().next().getName().equals(name)) {
-            throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION, null,
null);
+            throw new WSSecurityException("Failed Authentication : Invalid Subject");
         }
         msg.put(Subject.class, subject);
     }

Modified: cxf/branches/2.2.x-fixes/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/UserNameTokenAuthorizationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/UserNameTokenAuthorizationTest.java?rev=933721&r1=933720&r2=933721&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/UserNameTokenAuthorizationTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/ws/security/src/test/java/org/apache/cxf/ws/security/wss4j/UserNameTokenAuthorizationTest.java
Tue Apr 13 17:57:07 2010
@@ -19,7 +19,6 @@
 package org.apache.cxf.ws.security.wss4j;
 
 import java.util.Collections;
-import java.util.List;
 
 import javax.xml.ws.BindingProvider;
 
@@ -47,7 +46,7 @@ public class UserNameTokenAuthorizationT
     private Echo echo;
     private Client client;
 
-    public void setUpService(List<String> expectedRoles,
+    public void setUpService(String expectedRoles,
                              boolean digest,
                              boolean encryptUsernameTokenOnly) throws Exception {
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
@@ -119,7 +118,7 @@ public class UserNameTokenAuthorizationT
     
     @Test
     public void testDigestPasswordAuthorized() throws Exception {
-        setUpService(Collections.singletonList("developers"), true, false);
+        setUpService("developers", true, false);
         String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE
+ " "
                          + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;
 
@@ -132,7 +131,7 @@ public class UserNameTokenAuthorizationT
     
     @Test
     public void testDigestPasswordUnauthorized() throws Exception {
-        setUpService(Collections.singletonList("managers"), true, false);
+        setUpService("managers", true, false);
         String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE
+ " "
                          + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;
 
@@ -150,7 +149,7 @@ public class UserNameTokenAuthorizationT
     
     @Test
     public void testEncryptedDigestPasswordAuthorized() throws Exception {
-        setUpService(Collections.singletonList("developers"), true, true);
+        setUpService("developers", true, true);
         String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;
 
         wsIn.setProperty(WSHandlerConstants.ACTION, actions);
@@ -161,7 +160,7 @@ public class UserNameTokenAuthorizationT
     
     @Test
     public void testClearPasswordAuthorized() throws Exception {
-        setUpService(Collections.singletonList("developers"), false, false);
+        setUpService("developers", false, false);
         String actions = WSHandlerConstants.USERNAME_TOKEN;
 
         wsIn.setProperty(WSHandlerConstants.ACTION, actions);
@@ -172,7 +171,7 @@ public class UserNameTokenAuthorizationT
     
     @Test
     public void testEncyptedClearPasswordAuthorized() throws Exception {
-        setUpService(Collections.singletonList("developers"), false, true);
+        setUpService("developers", false, true);
         String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;
 
         wsIn.setProperty(WSHandlerConstants.ACTION, actions);



Mime
View raw message