1 13 14 package org.ejbca.ui.cli; 15 16 import org.ejbca.core.model.authorization.AuthorizationDeniedException; 17 import org.ejbca.core.model.ra.UserDataConstants; 18 import org.ejbca.core.model.ra.UserDataVO; 19 20 21 22 23 24 29 public class RaRevokeUserCommand extends BaseRaAdminCommand { 30 35 public RaRevokeUserCommand(String [] args) { 36 super(args); 37 } 38 39 45 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 46 try { 47 if (args.length < 3) { 48 getOutputStream().println("Usage: RA revokeuser <username> <reason>"); 49 getOutputStream().println( 50 "Reason: unused(0), keyCompromise(1), cACompromise(2), affiliationChanged(3), superseded(4), cessationOfOperation(5), certficateHold(6), removeFromCRL(8),privilegeWithdrawn(9),aACompromise(10)"); 51 getOutputStream().println("Normal reason is 0"); 52 53 return; 54 } 55 56 String username = args[1]; 57 int reason = Integer.parseInt(args[2]); 58 59 if ((reason == 7) || (reason < 0) || (reason > 10)) { 60 getOutputStream().println("Error : Reason must be an integer between 0 and 10 except 7."); 61 } else { 62 UserDataVO data = getAdminSession().findUser(administrator, username); 63 getOutputStream().println("Found user:"); 64 getOutputStream().println("username=" + data.getUsername()); 65 getOutputStream().println("dn=\"" + data.getDN() + "\""); 66 getOutputStream().println("Old status=" + data.getStatus()); 67 getAdminSession().setUserStatus(administrator, username, 68 UserDataConstants.STATUS_REVOKED); 69 getOutputStream().println("New status=" + UserDataConstants.STATUS_REVOKED); 70 71 try { 73 getAdminSession().revokeUser(administrator, username, reason); 74 } catch (AuthorizationDeniedException e) { 75 getOutputStream().println("Error : Not authorized to revoke user."); 76 } 77 } 78 } catch (Exception e) { 79 throw new ErrorAdminCommandException(e); 80 } 81 } 82 83 } 85 | Popular Tags |