// Get hold of configuration containing caKeystore GBean
AbstractName caKeystoreName = PortletManager.getNameFor(request, caKeystore);
Artifact configurationId = PortletManager.getConfigurationFor(request, caKeystoreName);
ServerInfo serverInfo = PortletManager.getCurrentServer(request).getServerInfo();
AbstractName serverInfoName = PortletManager.getNameFor(request, serverInfo);
Naming naming = PortletManager.getManagementHelper(request).getNaming();
// Add a CertificateStore GBean
AbstractName certStoreName = naming.createSiblingName(caKeystoreName, "geronimo-ca-cert-store", NameFactory.CERTIFICATE_STORE);
GBeanData certStore = new GBeanData(certStoreName, FileCertificateStore.GBEAN_INFO);
certStore.setAttribute("directoryPath", URI.create(certStorePath));
certStore.setReferencePattern("ServerInfo", serverInfoName);
PortletManager.addGBeanToConfiguration(request, configurationId, certStore, true);
// Add a CertificateRequestStore GBean
AbstractName certReqStoreName = naming.createSiblingName(caKeystoreName, "geronimo-ca-cert-req-store", NameFactory.CERTIFICATE_REQUEST_STORE);
GBeanData certReqStore = new GBeanData(certReqStoreName, FileCertificateRequestStore.GBEAN_INFO);
certReqStore.setAttribute("directoryPath", URI.create(certReqStorePath));
certReqStore.setReferencePattern("ServerInfo", serverInfoName);
PortletManager.addGBeanToConfiguration(request, configurationId, certReqStore, true);
// Add a CertificationAuthority GBean
AbstractName caName = naming.createSiblingName(caKeystoreName, "geronimo-ca", NameFactory.CERTIFICATION_AUTHORITY);
GBeanData ca = new GBeanData(caName, GeronimoCertificationAuthority.GBEAN_INFO);
ca.setReferencePattern("ServerInfo", serverInfoName);
ca.setReferencePattern("KeystoreInstance", caKeystoreName);
ca.setReferencePattern("CertificateStore", certStoreName);
ca.setReferencePattern("CertificateRequestStore", certReqStoreName);