Loading projects/cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/ApproveUser.java +17 −8 Original line number Diff line number Diff line Loading @@ -72,6 +72,8 @@ package ca.nrc.cadc.ac.admin; import java.security.AccessControlException; import java.security.Principal; import javax.security.auth.x500.X500Principal; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.User; Loading @@ -87,22 +89,29 @@ import ca.nrc.cadc.net.TransientException; public class ApproveUser extends AbstractUserCommand { private static final Logger log = Logger.getLogger(ApproveUser.class); private String dn; /** * Constructor * @param userID Id of the pending user to be approved */ public ApproveUser(final String userID) public ApproveUser(final String userID, final String dn) { super(userID); this.dn = dn; } protected void execute() throws AccessControlException, UserNotFoundException, TransientException { User<Principal> user = this.getUserPersistence().approvePendingUser(this.getPrincipal()); String msg = "User " + this.getPrincipal().getName() + " was approved successfully."; this.systemOut.println(msg); this.systemOut.println("User " + this.getPrincipal().getName() + " was approved successfully."); log.debug("approved user, now setting dn"); user = this.getUserPersistence().getUser(this.getPrincipal()); X500Principal dnPrincipal = new X500Principal(dn); user.getIdentities().add(dnPrincipal); this.getUserPersistence().modifyUser(user); this.systemOut.println("User " + this.getPrincipal().getName() + " now has DN " + dn); this.printUser(user); } } projects/cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/CmdLineParser.java +20 −12 Original line number Diff line number Diff line Loading @@ -222,7 +222,15 @@ public class CmdLineParser { if (this.hasValue(userID)) { this.command = new ApproveUser(userID); String dn = am.getValue("dn"); if (dn != null) { this.command = new ApproveUser(userID, dn); } else { throw new UsageException("Missing parameter 'dn'"); } } count++; Loading Loading @@ -285,14 +293,14 @@ public class CmdLineParser sb.append("\n"); sb.append("Usage: " + APP_NAME + " <command> [-v|--verbose|-d|--debug] [-h|--help]\n"); sb.append("Where command is\n"); sb.append("--list :list users in the Users tree\n"); sb.append(" :can be executed as an anonymous user\n"); sb.append("--list-pending :list users in the UserRequests tree\n"); sb.append(" :can be executed as an anonymous user\n"); sb.append("--view=<userid> :print the entire details of the user\n"); sb.append("--approve=<userid> :delete the user from the UserRequests tree\n"); sb.append(" :and insert it into the Users tree\n"); sb.append("--reject=<userid> :delete the user from the UserRequests tree\n"); sb.append("--list : List users in the Users tree\n"); sb.append(" can be executed as an anonymous user\n"); sb.append("--list-pending : List users in the UserRequests tree\n"); sb.append(" can be executed as an anonymous user\n"); sb.append("--view=<userid> : Print the entire details of the user\n"); sb.append("--approve=<userid> --dn=<dn> : Delete the user from the UserRequests tree\n"); sb.append(" and insert it into the Users tree\n"); sb.append("--reject=<userid> : Delete the user from the UserRequests tree\n"); sb.append("\n"); sb.append("-v|--verbose : Verbose mode print progress and error messages\n"); sb.append("-d|--debug : Debug mode print all the logging messages\n"); Loading Loading
projects/cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/ApproveUser.java +17 −8 Original line number Diff line number Diff line Loading @@ -72,6 +72,8 @@ package ca.nrc.cadc.ac.admin; import java.security.AccessControlException; import java.security.Principal; import javax.security.auth.x500.X500Principal; import org.apache.log4j.Logger; import ca.nrc.cadc.ac.User; Loading @@ -87,22 +89,29 @@ import ca.nrc.cadc.net.TransientException; public class ApproveUser extends AbstractUserCommand { private static final Logger log = Logger.getLogger(ApproveUser.class); private String dn; /** * Constructor * @param userID Id of the pending user to be approved */ public ApproveUser(final String userID) public ApproveUser(final String userID, final String dn) { super(userID); this.dn = dn; } protected void execute() throws AccessControlException, UserNotFoundException, TransientException { User<Principal> user = this.getUserPersistence().approvePendingUser(this.getPrincipal()); String msg = "User " + this.getPrincipal().getName() + " was approved successfully."; this.systemOut.println(msg); this.systemOut.println("User " + this.getPrincipal().getName() + " was approved successfully."); log.debug("approved user, now setting dn"); user = this.getUserPersistence().getUser(this.getPrincipal()); X500Principal dnPrincipal = new X500Principal(dn); user.getIdentities().add(dnPrincipal); this.getUserPersistence().modifyUser(user); this.systemOut.println("User " + this.getPrincipal().getName() + " now has DN " + dn); this.printUser(user); } }
projects/cadcAccessControl-Admin/src/ca/nrc/cadc/ac/admin/CmdLineParser.java +20 −12 Original line number Diff line number Diff line Loading @@ -222,7 +222,15 @@ public class CmdLineParser { if (this.hasValue(userID)) { this.command = new ApproveUser(userID); String dn = am.getValue("dn"); if (dn != null) { this.command = new ApproveUser(userID, dn); } else { throw new UsageException("Missing parameter 'dn'"); } } count++; Loading Loading @@ -285,14 +293,14 @@ public class CmdLineParser sb.append("\n"); sb.append("Usage: " + APP_NAME + " <command> [-v|--verbose|-d|--debug] [-h|--help]\n"); sb.append("Where command is\n"); sb.append("--list :list users in the Users tree\n"); sb.append(" :can be executed as an anonymous user\n"); sb.append("--list-pending :list users in the UserRequests tree\n"); sb.append(" :can be executed as an anonymous user\n"); sb.append("--view=<userid> :print the entire details of the user\n"); sb.append("--approve=<userid> :delete the user from the UserRequests tree\n"); sb.append(" :and insert it into the Users tree\n"); sb.append("--reject=<userid> :delete the user from the UserRequests tree\n"); sb.append("--list : List users in the Users tree\n"); sb.append(" can be executed as an anonymous user\n"); sb.append("--list-pending : List users in the UserRequests tree\n"); sb.append(" can be executed as an anonymous user\n"); sb.append("--view=<userid> : Print the entire details of the user\n"); sb.append("--approve=<userid> --dn=<dn> : Delete the user from the UserRequests tree\n"); sb.append(" and insert it into the Users tree\n"); sb.append("--reject=<userid> : Delete the user from the UserRequests tree\n"); sb.append("\n"); sb.append("-v|--verbose : Verbose mode print progress and error messages\n"); sb.append("-d|--debug : Debug mode print all the logging messages\n"); Loading