1 13 14 package org.ejbca.core.protocol.ws.client; 15 16 import org.ejbca.core.model.ca.crl.RevokedCertInfo; 17 import org.ejbca.core.protocol.ws.client.gen.AuthorizationDeniedException_Exception; 18 import org.ejbca.ui.cli.ErrorAdminCommandException; 19 import org.ejbca.ui.cli.IAdminCommand; 20 import org.ejbca.ui.cli.IllegalAdminCommandException; 21 22 27 public class RevokeTokenCommand extends EJBCAWSRABaseCommand implements IAdminCommand{ 28 29 30 private static final int ARG_HARDTOKENSN = 1; 31 private static final int ARG_REASON = 2; 32 33 34 39 public RevokeTokenCommand(String [] args) { 40 super(args); 41 } 42 43 49 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 50 try { 51 52 if(args.length != 3){ 53 usage(); 54 System.exit(-1); 55 } 56 57 String hardtokensn = args[ARG_HARDTOKENSN]; 58 int reason = getRevokeReason(args[ARG_REASON]); 59 60 if(reason == RevokedCertInfo.NOT_REVOKED){ 61 getPrintStream().println("Error : Unsupported reason " + reason); 62 usage(); 63 System.exit(-1); 64 } 65 66 try{ 67 68 getEjbcaRAWS().revokeToken(hardtokensn,reason); 69 getPrintStream().println("Token revoked sucessfully"); 70 }catch(AuthorizationDeniedException_Exception e){ 71 getPrintStream().println("Error : " + e.getMessage()); 72 } 73 } catch (Exception e) { 74 throw new ErrorAdminCommandException(e); 75 } 76 } 77 78 79 80 81 protected void usage() { 82 getPrintStream().println("Command used to revoke a tokens certificate"); 83 getPrintStream().println("Usage : revokecert <hardtokensn> <reason> \n\n"); 84 getPrintStream().println("Reason should be one of : "); 85 for(int i=1; i< REASON_TEXTS.length-1;i++){ 86 getPrintStream().print(REASON_TEXTS[i] + ", "); 87 } 88 getPrintStream().print(REASON_TEXTS[REASON_TEXTS.length-1]); 89 } 90 91 92 } 93 | Popular Tags |