Skip to content
Snippets Groups Projects
Commit 643c9b28 authored by Jeff Burke's avatar Jeff Burke
Browse files

Merge branch 's1651' of ssh://mach16/usr/cadc/dev/git/wopencadc into s1651

parents 4292bc53 e3ebdacb
No related branches found
No related tags found
No related merge requests found
...@@ -68,15 +68,16 @@ ...@@ -68,15 +68,16 @@
*/ */
package ca.nrc.cadc.ac.server; package ca.nrc.cadc.ac.server;
import java.util.List;
import org.apache.log4j.Logger;
import ca.nrc.cadc.ac.IdentityType; import ca.nrc.cadc.ac.IdentityType;
import ca.nrc.cadc.ac.Role; import ca.nrc.cadc.ac.Role;
import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.uws.Parameter; import ca.nrc.cadc.uws.Parameter;
import ca.nrc.cadc.uws.ParameterUtil; import ca.nrc.cadc.uws.ParameterUtil;
import java.security.Principal;
import java.util.List;
import org.apache.log4j.Logger;
/** /**
* Request Validator. This class extracts and validates the ID, TYPE, ROLE * Request Validator. This class extracts and validates the ID, TYPE, ROLE
* and GURI parameters. * and GURI parameters.
...@@ -86,8 +87,7 @@ public class RequestValidator ...@@ -86,8 +87,7 @@ public class RequestValidator
{ {
private static final Logger log = Logger.getLogger(RequestValidator.class); private static final Logger log = Logger.getLogger(RequestValidator.class);
private String userID; private Principal principal;
private IdentityType idType;
private Role role; private Role role;
private String groupID; private String groupID;
...@@ -95,8 +95,7 @@ public class RequestValidator ...@@ -95,8 +95,7 @@ public class RequestValidator
private void clear() private void clear()
{ {
this.userID = null; this.principal = null;
this.idType = null;
this.role = null; this.role = null;
this.groupID = null; this.groupID = null;
} }
...@@ -107,7 +106,7 @@ public class RequestValidator ...@@ -107,7 +106,7 @@ public class RequestValidator
if (paramList == null || paramList.isEmpty()) if (paramList == null || paramList.isEmpty())
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Missing required parameters: ID and IDTYPE"); "Missing required parameters: ID and TYPE");
} }
// ID // ID
...@@ -117,18 +116,21 @@ public class RequestValidator ...@@ -117,18 +116,21 @@ public class RequestValidator
throw new IllegalArgumentException( throw new IllegalArgumentException(
"ID parameter required but not found"); "ID parameter required but not found");
} }
this.userID = param.trim(); String userID = param.trim();
log.debug("ID: " + userID); log.debug("ID: " + userID);
// IDTYPE // TYPE
param = ParameterUtil.findParameterValue("IDTYPE", paramList); param = ParameterUtil.findParameterValue("IDTYPE", paramList);
if (param == null || param.trim().isEmpty()) if (param == null || param.trim().isEmpty())
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"IDTYPE parameter required but not found"); "IDTYPE parameter required but not found");
} }
this.idType = IdentityType.toValue(param);
log.debug("TYPE: " + idType); principal =
AuthenticationUtil.createPrincipal(userID,
param.trim());
log.debug("TYPE: " + param.trim());
// ROLE // ROLE
param = ParameterUtil.findParameterValue("ROLE", paramList); param = ParameterUtil.findParameterValue("ROLE", paramList);
...@@ -151,15 +153,10 @@ public class RequestValidator ...@@ -151,15 +153,10 @@ public class RequestValidator
} }
log.debug("GROUPID: " + groupID); log.debug("GROUPID: " + groupID);
} }
public String getUserID()
{
return userID;
}
public IdentityType getIDType() public Principal getPrincipal()
{ {
return idType; return principal;
} }
public Role getRole() public Role getRole()
......
...@@ -166,14 +166,10 @@ public class ACSearchRunner implements JobRunner ...@@ -166,14 +166,10 @@ public class ACSearchRunner implements JobRunner
RequestValidator rv = new RequestValidator(); RequestValidator rv = new RequestValidator();
rv.validate(job.getParameterList()); rv.validate(job.getParameterList());
Principal userID =
AuthenticationUtil.createPrincipal(rv.getUserID(),
rv.getIDType().getValue());
PluginFactory factory = new PluginFactory(); PluginFactory factory = new PluginFactory();
GroupPersistence dao = factory.getGroupPersistence(); GroupPersistence dao = factory.getGroupPersistence();
Collection<Group> groups = Collection<Group> groups =
dao.getGroups(userID, rv.getRole(), rv.getGroupID()); dao.getGroups(rv.getPrincipal(), rv.getRole(), rv.getGroupID());
syncOut.setResponseCode(HttpServletResponse.SC_OK); syncOut.setResponseCode(HttpServletResponse.SC_OK);
GroupsWriter.write(groups, syncOut.getOutputStream()); GroupsWriter.write(groups, syncOut.getOutputStream());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment