Loading projects/cadcAccessControl/src/ca/nrc/cadc/ac/User.java +18 −0 Original line number Diff line number Diff line Loading @@ -143,4 +143,22 @@ public class User<T extends Principal> return getClass().getSimpleName() + "[" + userID.getName() + "]"; } public <S extends UserDetails> Set<S> getDetails( final Class<S> userDetailsClass) { final Set<S> matchedDetails = new HashSet<S>(); for (final UserDetails ud : details) { if (ud.getClass() == userDetailsClass) { // This casting shouldn't happen, but it's the only way to // do this without a lot of work. // jenkinsd 2014.09.26 matchedDetails.add((S) ud); } } return matchedDetails; } } projects/cadcAccessControl/test/src/ca/nrc/cadc/ac/UserTest.java +16 −3 Original line number Diff line number Diff line Loading @@ -67,9 +67,7 @@ ************************************************************************ */package ca.nrc.cadc.ac; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.*; import javax.security.auth.x500.X500Principal; Loading Loading @@ -200,4 +198,19 @@ public class UserTest } assertTrue(thrown); } @Test public void getDetails() throws Exception { final User<HttpPrincipal> testSubject = new User<HttpPrincipal>(new HttpPrincipal("test")); testSubject.details.add(new PersonalDetails("First", "Last")); assertTrue("Should be empty.", testSubject.getDetails(PosixDetails.class).isEmpty()); assertEquals("Should be 1.", 1, testSubject.getDetails(PersonalDetails.class).size()); } } projects/cadcAccessControl/test/src/ca/nrc/cadc/ac/client/GMSClientTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -110,7 +110,8 @@ public class GMSClientTest subject.getPrincipals().add(userID); RegistryClient regClient = new RegistryClient(); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI)); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI), "https"); GMSClient client = new GMSClient(baseURL.toString()); Assert.assertFalse(client.userIsSubject(null, null)); Loading Loading @@ -148,7 +149,8 @@ public class GMSClientTest public Object run() throws Exception { RegistryClient regClient = new RegistryClient(); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI)); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI), "https"); GMSClient client = new GMSClient(baseURL.toString()); List<Group> initial = client.getCachedGroups(userID, Role.MEMBER); Loading Loading @@ -180,7 +182,8 @@ public class GMSClientTest // do the same without a subject RegistryClient regClient = new RegistryClient(); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI)); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI), "https"); GMSClient client = new GMSClient(baseURL.toString()); List<Group> initial = client.getCachedGroups(userID, Role.MEMBER); Loading Loading
projects/cadcAccessControl/src/ca/nrc/cadc/ac/User.java +18 −0 Original line number Diff line number Diff line Loading @@ -143,4 +143,22 @@ public class User<T extends Principal> return getClass().getSimpleName() + "[" + userID.getName() + "]"; } public <S extends UserDetails> Set<S> getDetails( final Class<S> userDetailsClass) { final Set<S> matchedDetails = new HashSet<S>(); for (final UserDetails ud : details) { if (ud.getClass() == userDetailsClass) { // This casting shouldn't happen, but it's the only way to // do this without a lot of work. // jenkinsd 2014.09.26 matchedDetails.add((S) ud); } } return matchedDetails; } }
projects/cadcAccessControl/test/src/ca/nrc/cadc/ac/UserTest.java +16 −3 Original line number Diff line number Diff line Loading @@ -67,9 +67,7 @@ ************************************************************************ */package ca.nrc.cadc.ac; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.*; import javax.security.auth.x500.X500Principal; Loading Loading @@ -200,4 +198,19 @@ public class UserTest } assertTrue(thrown); } @Test public void getDetails() throws Exception { final User<HttpPrincipal> testSubject = new User<HttpPrincipal>(new HttpPrincipal("test")); testSubject.details.add(new PersonalDetails("First", "Last")); assertTrue("Should be empty.", testSubject.getDetails(PosixDetails.class).isEmpty()); assertEquals("Should be 1.", 1, testSubject.getDetails(PersonalDetails.class).size()); } }
projects/cadcAccessControl/test/src/ca/nrc/cadc/ac/client/GMSClientTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -110,7 +110,8 @@ public class GMSClientTest subject.getPrincipals().add(userID); RegistryClient regClient = new RegistryClient(); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI)); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI), "https"); GMSClient client = new GMSClient(baseURL.toString()); Assert.assertFalse(client.userIsSubject(null, null)); Loading Loading @@ -148,7 +149,8 @@ public class GMSClientTest public Object run() throws Exception { RegistryClient regClient = new RegistryClient(); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI)); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI), "https"); GMSClient client = new GMSClient(baseURL.toString()); List<Group> initial = client.getCachedGroups(userID, Role.MEMBER); Loading Loading @@ -180,7 +182,8 @@ public class GMSClientTest // do the same without a subject RegistryClient regClient = new RegistryClient(); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI)); URL baseURL = regClient.getServiceURL(new URI(AC.GMS_SERVICE_URI), "https"); GMSClient client = new GMSClient(baseURL.toString()); List<Group> initial = client.getCachedGroups(userID, Role.MEMBER); Loading