1 13 14 package org.ejbca.ui.cli; 15 16 import java.util.Collection ; 17 import java.util.Iterator ; 18 19 import org.ejbca.core.ejb.ca.caadmin.ICAAdminSessionRemote; 20 import org.ejbca.core.model.ca.caadmin.CAInfo; 21 22 27 public class CaListCAsCommand extends BaseCaAdminCommand { 28 33 public CaListCAsCommand(String [] args) { 34 super(args); 35 } 36 37 43 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 44 45 if (args.length > 1) { 46 String msg = "Lists the names of all available CAs.\nUsage: CA listcas"; 47 throw new IllegalAdminCommandException(msg); 48 } 49 try { 50 ICAAdminSessionRemote casession = getCAAdminSessionRemote(); 51 Collection caids = casession.getAvailableCAs(administrator); 52 Iterator iter = caids.iterator(); 53 while (iter.hasNext()) { 54 int caid = ((Integer )iter.next()).intValue(); 55 CAInfo ca = casession.getCAInfo(administrator,caid); 56 getOutputStream().println(); 57 getOutputStream().println("CA Name: "+ca.getName()); 58 getOutputStream().println("Id: "+ca.getCAId()); 59 getOutputStream().println("DN: "+ca.getSubjectDN()); 60 getOutputStream().println("Type: "+ca.getCAType()); 61 getOutputStream().println("Expire time: "+ca.getExpireTime()); 62 getOutputStream().println("Signed by: "+ca.getSignedBy()); 63 } 64 } catch (Exception e) { 65 throw new ErrorAdminCommandException(e); 66 } 67 } } 69 | Popular Tags |