Commit b537af89 authored by Alinga Yeung's avatar Alinga Yeung
Browse files

Story 1849. We now use Standard ID to look up the resourceIdentifier in LocalAuthority.properties.

parent 5e439ef7
...@@ -100,6 +100,7 @@ import ca.nrc.cadc.auth.HttpPrincipal; ...@@ -100,6 +100,7 @@ import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.NumericPrincipal; import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.profiler.Profiler; import ca.nrc.cadc.profiler.Profiler;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority; import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.ObjectUtil; import ca.nrc.cadc.util.ObjectUtil;
import ca.nrc.cadc.util.StringUtil; import ca.nrc.cadc.util.StringUtil;
...@@ -739,7 +740,7 @@ public class LdapUserDAO extends LdapDAO ...@@ -739,7 +740,7 @@ public class LdapUserDAO extends LdapDAO
// cache memberOf values in the user // cache memberOf values in the user
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI gmsServiceURI = localAuthority.getServiceURI("ac"); URI gmsServiceURI = localAuthority.getServiceURI(Standards.GMS_GROUPS_01.toString());
GroupMemberships gms = new GroupMemberships(gmsServiceURI.toString(), userID); GroupMemberships gms = new GroupMemberships(gmsServiceURI.toString(), userID);
user.appData = gms; // add even if empty user.appData = gms; // add even if empty
...@@ -1277,7 +1278,7 @@ public class LdapUserDAO extends LdapDAO ...@@ -1277,7 +1278,7 @@ public class LdapUserDAO extends LdapDAO
{ {
UUID uuid = new UUID(0L, Long.parseLong(numericID)); UUID uuid = new UUID(0L, Long.parseLong(numericID));
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac"); URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_REQS_01.toString());
String uriString = umsServiceURI.toString() + "?" + uuid.toString(); String uriString = umsServiceURI.toString() + "?" + uuid.toString();
URI uri; URI uri;
try try
......
...@@ -168,7 +168,7 @@ public class WhoAmIServlet extends HttpServlet ...@@ -168,7 +168,7 @@ public class WhoAmIServlet extends HttpServlet
final RegistryClient registryClient = getRegistryClient(); final RegistryClient registryClient = getRegistryClient();
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac"); URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_WHOAMI_01.toString());
log.debug("ums service uri: " + umsServiceURI); log.debug("ums service uri: " + umsServiceURI);
final URL serviceURL = registryClient.getServiceURL(umsServiceURI, Standards.UMS_USERS_01, AuthMethod.CERT); final URL serviceURL = registryClient.getServiceURL(umsServiceURI, Standards.UMS_USERS_01, AuthMethod.CERT);
......
...@@ -82,17 +82,31 @@ import javax.security.auth.Subject; ...@@ -82,17 +82,31 @@ 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 ca.nrc.cadc.ac.server.web.groups.AddUserMemberActionTest;
import ca.nrc.cadc.auth.AuthMethod; import ca.nrc.cadc.auth.AuthMethod;
import ca.nrc.cadc.reg.Standards; import ca.nrc.cadc.reg.Standards;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.reg.client.LocalAuthority; import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.reg.client.RegistryClient; import ca.nrc.cadc.reg.client.RegistryClient;
import ca.nrc.cadc.util.Log4jInit;
public class WhoAmIServletTest public class WhoAmIServletTest
{ {
private final static Logger log = Logger.getLogger(WhoAmIServletTest.class);
@BeforeClass
public static void setUpClass()
{
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO);
}
@Test @Test
public void doGet() throws Exception public void doGet() throws Exception
{ {
...@@ -135,13 +149,13 @@ public class WhoAmIServletTest ...@@ -135,13 +149,13 @@ public class WhoAmIServletTest
expectLastCall().once(); expectLastCall().once();
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac"); URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_WHOAMI_01.toString());
// expect(mockRegistry.getServiceURL(URI.create(umsServiceURI.toString() + "#users"), // expect(mockRegistry.getServiceURL(URI.create(umsServiceURI.toString() + "#users"),
// "http", "/%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();
expect(mockRegistry.getServiceURL(umsServiceURI, Standards.UMS_USERS_01, AuthMethod.PASSWORD)) expect(mockRegistry.getServiceURL(umsServiceURI, Standards.UMS_USERS_01, AuthMethod.CERT))
.andReturn(new URL("http://mysite.com/ac/users")).once(); .andReturn(new URL("http://mysite.com/ac/users")).once();
replay(mockRequest, mockResponse, mockRegistry); replay(mockRequest, mockResponse, mockRegistry);
......
...@@ -92,6 +92,7 @@ import ca.nrc.cadc.ac.server.UserPersistence; ...@@ -92,6 +92,7 @@ import ca.nrc.cadc.ac.server.UserPersistence;
import ca.nrc.cadc.auth.AuthenticationUtil; import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.IdentityType; import ca.nrc.cadc.auth.IdentityType;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority; import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.Log4jInit; import ca.nrc.cadc.util.Log4jInit;
import ca.nrc.cadc.util.ObjectUtil; import ca.nrc.cadc.util.ObjectUtil;
...@@ -118,7 +119,7 @@ public class RemoveUserMemberActionTest ...@@ -118,7 +119,7 @@ public class RemoveUserMemberActionTest
{ {
User user = new User(); User user = new User();
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac"); URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_REQS_01.toString());
InternalID internalID = new InternalID(new URI(umsServiceURI.toASCIIString() + "?" + UUID.randomUUID())); InternalID internalID = new InternalID(new URI(umsServiceURI.toASCIIString() + "?" + UUID.randomUUID()));
ObjectUtil.setField(user, internalID, "id"); ObjectUtil.setField(user, internalID, "id");
...@@ -172,7 +173,7 @@ public class RemoveUserMemberActionTest ...@@ -172,7 +173,7 @@ public class RemoveUserMemberActionTest
{ {
User user = new User(); User user = new User();
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac"); URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_REQS_01.toString());
InternalID internalID = new InternalID(new URI(umsServiceURI.toString() + "?" + UUID.randomUUID())); InternalID internalID = new InternalID(new URI(umsServiceURI.toString() + "?" + UUID.randomUUID()));
ObjectUtil.setField(user, internalID, "id"); ObjectUtil.setField(user, internalID, "id");
......
...@@ -104,6 +104,7 @@ import ca.nrc.cadc.auth.IdentityType; ...@@ -104,6 +104,7 @@ import ca.nrc.cadc.auth.IdentityType;
import ca.nrc.cadc.auth.NumericPrincipal; import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.auth.OpenIdPrincipal; import ca.nrc.cadc.auth.OpenIdPrincipal;
import ca.nrc.cadc.date.DateUtil; import ca.nrc.cadc.date.DateUtil;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority; import ca.nrc.cadc.reg.client.LocalAuthority;
/** /**
...@@ -156,7 +157,7 @@ public abstract class AbstractReaderWriter ...@@ -156,7 +157,7 @@ public abstract class AbstractReaderWriter
public AbstractReaderWriter() public AbstractReaderWriter()
{ {
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
URI serviceURI = localAuthority.getServiceURI("ac"); URI serviceURI = localAuthority.getServiceURI(Standards.GMS_GROUPS_01.toString());
gmsServiceURI = serviceURI.toString(); gmsServiceURI = serviceURI.toString();
} }
......
...@@ -86,6 +86,7 @@ import org.junit.Test; ...@@ -86,6 +86,7 @@ import org.junit.Test;
import ca.nrc.cadc.auth.HttpPrincipal; import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.NumericPrincipal; import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority; import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.Log4jInit; import ca.nrc.cadc.util.Log4jInit;
...@@ -101,7 +102,7 @@ public class UserClientTest ...@@ -101,7 +102,7 @@ public class UserClientTest
{ {
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO); Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO);
LocalAuthority localAuthority = new LocalAuthority(); LocalAuthority localAuthority = new LocalAuthority();
umsServiceURI = localAuthority.getServiceURI("ac"); umsServiceURI = localAuthority.getServiceURI(Standards.UMS_USERS_01.toString());
} }
@Test @Test
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
<!-- developer convenience: place for extra targets and properties --> <!-- developer convenience: place for extra targets and properties -->
<import file="extras.xml" optional="true" /> <import file="extras.xml" optional="true" />
<property name="cadc" value="${lib}/cadcUtil.jar" /> <property name="cadc" value="${lib}/cadcUtil.jar:${lib}/cadcRegistry.jar" />
<property name="log4j" value="${ext.lib}/log4j.jar" /> <property name="log4j" value="${ext.lib}/log4j.jar" />
<property name="tomcat" value="${ext.lib}/catalina.jar:${ext.lib}/tomcat-util.jar:${ext.lib}/tomcat-coyote.jar" /> <property name="tomcat" value="${ext.lib}/catalina.jar:${ext.lib}/tomcat-util.jar:${ext.lib}/tomcat-coyote.jar" />
<property name="jars" value="${cadc}:${log4j}:${tomcat}" /> <property name="jars" value="${cadc}:${log4j}:${tomcat}" />
......
...@@ -83,6 +83,8 @@ import org.apache.catalina.realm.RealmBase; ...@@ -83,6 +83,8 @@ import org.apache.catalina.realm.RealmBase;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import ca.nrc.cadc.reg.Standards;
/** /**
* Custom class for Tomcat realm authentication. * Custom class for Tomcat realm authentication.
* *
...@@ -97,7 +99,7 @@ public class CadcBasicAuthenticator extends RealmBase ...@@ -97,7 +99,7 @@ public class CadcBasicAuthenticator extends RealmBase
{ {
private static Logger log = Logger.getLogger(CadcBasicAuthenticator.class); private static Logger log = Logger.getLogger(CadcBasicAuthenticator.class);
private static final String AC_URI = "ivo://cadc.nrc.ca/ac"; private static final String AC_URI = Standards.UMS_LOGIN_01.toString();
static static
{ {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment