1 18 package org.apache.geronimo.ca.helper.util; 19 20 import java.math.BigInteger ; 21 import java.util.Iterator ; 22 import java.util.Set ; 23 24 import org.apache.geronimo.gbean.AbstractName; 25 import org.apache.geronimo.gbean.AbstractNameQuery; 26 import org.apache.geronimo.kernel.Kernel; 27 import org.apache.geronimo.kernel.KernelRegistry; 28 import org.apache.geronimo.management.geronimo.CertificateRequestStore; 29 import org.apache.geronimo.management.geronimo.CertificateStore; 30 import org.apache.geronimo.management.geronimo.SecureConnector; 31 32 37 public class CAHelperUtils { 38 43 public static void removeRequest(String csrId, BigInteger sNo) { 44 getCertificateRequestStore().removeRequestStatus(csrId, sNo); 45 } 46 47 50 public static CertificateRequestStore getCertificateRequestStore() { 51 Kernel kernel = KernelRegistry.getSingleKernel(); 52 53 AbstractNameQuery certReqStoreQuery = new AbstractNameQuery(org.apache.geronimo.management.geronimo.CertificateRequestStore.class.getName()); 54 Set set = kernel.listGBeans(certReqStoreQuery); 55 try { 56 CertificateRequestStore certReqStore = (CertificateRequestStore)kernel.getGBean((AbstractName)set.iterator().next()); 57 return certReqStore; 58 } catch (Exception e) { 59 e.printStackTrace(); 60 } 61 return null; 62 } 63 64 67 public static CertificateStore getCertificateStore() { 68 Kernel kernel = KernelRegistry.getSingleKernel(); 69 70 AbstractNameQuery certStoreQuery = new AbstractNameQuery(org.apache.geronimo.management.geronimo.CertificateStore.class.getName()); 71 Set set = kernel.listGBeans(certStoreQuery); 72 try { 73 CertificateStore certStore = (CertificateStore)kernel.getGBean((AbstractName)set.iterator().next()); 74 return certStore; 75 } catch(Exception e) { 76 e.printStackTrace(); 77 } 78 return null; 79 } 80 81 87 public static int getHttpsClientAuthPort() { 88 Kernel kernel = KernelRegistry.getSingleKernel(); 89 90 AbstractNameQuery connectorQuery = new AbstractNameQuery(SecureConnector.class.getName()); 91 Set set = kernel.listGBeans(connectorQuery); 92 for(Iterator itr = set.iterator(); itr.hasNext(); ){ 93 try { 94 SecureConnector connector = (SecureConnector)kernel.getGBean((AbstractName)itr.next()); 95 if(connector.isClientAuthRequired()) 96 return connector.getPort(); 97 } catch(Exception e) { 98 e.printStackTrace(); 99 } 100 } 101 return -1; 102 } 103 } 104 | Popular Tags |