cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [3/3] cxf git commit: Fixing merge
Date Fri, 24 Mar 2017 11:01:36 GMT
Fixing merge


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b951579b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b951579b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b951579b

Branch: refs/heads/3.1.x-fixes
Commit: b951579b1c5c1e1ae06fdeebe96bdc20f830a5c0
Parents: dbbf17a
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Fri Mar 24 11:01:27 2017 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Fri Mar 24 11:01:27 2017 +0000

----------------------------------------------------------------------
 .../systest/kerberos/ldap/LDAPClaimsTest.java   | 177 ++++++-------------
 1 file changed, 56 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b951579b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
----------------------------------------------------------------------
diff --git a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
index 2751787..5008bde 100644
--- a/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
+++ b/systests/kerberos/src/test/java/org/apache/cxf/systest/kerberos/ldap/LDAPClaimsTest.java
@@ -39,6 +39,7 @@ import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.rt.security.claims.Claim;
 import org.apache.cxf.rt.security.claims.ClaimCollection;
 import org.apache.cxf.sts.claims.ClaimTypes;
+import org.apache.cxf.sts.claims.ClaimsHandler;
 import org.apache.cxf.sts.claims.ClaimsManager;
 import org.apache.cxf.sts.claims.ClaimsParameters;
 import org.apache.cxf.sts.claims.LdapClaimsHandler;
@@ -93,9 +94,9 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
     private static Properties props;
     private static boolean portUpdated;
-    
+
     private ClassPathXmlApplicationContext appContext;
-    
+
     @BeforeClass
     public static void startServers() throws Exception {
         props = new Properties();
@@ -114,18 +115,18 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
             if (basedir == null) {
                 basedir = new File(".").getCanonicalPath();
             }
-            
+
             // Read in ldap.xml and substitute in the correct port
             Path path = FileSystems.getDefault().getPath(basedir, "/src/test/resources/ldap.xml");
             String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
             content = content.replaceAll("portno", "" + super.getLdapServer().getPort());
-            
+
             Path path2 = FileSystems.getDefault().getPath(basedir, "/target/test-classes/ldapport.xml");
             Files.write(path2, content.getBytes());
-            
+
             portUpdated = true;
         }
-        
+
         appContext = new ClassPathXmlApplicationContext("ldapport.xml");
     }
 
@@ -133,7 +134,7 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
     public void testRetrieveClaims() throws Exception {
         LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("claimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -144,20 +145,15 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         expectedClaims.add(ClaimTypes.FIRSTNAME);
         expectedClaims.add(ClaimTypes.LASTNAME);
         expectedClaims.add(ClaimTypes.EMAILADDRESS);
-       
+
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(
-                      retrievedClaims.size() == expectedClaims.size(), 
-                      "Retrieved number of claims [" + retrievedClaims.size() 
+                      retrievedClaims.size() == expectedClaims.size(),
+                      "Retrieved number of claims [" + retrievedClaims.size()
                       + "] doesn't match with expected [" + expectedClaims.size() + "]"
         );
 
@@ -169,12 +165,12 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
             }
         }
     }
-    
+
     @org.junit.Test
     public void testRetrieveClaimsUsingLDAPLookup() throws Exception {
         LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         ClaimCollection requestedClaims = createRequestClaimCollection();
 
@@ -182,20 +178,15 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         expectedClaims.add(ClaimTypes.FIRSTNAME);
         expectedClaims.add(ClaimTypes.LASTNAME);
         expectedClaims.add(ClaimTypes.EMAILADDRESS);
-       
+
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal("cn=alice,ou=users,dc=example,dc=com"));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(
-                      retrievedClaims.size() == expectedClaims.size(), 
-                      "Retrieved number of claims [" + retrievedClaims.size() 
+                      retrievedClaims.size() == expectedClaims.size(),
+                      "Retrieved number of claims [" + retrievedClaims.size()
                       + "] doesn't match with expected [" + expectedClaims.size() + "]"
         );
 
