Skip to content
Snippets Groups Projects
Commit ad4fc1e6 authored by Patrick Dowler's avatar Patrick Dowler
Browse files

improved ldap queries for getGroups; added --delete option to command-line GMS client

parent fafc8195
No related branches found
No related tags found
No related merge requests found
...@@ -132,17 +132,17 @@ ...@@ -132,17 +132,17 @@
</copy> </copy>
</target> </target>
<!--<target name="test" depends="compile,compile-test,resources">--> <!--
<!--<echo message="Running test suite..." />--> <target name="group-dao-test" depends="compile,compile-test,resources">
<!--<junit printsummary="yes" haltonfailure="yes" fork="yes">--> <junit printsummary="yes" haltonfailure="yes" fork="yes">
<!--<classpath>--> <classpath>
<!--<pathelement path="${build}/class"/>--> <pathelement path="${build}/class"/>
<!--<pathelement path="${build}/test/class"/>--> <pathelement path="${build}/test/class"/>
<!--<pathelement path="${testingJars}"/>--> <pathelement path="${testingJars}"/>
<!--</classpath>--> </classpath>
<!--<test name="ca.nrc.cadc.ac.server.ldap.LdapGroupDAOTest" />--> <test name="ca.nrc.cadc.ac.server.ldap.LdapGroupDAOTest" />
<!--<formatter type="plain" usefile="false" />--> <formatter type="plain" usefile="false" />
<!--</junit>--> </junit>
<!--</target>--> </target>
-->
</project> </project>
...@@ -336,6 +336,23 @@ public class ACSearchRunner implements JobRunner ...@@ -336,6 +336,23 @@ public class ACSearchRunner implements JobRunner
// } // }
} }
*/ */
catch(IllegalArgumentException ex)
{
logInfo.setSuccess(true);
logInfo.setMessage(ex.getMessage());
log.debug("FAIL", ex);
syncOut.setResponseCode(400);
syncOut.setHeader("Content-Type", "text/plain");
try
{
syncOut.getOutputStream().write(ex.getMessage().getBytes());
}
catch (IOException e)
{
log.warn("Could not write response to output stream", e);
}
}
catch (AccessControlException t) catch (AccessControlException t)
{ {
logInfo.setSuccess(true); logInfo.setSuccess(true);
......
...@@ -863,18 +863,10 @@ public class LdapGroupDAOTest extends AbstractLdapDAOTest ...@@ -863,18 +863,10 @@ public class LdapGroupDAOTest extends AbstractLdapDAOTest
getGroupDAO().getGroups(unknownPrincipal, Role.OWNER, getGroupDAO().getGroups(unknownPrincipal, Role.OWNER,
groupID); groupID);
fail("searchGroups with unknown user should throw " + fail("searchGroups with unknown user should throw " +
"UserNotFoundException"); "AccessControlException");
} }
catch (AccessControlException ignore) {} catch (AccessControlException ignore) {}
try
{
getGroupDAO().getGroups(daoTestPrincipal1, Role.OWNER,
"foo");
fail("searchGroups with unknown user should throw " +
"GroupNotFoundException");
}
catch (GroupNotFoundException ignore) {}
return null; return null;
} }
}); });
......
...@@ -103,6 +103,7 @@ public class GMSClientMain implements PrivilegedAction<Object> ...@@ -103,6 +103,7 @@ public class GMSClientMain implements PrivilegedAction<Object>
public static final String ARG_ADD_MEMBER = "add-member"; public static final String ARG_ADD_MEMBER = "add-member";
public static final String ARG_CREATE_GROUP = "create"; public static final String ARG_CREATE_GROUP = "create";
public static final String ARG_GET_GROUP = "get"; public static final String ARG_GET_GROUP = "get";
public static final String ARG_DELETE_GROUP = "delete";
public static final String ARG_USERID = "userid"; public static final String ARG_USERID = "userid";
public static final String ARG_GROUP = "group"; public static final String ARG_GROUP = "group";
...@@ -181,6 +182,9 @@ public class GMSClientMain implements PrivilegedAction<Object> ...@@ -181,6 +182,9 @@ public class GMSClientMain implements PrivilegedAction<Object>
if (argMap.isSet(ARG_GET_GROUP)) if (argMap.isSet(ARG_GET_GROUP))
return ARG_GET_GROUP; return ARG_GET_GROUP;
if (argMap.isSet(ARG_DELETE_GROUP))
return ARG_DELETE_GROUP;
throw new IllegalArgumentException("No valid commands"); throw new IllegalArgumentException("No valid commands");
} }
...@@ -190,7 +194,7 @@ public class GMSClientMain implements PrivilegedAction<Object> ...@@ -190,7 +194,7 @@ public class GMSClientMain implements PrivilegedAction<Object>
System.out.println("--add-member --group=<g> --userid=<u>"); System.out.println("--add-member --group=<g> --userid=<u>");
System.out.println("--create --group=<g>"); System.out.println("--create --group=<g>");
System.out.println("--get --group=<g>"); System.out.println("--get --group=<g>");
System.out.println("--delete --group=<g>");
} }
@Override @Override
...@@ -213,8 +217,7 @@ public class GMSClientMain implements PrivilegedAction<Object> ...@@ -213,8 +217,7 @@ public class GMSClientMain implements PrivilegedAction<Object>
client.addUserMember(group, new HttpPrincipal(userID)); client.addUserMember(group, new HttpPrincipal(userID));
} }
else if (command.equals(ARG_CREATE_GROUP))
if (command.equals(ARG_CREATE_GROUP))
{ {
String group = argMap.getValue(ARG_GROUP); String group = argMap.getValue(ARG_GROUP);
if (group == null) if (group == null)
...@@ -229,8 +232,7 @@ public class GMSClientMain implements PrivilegedAction<Object> ...@@ -229,8 +232,7 @@ public class GMSClientMain implements PrivilegedAction<Object>
g.getUserMembers().add(g.getOwner()); g.getUserMembers().add(g.getOwner());
client.createGroup(g); client.createGroup(g);
} }
else if (command.equals(ARG_GET_GROUP))
if (command.equals(ARG_GET_GROUP))
{ {
String group = argMap.getValue(ARG_GROUP); String group = argMap.getValue(ARG_GROUP);
if (group == null) if (group == null)
...@@ -254,6 +256,14 @@ public class GMSClientMain implements PrivilegedAction<Object> ...@@ -254,6 +256,14 @@ public class GMSClientMain implements PrivilegedAction<Object>
System.out.println("member: " + gm); System.out.println("member: " + gm);
} }
else if (command.equals(ARG_DELETE_GROUP))
{
String group = argMap.getValue(ARG_GROUP);
if (group == null)
throw new IllegalArgumentException("No group specified");
client.deleteGroup(group);
}
return null; return null;
} }
......
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