@Override public void unload(DummyApplication container, DeploymentContext context) { OpsParams params = context.getCommandParameters(OpsParams.class); cleanSecurityContext(params.name()); }
@Override public DummyApplication load(SecurityContainer container, DeploymentContext context) { DeployCommandParameters dparams = context.getCommandParameters(DeployCommandParameters.class); Application app = context.getModuleMetaData(Application.class); handleCNonceCacheBSInit(app.getAppName(), app.getBundleDescriptors(WebBundleDescriptor.class), dparams.availabilityenabled); return new DummyApplication(); }
@Override protected void cleanArtifacts(DeploymentContext dc) throws DeploymentException { removePolicy(dc); SecurityUtil.removeRoleMapper(dc); OpsParams params = dc.getCommandParameters(OpsParams.class); if (this.appCnonceMap != null) { CNonceCache cache = appCnonceMap.remove(params.name()); if (cache != null) { cache.destroy(); } } }
@Override protected void generateArtifacts(DeploymentContext dc) throws DeploymentException { OpsParams params = dc.getCommandParameters(OpsParams.class); if (params.origin.isArtifactsPresent()) { return; } String appName = params.name(); try { Application app = dc.getModuleMetaData(Application.class); Set<WebBundleDescriptor> webDesc = app.getBundleDescriptors(WebBundleDescriptor.class); if (webDesc == null) { return; } for (WebBundleDescriptor webBD : webDesc) { loadPolicy(webBD, false); } } catch (Exception se) { String msg = "Error in generating security policy for " + appName; throw new DeploymentException(msg, se); } }
private void handleCNonceCacheBSInit(String appName, Set<WebBundleDescriptor> webDesc, boolean isHA) { boolean hasDigest = false; for (WebBundleDescriptor webBD : webDesc) { LoginConfiguration lc = webBD.getLoginConfiguration(); if (lc != null && LoginConfiguration.DIGEST_AUTHENTICATION.equals( lc.getAuthenticationMethod())) { hasDigest = true; break; } } if (!hasDigest) { return; } // initialize the backing stores as well for cnonce cache. if (isHaEnabled() && isHA) { final String clusterName = haUtil.getClusterName(); final String instanceName = haUtil.getInstanceName(); if (cnonceCacheFactory != null) { CNonceCache cache = cnonceCacheFactory.createCNonceCache( appName, clusterName, instanceName, HA_CNONCE_BS_NAME); this.appCnonceMap.put(appName, cache); } } } }
/** * puts Web Bundle Policy In Service, repeats translation is Descriptor * indicate policy was changed by ContextListener. * @param webBD * @throws DeploymentException */ private void commitPolicy(WebBundleDescriptor webBD) throws DeploymentException { try { if (webBD != null) { if (webBD.isPolicyModified()) { // redo policy translation for web module loadPolicy(webBD, true); } String cid = SecurityUtil.getContextID(webBD); websecurityProbeProvider.policyCreationStartedEvent(cid); SecurityUtil.generatePolicyFile(cid); websecurityProbeProvider.policyCreationEndedEvent(cid); websecurityProbeProvider.policyCreationEvent(cid); } } catch (Exception se) { String msg = "Error in generating security policy for " + webBD.getModuleDescriptor().getModuleName(); throw new DeploymentException(msg, se); } }