1 13 14 package org.ejbca.ui.cli; 15 16 import org.ejbca.core.model.SecConst; 17 import org.ejbca.core.model.ca.caadmin.CAInfo; 18 import org.ejbca.core.model.ca.catoken.HardCATokenInfo; 19 20 21 22 23 24 29 public class CaDeactivateCACommand extends BaseCaAdminCommand { 30 35 public CaDeactivateCACommand(String [] args) { 36 super(args); 37 } 38 39 45 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 46 try { 47 if (args.length < 2) { 48 getOutputStream().println("Usage: CA deactivateca <CA name> "); 49 return; 50 } 51 52 String caname = args[1]; 53 54 CAInfo cainfo = getCAAdminSessionRemote().getCAInfo(administrator, caname); 56 if(cainfo == null){ 57 getOutputStream().println("Error: CA " + caname + " cannot be found"); 58 return; 59 } 60 61 if(!(cainfo.getCATokenInfo() instanceof HardCATokenInfo)){ 63 getOutputStream().println("Error: CA have a Soft CAToken and cannot be deactivated"); 64 return; 65 } 66 67 if(cainfo.getStatus() == SecConst.CA_ACTIVE){ 68 getCAAdminSessionRemote().deactivateCAToken(administrator, cainfo.getCAId()); 69 }else{ 70 getOutputStream().println("Error: CA or CAToken must be active to be put offline."); 71 } 72 73 } catch (Exception e) { 74 throw new ErrorAdminCommandException(e); 75 } 76 } } 78 | Popular Tags |