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;
import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.profiler.Profiler;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.ObjectUtil;
import ca.nrc.cadc.util.StringUtil;
......@@ -739,7 +740,7 @@ public class LdapUserDAO extends LdapDAO
// cache memberOf values in the user
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);
user.appData = gms; // add even if empty
......@@ -1277,7 +1278,7 @@ public class LdapUserDAO extends LdapDAO
{
UUID uuid = new UUID(0L, Long.parseLong(numericID));
LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac");
URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_REQS_01.toString());
String uriString = umsServiceURI.toString() + "?" + uuid.toString();
URI uri;
try
......
......@@ -168,7 +168,7 @@ public class WhoAmIServlet extends HttpServlet
final RegistryClient registryClient = getRegistryClient();
LocalAuthority localAuthority = new LocalAuthority();
URI umsServiceURI = localAuthority.getServiceURI("ac");
URI umsServiceURI = localAuthority.getServiceURI(Standards.UMS_WHOAMI_01.toString());
log.debug("ums service uri: " + umsServiceURI);
final URL serviceURL = registryClient.getServiceURL(umsServiceURI, Standards.UMS_USERS_01, AuthMethod.CERT);
......
......@@ -82,17 +82,31 @@ import javax.security.auth.Subject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ca.nrc.cadc.ac.server.web.groups.AddUserMemberActionTest;
import ca.nrc.cadc.auth.AuthMethod;
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 ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.reg.client.RegistryClient;
import ca.nrc.cadc.util.Log4jInit;
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
public void doGet() throws Exception
{
......@@ -135,13 +149,13 @@ public class WhoAmIServletTest
expectLastCall().once();
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"),
// "http", "/%s?idType=HTTP")).
// 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();
replay(mockRequest, mockResponse, mockRegistry);
......
......@@ -92,6 +92,7 @@ import ca.nrc.cadc.ac.server.UserPersistence;
import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.IdentityType;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.Log4jInit;
import ca.nrc.cadc.util.ObjectUtil;
......@@ -118,7 +119,7 @@ public class RemoveUserMemberActionTest
{
User user = new User();
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()));
ObjectUtil.setField(user, internalID, "id");
......@@ -172,7 +173,7 @@ public class RemoveUserMemberActionTest
{
User user = new User();
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()));
ObjectUtil.setField(user, internalID, "id");
......
......@@ -104,6 +104,7 @@ import ca.nrc.cadc.auth.IdentityType;
import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.auth.OpenIdPrincipal;
import ca.nrc.cadc.date.DateUtil;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
/**
......@@ -156,7 +157,7 @@ public abstract class AbstractReaderWriter
public AbstractReaderWriter()
{
LocalAuthority localAuthority = new LocalAuthority();
URI serviceURI = localAuthority.getServiceURI("ac");
URI serviceURI = localAuthority.getServiceURI(Standards.GMS_GROUPS_01.toString());
gmsServiceURI = serviceURI.toString();
}
......
......@@ -86,6 +86,7 @@ import org.junit.Test;
import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.auth.NumericPrincipal;
import ca.nrc.cadc.reg.Standards;
import ca.nrc.cadc.reg.client.LocalAuthority;
import ca.nrc.cadc.util.Log4jInit;
......@@ -101,7 +102,7 @@ public class UserClientTest
{
Log4jInit.setLevel("ca.nrc.cadc.ac", Level.INFO);
LocalAuthority localAuthority = new LocalAuthority();
umsServiceURI = localAuthority.getServiceURI("ac");
umsServiceURI = localAuthority.getServiceURI(Standards.UMS_USERS_01.toString());
}
@Test
......
......@@ -86,7 +86,7 @@
<!-- developer convenience: place for extra targets and properties -->
<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="tomcat" value="${ext.lib}/catalina.jar:${ext.lib}/tomcat-util.jar:${ext.lib}/tomcat-coyote.jar" />
<property name="jars" value="${cadc}:${log4j}:${tomcat}" />
......
......@@ -83,6 +83,8 @@ import org.apache.catalina.realm.RealmBase;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import ca.nrc.cadc.reg.Standards;
/**
* Custom class for Tomcat realm authentication.
*
......@@ -97,7 +99,7 @@ public class CadcBasicAuthenticator extends RealmBase
{
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
{
......
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