@@ -212,7 +203,7 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
     public void testMultiUserBaseDNs() throws Exception {
         LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandlerMultipleUserBaseDNs");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("claimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -225,21 +216,16 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         expectedClaims.add(ClaimTypes.FIRSTNAME);
         expectedClaims.add(ClaimTypes.LASTNAME);
         expectedClaims.add(ClaimTypes.EMAILADDRESS);
-       
+
         // First user
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(
-                      retrievedClaims.size() == expectedClaims.size(), 
-                      "Retrieved number of claims [" + retrievedClaims.size() 
+                      retrievedClaims.size() == expectedClaims.size(),
+                      "Retrieved number of claims [" + retrievedClaims.size()
                       + "] doesn't match with expected [" + expectedClaims.size() + "]"
         );
 
@@ -250,7 +236,7 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
                 Assert.isTrue(false, "Claim '" + c.getClaimType() + "' not requested");
             }
         }
-        
+
         // Second user
         params.setPrincipal(new CustomTokenPrincipal(otherUser));
         retrievedClaims = claimsManager.retrieveClaimValues(requestedClaims, params);
@@ -258,10 +244,10 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         expectedClaims.add(ClaimTypes.FIRSTNAME);
         expectedClaims.add(ClaimTypes.LASTNAME);
         expectedClaims.add(ClaimTypes.EMAILADDRESS);
-        
+
         Assert.isTrue(
-                      retrievedClaims.size() == expectedClaims.size(), 
-                      "Retrieved number of claims [" + retrievedClaims.size() 
+                      retrievedClaims.size() == expectedClaims.size(),
+                      "Retrieved number of claims [" + retrievedClaims.size()
                       + "] doesn't match with expected [" + expectedClaims.size() + "]"
         );
 
@@ -278,7 +264,7 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
     public void testRetrieveClaimsWithUnsupportedMandatoryClaimType() throws Exception {
         LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("claimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -292,35 +278,14 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection processedClaim = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-        
-        for (Claim requestedClaim : requestedClaims) {
-            URI claimType = requestedClaim.getClaimType();
-            boolean found = false;
-            if (!requestedClaim.isOptional()) {
-                for (ProcessedClaim c : processedClaim) {
-                    if (c.getClaimType().equals(claimType)) {
-                        found = true;
-                        break;
-                    }
-                }
-                if (!found) {
-                    throw new STSException("Mandatory claim '" + claim.getClaimType() + "'
not found");
-                }
-            }
-        }
-=======
         claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
     }
-    
+
     @org.junit.Test
     public void testRetrieveClaimsWithUnsupportedOptionalClaimType() throws Exception {
         LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("claimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -337,20 +302,15 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         expectedClaims.add(ClaimTypes.FIRSTNAME);
         expectedClaims.add(ClaimTypes.LASTNAME);
         expectedClaims.add(ClaimTypes.EMAILADDRESS);
-        
+
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(
-                      retrievedClaims.size() == expectedClaims.size(), 
-                      "Retrieved number of claims [" + retrievedClaims.size() 
+                      retrievedClaims.size() == expectedClaims.size(),
+                      "Retrieved number of claims [" + retrievedClaims.size()
                       + "] doesn't match with expected [" + expectedClaims.size() + "]"
         );
 
@@ -362,11 +322,11 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
             }
         }
     }
-    
-    @org.junit.Test    
+
+    @org.junit.Test
     public void testSupportedClaims() throws Exception {
 
-        Map<String, String> mapping 
+        Map<String, String> mapping
             = CastUtils.cast((Map<?, ?>)appContext.getBean("claimsToLdapAttributeMapping"));
 
         LdapClaimsHandler cHandler = new LdapClaimsHandler();
@@ -375,23 +335,23 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         List<URI> supportedClaims = cHandler.getSupportedClaimTypes();
 
         Assert.isTrue(
-                      mapping.size() == supportedClaims.size(), 
+                      mapping.size() == supportedClaims.size(),
                       "Supported claims and claims/ldap attribute mapping size different"
         );
 
         for (String claim : mapping.keySet()) {
             Assert.isTrue(
-                          supportedClaims.contains(new URI(claim)), 
+                          supportedClaims.contains(new URI(claim)),
                           "Claim '" + claim + "' not listed in supported list"
             );
         }
     }
-    
+
     @org.junit.Test
     public void testRetrieveBinaryClaims() throws Exception {
         LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("binaryClaimUser");
         Assert.notNull(user, "Property 'binaryClaimUser' not configured");
@@ -402,26 +362,21 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         claim.setClaimType(URI.create("http://custom/x509"));
         claim.setOptional(true);
         requestedClaims.add(claim);
-        
+
         List<URI> expectedClaims = new ArrayList<URI>();
         expectedClaims.add(ClaimTypes.FIRSTNAME);
         expectedClaims.add(ClaimTypes.LASTNAME);
         expectedClaims.add(ClaimTypes.EMAILADDRESS);
         expectedClaims.add(URI.create("http://custom/x509"));
-       
+
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(
-                      retrievedClaims.size() == expectedClaims.size(), 
-                      "Retrieved number of claims [" + retrievedClaims.size() 
+                      retrievedClaims.size() == expectedClaims.size(),
+                      "Retrieved number of claims [" + retrievedClaims.size()
                       + "] doesn't match with expected [" + expectedClaims.size() + "]"
         );
 
@@ -436,16 +391,16 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
                 Assert.isTrue(cert != null);
             }
         }
-        
+
         Assert.isTrue(foundCert);
     }
-    
+
     @org.junit.Test
     public void testRetrieveRolesForAlice() throws Exception {
-        LdapGroupClaimsHandler claimsHandler = 
+        LdapGroupClaimsHandler claimsHandler =
             (LdapGroupClaimsHandler)appContext.getBean("testGroupClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("claimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -458,25 +413,20 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(retrievedClaims.size() == 1);
         Assert.isTrue(retrievedClaims.get(0).getClaimType().equals(roleURI));
         Assert.isTrue(retrievedClaims.get(0).getValues().size() == 2);
     }
-    
+
     @org.junit.Test
     public void testRetrieveRolesForAliceUsingLDAPLookup() throws Exception {
-        LdapGroupClaimsHandler claimsHandler = 
+        LdapGroupClaimsHandler claimsHandler =
             (LdapGroupClaimsHandler)appContext.getBean("testGroupClaimsHandler");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         ClaimCollection requestedClaims = new ClaimCollection();
         Claim claim = new Claim();
@@ -486,25 +436,20 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal("cn=alice,ou=users,dc=example,dc=com"));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(retrievedClaims.size() == 1);
         Assert.isTrue(retrievedClaims.get(0).getClaimType().equals(roleURI));
         Assert.isTrue(retrievedClaims.get(0).getValues().size() == 2);
     }
-    
+
     @org.junit.Test
     public void testRetrieveRolesForBob() throws Exception {
-        LdapGroupClaimsHandler claimsHandler = 
+        LdapGroupClaimsHandler claimsHandler =
             (LdapGroupClaimsHandler)appContext.getBean("testGroupClaimsHandlerOtherUsers");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("otherClaimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -517,25 +462,20 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(retrievedClaims.size() == 1);
         Assert.isTrue(retrievedClaims.get(0).getClaimType().equals(roleURI));
         Assert.isTrue(retrievedClaims.get(0).getValues().size() == 2);
     }
-    
+
     @org.junit.Test
     public void testRetrieveRolesForBobInBusinessCategoryWidgets() throws Exception {
-        LdapGroupClaimsHandler claimsHandler = 
+        LdapGroupClaimsHandler claimsHandler =
             (LdapGroupClaimsHandler)appContext.getBean("testGroupClaimsHandlerFilter");
         ClaimsManager claimsManager = new ClaimsManager();
-        claimsManager.setClaimHandlers(Collections.singletonList(claimsHandler));
+        claimsManager.setClaimHandlers(Collections.<ClaimsHandler>singletonList(claimsHandler));
 
         String user = props.getProperty("otherClaimUser");
         Assert.notNull(user, "Property 'claimUser' not configured");
@@ -548,19 +488,14 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
 
         ClaimsParameters params = new ClaimsParameters();
         params.setPrincipal(new CustomTokenPrincipal(user));
-<<<<<<< HEAD
-        ProcessedClaimCollection retrievedClaims = 
-            claimsHandler.retrieveClaimValues(requestedClaims, params);
-=======
         ProcessedClaimCollection retrievedClaims =
             claimsManager.retrieveClaimValues(requestedClaims, params);
->>>>>>> a719adc... CXF-6044 - Obsolet Testing Method in LDAPClaimsTest
 
         Assert.isTrue(retrievedClaims.size() == 1);
         Assert.isTrue(retrievedClaims.get(0).getClaimType().equals(roleURI));
         Assert.isTrue(retrievedClaims.get(0).getValues().size() == 1);
     }
-    
+
     private ClaimCollection createRequestClaimCollection() {
         ClaimCollection claims = new ClaimCollection();
         Claim claim = new Claim();
@@ -577,5 +512,5 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
         claims.add(claim);
         return claims;
     }
-    
+
 }


Mime
View raw message