Skip to content
Snippets Groups Projects
Commit f7c482d6 authored by bmajor's avatar bmajor
Browse files

Merge pull request #1 from bertocco/collaboration

Collaboration - Merged pull request for DN handling changes to approve user.
parents 9f245ce9 f9e2eab9
Branches
Tags
No related merge requests found
...@@ -155,8 +155,11 @@ ...@@ -155,8 +155,11 @@
<property name="easymock" value="${ext.dev}/easymock.jar" /> <property name="easymock" value="${ext.dev}/easymock.jar" />
<property name="junit" value="${ext.dev}/junit.jar" /> <property name="junit" value="${ext.dev}/junit.jar" />
<property name="objenesis" value="${ext.dev}/objenesis.jar" /> <property name="objenesis" value="${ext.dev}/objenesis.jar" />
<property name="jdom2" value="${ext.dev}/jdom2.jar"/>
<property name="json" value="${ext.dev}/json.jar" />
<property name="jsonassert" value="${ext.dev}/jsonassert.jar" />
<property name="testingJars" value="${junit}:${asm}:${cglib}:${easymock}:${objenesis}:{unboundid}:${cadcLog}"/> <property name="testingJars" value="${jsonassert}:${junit}:${asm}:${cglib}:${easymock}:${objenesis}:${jdom2}:${json}:${cadcLog}"/>
<target name="int-test" depends="build,compile-test,setup-test"> <target name="int-test" depends="build,compile-test,setup-test">
<echo message="Running test suite..."/> <echo message="Running test suite..."/>
......
...@@ -93,6 +93,7 @@ import ca.nrc.cadc.auth.HttpPrincipal; ...@@ -93,6 +93,7 @@ import ca.nrc.cadc.auth.HttpPrincipal;
import ca.nrc.cadc.net.TransientException; import ca.nrc.cadc.net.TransientException;
import ca.nrc.cadc.util.PropertiesReader; import ca.nrc.cadc.util.PropertiesReader;
/** /**
* This class approves the specified pending user by moving the user * This class approves the specified pending user by moving the user
* from a pending user to an active user in the LDAP server. * from a pending user to an active user in the LDAP server.
...@@ -114,9 +115,11 @@ public class ApproveUser extends AbstractUserCommand ...@@ -114,9 +115,11 @@ public class ApproveUser extends AbstractUserCommand
private String dn; private String dn;
/** /**
* Constructor * Constructor
* @param userID Id of the pending user to be approved * @param userID Id of the pending user to be approved
* @param dn of the pending user to be approved
*/ */
public ApproveUser(final String userID, final String dn) public ApproveUser(final String userID, final String dn)
{ {
...@@ -124,9 +127,57 @@ public class ApproveUser extends AbstractUserCommand ...@@ -124,9 +127,57 @@ public class ApproveUser extends AbstractUserCommand
this.dn = dn; this.dn = dn;
} }
/**
* Constructor
* @param userID Id of the pending user to be approved
*/
public ApproveUser(final String userID)
{
super(userID);
}
protected void execute() protected void execute()
throws AccessControlException, UserNotFoundException, TransientException throws AccessControlException, UserNotFoundException, TransientException
{ {
User<Principal> user = null;
try
{
// Search the user in the pending tree
user = this.getUserPersistence().getPendingUser(this.getPrincipal());
}
catch (Exception e)
{
log.info("User not found in userRequests");
this.systemOut.println("User not found in userRequests. Impossible to approve it.");
this.systemOut.println("Check the validity of the provided uid.");
return;
}
log.debug("User found in userRequests");
// If user DN is not provided by command line, search if it is available in UserRequests
if (dn == null || dn.isEmpty()) {
boolean foundDN = false;
for (Principal p : user.getIdentities())
{
if (p instanceof X500Principal)
{
this.dn = p.getName();
log.debug("User DN FOUND in pendingUser. userDN = " + dn);
foundDN = true;
break;
}
}
if(!foundDN)
{
log.debug("User DN NOT FOUND in UserRequests.");
this.systemOut.println("User DN not found in userRequests.");
this.systemOut.println("Use --dn option to provide a valid user DN");
return;
}
}
X500Principal dnPrincipal = null; X500Principal dnPrincipal = null;
try try
{ {
...@@ -150,7 +201,7 @@ public class ApproveUser extends AbstractUserCommand ...@@ -150,7 +201,7 @@ public class ApproveUser extends AbstractUserCommand
this.systemOut.println("Could not find pending user " + this.getPrincipal()); this.systemOut.println("Could not find pending user " + this.getPrincipal());
} }
User<Principal> user = null; user = null;
try try
{ {
user = this.getUserPersistence().getUser(this.getPrincipal()); user = this.getUserPersistence().getUser(this.getPrincipal());
......
...@@ -231,7 +231,7 @@ public class CmdLineParser ...@@ -231,7 +231,7 @@ public class CmdLineParser
} }
else else
{ {
throw new UsageException("Missing parameter 'dn'"); this.command = new ApproveUser(userID);
} }
} }
......
...@@ -124,9 +124,10 @@ ...@@ -124,9 +124,10 @@
<property name="dev.easyMock" value="${ext.dev}/easymock.jar"/> <property name="dev.easyMock" value="${ext.dev}/easymock.jar"/>
<property name="dev.objenesis" value="${ext.dev}/objenesis.jar"/> <property name="dev.objenesis" value="${ext.dev}/objenesis.jar"/>
<property name="dev.jsonassert" value="${ext.dev}/jsonassert.jar" /> <property name="dev.jsonassert" value="${ext.dev}/jsonassert.jar" />
<property name="dev.mail" value="${ext.dev}/mail.jar" />
<property name="lib.xerces" value="${ext.lib}/xerces.jar"/> <property name="lib.xerces" value="${ext.lib}/xerces.jar"/>
<property name="lib.commons-logging" value="${ext.lib}/commons-logging.jar"/> <property name="lib.commons-logging" value="${ext.lib}/commons-logging.jar"/>
<property name="testingJars" value="${lib.commons-logging}:${dev.junit}:${dev.jsonassert}:${dev.asm}:${dev.cglib}:${dev.easyMock}:${dev.objenesis}:${lib.xerces}"/> <property name="testingJars" value="${lib.commons-logging}:${dev.junit}:${dev.jsonassert}:${dev.asm}:${dev.cglib}:${dev.easyMock}:${dev.objenesis}:${lib.xerces}:${dev.mail}"/>
<target name="single-test" depends="compile,compile-test"> <target name="single-test" depends="compile,compile-test">
<echo message="Running test suite..." /> <echo message="Running test suite..." />
......
...@@ -112,8 +112,8 @@ ...@@ -112,8 +112,8 @@
<property name="junit" value="${ext.dev}/junit.jar" /> <property name="junit" value="${ext.dev}/junit.jar" />
<property name="objenesis" value="${ext.dev}/objenesis.jar" /> <property name="objenesis" value="${ext.dev}/objenesis.jar" />
<property name="jsonassert" value="${ext.dev}/jsonassert.jar" /> <property name="jsonassert" value="${ext.dev}/jsonassert.jar" />
<property name="mail" value="${ext.dev}/mail.jar" />
<property name="testingJars" value="${build}/class:${jsonassert}:${jars}:${xerces}:${asm}:${cglib}:${easymock}:${junit}:${objenesis}" /> <property name="testingJars" value="${build}/class:${xerces}:${jsonassert}:${jars}:${asm}:${cglib}:${easymock}:${junit}:${objenesis}:${mail}" />
<target name="single-test" depends="compile,compile-test"> <target name="single-test" depends="compile,compile-test">
<echo message="Running test suite..." /> <echo message="Running test suite..." />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment