Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapGroupPersistence.java +2 −25 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,6 @@ */ */ package ca.nrc.cadc.ac.server.ldap; package ca.nrc.cadc.ac.server.ldap; import java.lang.reflect.Field; import java.security.AccessControlException; import java.security.AccessControlException; import java.security.Principal; import java.security.Principal; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -94,6 +93,7 @@ import ca.nrc.cadc.auth.AuthMethod; import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.auth.DNPrincipal; import ca.nrc.cadc.auth.DNPrincipal; import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.util.ObjectUtil; public class LdapGroupPersistence extends LdapPersistence implements GroupPersistence public class LdapGroupPersistence extends LdapPersistence implements GroupPersistence { { Loading Loading @@ -182,7 +182,7 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis { { LdapUserDAO userDAO = new LdapUserDAO(conns); LdapUserDAO userDAO = new LdapUserDAO(conns); User owner = userDAO.getAugmentedUser(userID); User owner = userDAO.getAugmentedUser(userID); setField(group, owner, "owner"); ObjectUtil.setField(group, owner, "owner"); LdapGroupDAO groupDAO = new LdapGroupDAO(conns, userDAO); LdapGroupDAO groupDAO = new LdapGroupDAO(conns, userDAO); groupDAO.addGroup(group); groupDAO.addGroup(group); } } Loading Loading @@ -395,27 +395,4 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis GroupMemberships gms = gset.iterator().next(); GroupMemberships gms = gset.iterator().next(); return gms.getUserID(); return gms.getUserID(); } } // set private field using reflection private void setField(Object object, Object value, String name) { try { Field field = object.getClass().getDeclaredField(name); field.setAccessible(true); field.set(object, value); } catch (NoSuchFieldException e) { final String error = object.getClass().getSimpleName() + " field " + name + "not found"; throw new RuntimeException(error, e); } catch (IllegalAccessException e) { final String error = "unable to update " + name + " in " + object.getClass().getSimpleName(); throw new RuntimeException(error, e); } } } } cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +8 −2 Original line number Original line Diff line number Diff line Loading @@ -142,6 +142,8 @@ public class LdapUserDAO extends LdapDAO private final Profiler profiler = new Profiler(LdapUserDAO.class); private final Profiler profiler = new Profiler(LdapUserDAO.class); private String internalIdUriPrefix = AC.USER_URI; // Map of identity type to LDAP attribute // Map of identity type to LDAP attribute private final Map<Class<?>, String> userLdapAttrib = new HashMap<Class<?>, String>(); private final Map<Class<?>, String> userLdapAttrib = new HashMap<Class<?>, String>(); Loading Loading @@ -1263,11 +1265,15 @@ public class LdapUserDAO extends LdapDAO return uuid.getLeastSignificantBits(); return uuid.getLeastSignificantBits(); } } protected void setInternalIdUriPrefix(String internalIdUriPrefix) { this.internalIdUriPrefix = internalIdUriPrefix; } protected InternalID getInternalID(String numericID) protected InternalID getInternalID(String numericID) { { UUID uuid = new UUID(0L, Long.parseLong(numericID)); UUID uuid = new UUID(0L, Long.parseLong(numericID)); String uriString = internalIdUriPrefix + "?" + uuid.toString(); final String uriString = AC.USER_URI + uuid.toString(); URI uri; URI uri; try try { { Loading cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserPersistence.java +35 −15 Original line number Original line Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.addUser(user); userDAO.addUser(user); } } finally finally Loading @@ -147,7 +147,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.addUserRequest(userRequest); userDAO.addUserRequest(userRequest); } } finally finally Loading Loading @@ -178,7 +178,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUser(userID); return userDAO.getUser(userID); } } finally finally Loading Loading @@ -206,7 +206,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { LdapUserDAO userDAO = new LdapUserDAO(conns); LdapUserDAO userDAO = getLdapUserDao(conns); return userDAO.getUserByEmailAddress(emailAddress); return userDAO.getUserByEmailAddress(emailAddress); } } finally finally Loading Loading @@ -235,7 +235,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUserRequest(userID); return userDAO.getUserRequest(userID); } } finally finally Loading Loading @@ -263,7 +263,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); profiler.checkpoint("Create LdapUserDAO"); profiler.checkpoint("Create LdapUserDAO"); User user = userDAO.getAugmentedUser(userID); User user = userDAO.getAugmentedUser(userID); profiler.checkpoint("getAugmentedUser"); profiler.checkpoint("getAugmentedUser"); Loading Loading @@ -294,7 +294,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUsers(); return userDAO.getUsers(); } } finally finally Loading @@ -318,7 +318,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUserRequests(); return userDAO.getUserRequests(); } } finally finally Loading Loading @@ -348,7 +348,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.approveUserRequest(userID); return userDAO.approveUserRequest(userID); } } finally finally Loading Loading @@ -380,7 +380,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.modifyUser(user); return userDAO.modifyUser(user); } } finally finally Loading Loading @@ -410,7 +410,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.deleteUser(userID); userDAO.deleteUser(userID); } } finally finally Loading @@ -437,7 +437,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.deleteUserRequest(userID); userDAO.deleteUserRequest(userID); } } finally finally Loading @@ -464,7 +464,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.doLogin(userID, password); return userDAO.doLogin(userID, password); } } finally finally Loading Loading @@ -494,7 +494,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); if (userDAO.doLogin(userID.getName(), oldPassword)) if (userDAO.doLogin(userID.getName(), oldPassword)) { { // oldPassword is correct // oldPassword is correct Loading Loading @@ -527,7 +527,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); User user = getUser(userID); User user = getUser(userID); if (user != null) if (user != null) Loading Loading @@ -570,4 +570,24 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste } } return false; return false; } } private LdapUserDAO getLdapUserDao(LdapConnections conn) { LdapUserDAO dao = new LdapUserDAO(conn); if (getInternalIdUriPrefix() != null) dao.setInternalIdUriPrefix(getInternalIdUriPrefix()); return dao; } /** * Web services can override this method to change * the user prefix used in the internal ID. * * By default the LdapUserDAO will use AC.USER_URI; */ protected String getInternalIdUriPrefix() { return null; } } } cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/web/WhoAmIServletTest.java +15 −10 Original line number Original line Diff line number Diff line Loading @@ -68,20 +68,25 @@ package ca.nrc.cadc.ac.server.web; package ca.nrc.cadc.ac.server.web; import ca.nrc.cadc.ac.AC; import static org.easymock.EasyMock.createMock; import ca.nrc.cadc.auth.HttpPrincipal; import static org.easymock.EasyMock.expect; import ca.nrc.cadc.reg.client.RegistryClient; import static org.easymock.EasyMock.expectLastCall; import org.junit.Test; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import java.net.URI; import java.net.URL; import java.security.PrivilegedExceptionAction; import javax.security.auth.Subject; import javax.security.auth.Subject; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse; import java.net.URI; import org.junit.Test; import java.net.URL; import java.security.PrivilegedExceptionAction; import static org.easymock.EasyMock.*; import ca.nrc.cadc.ac.AC; import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.reg.client.RegistryClient; public class WhoAmIServletTest public class WhoAmIServletTest Loading Loading @@ -127,8 +132,8 @@ public class WhoAmIServletTest mockResponse.sendRedirect("/ac/users/CADCtest?idType=HTTP"); mockResponse.sendRedirect("/ac/users/CADCtest?idType=HTTP"); expectLastCall().once(); expectLastCall().once(); expect(mockRegistry.getServiceURL(URI.create(AC.GMS_SERVICE_URI), expect(mockRegistry.getServiceURL(URI.create(AC.UMS_SERVICE_URI + "#users"), "http", "/users/%s?idType=HTTP")). "http", "/%s?idType=HTTP")). andReturn(new URL("http://mysite.com/ac/users/CADCtest?idType=HTTP")).once(); andReturn(new URL("http://mysite.com/ac/users/CADCtest?idType=HTTP")).once(); replay(mockRequest, mockResponse, mockRegistry); replay(mockRequest, mockResponse, mockRegistry); Loading cadcAccessControl/src/ca/nrc/cadc/ac/AC.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -92,6 +92,6 @@ public class AC public static final String GROUP_URI = "ivo://cadc.nrc.ca/gms#"; public static final String GROUP_URI = "ivo://cadc.nrc.ca/gms#"; // User URI with appended UUID represents a unique user // User URI with appended UUID represents a unique user public static final String USER_URI = "ivo://cadc.nrc.ca/user?"; public static final String USER_URI = "ivo://cadc.nrc.ca/user"; } } Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapGroupPersistence.java +2 −25 Original line number Original line Diff line number Diff line Loading @@ -68,7 +68,6 @@ */ */ package ca.nrc.cadc.ac.server.ldap; package ca.nrc.cadc.ac.server.ldap; import java.lang.reflect.Field; import java.security.AccessControlException; import java.security.AccessControlException; import java.security.Principal; import java.security.Principal; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -94,6 +93,7 @@ import ca.nrc.cadc.auth.AuthMethod; import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.auth.DNPrincipal; import ca.nrc.cadc.auth.DNPrincipal; import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.util.ObjectUtil; public class LdapGroupPersistence extends LdapPersistence implements GroupPersistence public class LdapGroupPersistence extends LdapPersistence implements GroupPersistence { { Loading Loading @@ -182,7 +182,7 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis { { LdapUserDAO userDAO = new LdapUserDAO(conns); LdapUserDAO userDAO = new LdapUserDAO(conns); User owner = userDAO.getAugmentedUser(userID); User owner = userDAO.getAugmentedUser(userID); setField(group, owner, "owner"); ObjectUtil.setField(group, owner, "owner"); LdapGroupDAO groupDAO = new LdapGroupDAO(conns, userDAO); LdapGroupDAO groupDAO = new LdapGroupDAO(conns, userDAO); groupDAO.addGroup(group); groupDAO.addGroup(group); } } Loading Loading @@ -395,27 +395,4 @@ public class LdapGroupPersistence extends LdapPersistence implements GroupPersis GroupMemberships gms = gset.iterator().next(); GroupMemberships gms = gset.iterator().next(); return gms.getUserID(); return gms.getUserID(); } } // set private field using reflection private void setField(Object object, Object value, String name) { try { Field field = object.getClass().getDeclaredField(name); field.setAccessible(true); field.set(object, value); } catch (NoSuchFieldException e) { final String error = object.getClass().getSimpleName() + " field " + name + "not found"; throw new RuntimeException(error, e); } catch (IllegalAccessException e) { final String error = "unable to update " + name + " in " + object.getClass().getSimpleName(); throw new RuntimeException(error, e); } } } }
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserDAO.java +8 −2 Original line number Original line Diff line number Diff line Loading @@ -142,6 +142,8 @@ public class LdapUserDAO extends LdapDAO private final Profiler profiler = new Profiler(LdapUserDAO.class); private final Profiler profiler = new Profiler(LdapUserDAO.class); private String internalIdUriPrefix = AC.USER_URI; // Map of identity type to LDAP attribute // Map of identity type to LDAP attribute private final Map<Class<?>, String> userLdapAttrib = new HashMap<Class<?>, String>(); private final Map<Class<?>, String> userLdapAttrib = new HashMap<Class<?>, String>(); Loading Loading @@ -1263,11 +1265,15 @@ public class LdapUserDAO extends LdapDAO return uuid.getLeastSignificantBits(); return uuid.getLeastSignificantBits(); } } protected void setInternalIdUriPrefix(String internalIdUriPrefix) { this.internalIdUriPrefix = internalIdUriPrefix; } protected InternalID getInternalID(String numericID) protected InternalID getInternalID(String numericID) { { UUID uuid = new UUID(0L, Long.parseLong(numericID)); UUID uuid = new UUID(0L, Long.parseLong(numericID)); String uriString = internalIdUriPrefix + "?" + uuid.toString(); final String uriString = AC.USER_URI + uuid.toString(); URI uri; URI uri; try try { { Loading
cadcAccessControl-Server/src/ca/nrc/cadc/ac/server/ldap/LdapUserPersistence.java +35 −15 Original line number Original line Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.addUser(user); userDAO.addUser(user); } } finally finally Loading @@ -147,7 +147,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.addUserRequest(userRequest); userDAO.addUserRequest(userRequest); } } finally finally Loading Loading @@ -178,7 +178,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUser(userID); return userDAO.getUser(userID); } } finally finally Loading Loading @@ -206,7 +206,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { LdapUserDAO userDAO = new LdapUserDAO(conns); LdapUserDAO userDAO = getLdapUserDao(conns); return userDAO.getUserByEmailAddress(emailAddress); return userDAO.getUserByEmailAddress(emailAddress); } } finally finally Loading Loading @@ -235,7 +235,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUserRequest(userID); return userDAO.getUserRequest(userID); } } finally finally Loading Loading @@ -263,7 +263,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); profiler.checkpoint("Create LdapUserDAO"); profiler.checkpoint("Create LdapUserDAO"); User user = userDAO.getAugmentedUser(userID); User user = userDAO.getAugmentedUser(userID); profiler.checkpoint("getAugmentedUser"); profiler.checkpoint("getAugmentedUser"); Loading Loading @@ -294,7 +294,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUsers(); return userDAO.getUsers(); } } finally finally Loading @@ -318,7 +318,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.getUserRequests(); return userDAO.getUserRequests(); } } finally finally Loading Loading @@ -348,7 +348,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.approveUserRequest(userID); return userDAO.approveUserRequest(userID); } } finally finally Loading Loading @@ -380,7 +380,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.modifyUser(user); return userDAO.modifyUser(user); } } finally finally Loading Loading @@ -410,7 +410,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.deleteUser(userID); userDAO.deleteUser(userID); } } finally finally Loading @@ -437,7 +437,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); userDAO.deleteUserRequest(userID); userDAO.deleteUserRequest(userID); } } finally finally Loading @@ -464,7 +464,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); return userDAO.doLogin(userID, password); return userDAO.doLogin(userID, password); } } finally finally Loading Loading @@ -494,7 +494,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); if (userDAO.doLogin(userID.getName(), oldPassword)) if (userDAO.doLogin(userID.getName(), oldPassword)) { { // oldPassword is correct // oldPassword is correct Loading Loading @@ -527,7 +527,7 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste LdapConnections conns = new LdapConnections(this); LdapConnections conns = new LdapConnections(this); try try { { userDAO = new LdapUserDAO(conns); userDAO = getLdapUserDao(conns); User user = getUser(userID); User user = getUser(userID); if (user != null) if (user != null) Loading Loading @@ -570,4 +570,24 @@ public class LdapUserPersistence extends LdapPersistence implements UserPersiste } } return false; return false; } } private LdapUserDAO getLdapUserDao(LdapConnections conn) { LdapUserDAO dao = new LdapUserDAO(conn); if (getInternalIdUriPrefix() != null) dao.setInternalIdUriPrefix(getInternalIdUriPrefix()); return dao; } /** * Web services can override this method to change * the user prefix used in the internal ID. * * By default the LdapUserDAO will use AC.USER_URI; */ protected String getInternalIdUriPrefix() { return null; } } }
cadcAccessControl-Server/test/src/ca/nrc/cadc/ac/server/web/WhoAmIServletTest.java +15 −10 Original line number Original line Diff line number Diff line Loading @@ -68,20 +68,25 @@ package ca.nrc.cadc.ac.server.web; package ca.nrc.cadc.ac.server.web; import ca.nrc.cadc.ac.AC; import static org.easymock.EasyMock.createMock; import ca.nrc.cadc.auth.HttpPrincipal; import static org.easymock.EasyMock.expect; import ca.nrc.cadc.reg.client.RegistryClient; import static org.easymock.EasyMock.expectLastCall; import org.junit.Test; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import java.net.URI; import java.net.URL; import java.security.PrivilegedExceptionAction; import javax.security.auth.Subject; import javax.security.auth.Subject; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse; import java.net.URI; import org.junit.Test; import java.net.URL; import java.security.PrivilegedExceptionAction; import static org.easymock.EasyMock.*; import ca.nrc.cadc.ac.AC; import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.reg.client.RegistryClient; public class WhoAmIServletTest public class WhoAmIServletTest Loading Loading @@ -127,8 +132,8 @@ public class WhoAmIServletTest mockResponse.sendRedirect("/ac/users/CADCtest?idType=HTTP"); mockResponse.sendRedirect("/ac/users/CADCtest?idType=HTTP"); expectLastCall().once(); expectLastCall().once(); expect(mockRegistry.getServiceURL(URI.create(AC.GMS_SERVICE_URI), expect(mockRegistry.getServiceURL(URI.create(AC.UMS_SERVICE_URI + "#users"), "http", "/users/%s?idType=HTTP")). "http", "/%s?idType=HTTP")). andReturn(new URL("http://mysite.com/ac/users/CADCtest?idType=HTTP")).once(); andReturn(new URL("http://mysite.com/ac/users/CADCtest?idType=HTTP")).once(); replay(mockRequest, mockResponse, mockRegistry); replay(mockRequest, mockResponse, mockRegistry); Loading
cadcAccessControl/src/ca/nrc/cadc/ac/AC.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -92,6 +92,6 @@ public class AC public static final String GROUP_URI = "ivo://cadc.nrc.ca/gms#"; public static final String GROUP_URI = "ivo://cadc.nrc.ca/gms#"; // User URI with appended UUID represents a unique user // User URI with appended UUID represents a unique user public static final String USER_URI = "ivo://cadc.nrc.ca/user?"; public static final String USER_URI = "ivo://cadc.nrc.ca/user"; } }