1 13 14 package org.ejbca.ui.cli; 15 16 import java.io.FileOutputStream ; 17 18 import javax.naming.Context ; 19 20 import org.ejbca.core.ejb.ca.store.ICertificateStoreSessionHome; 21 import org.ejbca.core.ejb.ca.store.ICertificateStoreSessionRemote; 22 23 24 29 public class CaGetCrlCommand extends BaseCaAdminCommand { 30 35 public CaGetCrlCommand(String [] args) { 36 super(args); 37 } 38 39 45 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 46 if (args.length < 3) { 47 throw new IllegalAdminCommandException("Retrieves CRL in DER format.\nUsage: CA getcrl <caname> <outfile>"); 48 } 49 try { 50 String outfile = args[2]; 51 String caname = args[1]; 52 String issuerdn = getIssuerDN(caname); 53 Context context = getInitialContext(); 54 ICertificateStoreSessionHome storehome = (ICertificateStoreSessionHome) javax.rmi.PortableRemoteObject.narrow(context.lookup("CertificateStoreSession"),ICertificateStoreSessionHome.class); 55 ICertificateStoreSessionRemote store = storehome.create(); 56 byte[] crl = store.getLastCRL(administrator, issuerdn); 57 FileOutputStream fos = new FileOutputStream (outfile); 58 fos.write(crl); 59 fos.close(); 60 getOutputStream().println("Wrote latest CRL to " + outfile + "."); 61 } catch (Exception e) { 62 throw new ErrorAdminCommandException(e); 63 } 64 } 66 } 67 | Popular Tags |