public void updateWebSecurityManager() { if (webSecurityManager == null) { webSecurityManager = getWebSecurityManager(true); } if (webSecurityManager != null) { try { webSecurityManager.release(); webSecurityManager.destroy(); } catch (Exception ex) { ex.printStackTrace(); } webSecurityManager = webSecurityManagerFactory.createManager(webDesc, true, serverContext); if (_logger.isLoggable(Level.FINE)) { _logger.fine("WebSecurityManager for "+CONTEXT_ID+" has been update"); } } }
/** * Generate the JSR 115 policy file for a web application, bundled * within a ear or deployed as a standalone war file. * * Implementation note: If the generated file doesn't contains * all the permission, the role mapper is probably broken. */ protected void configureSecurity(WebBundleDescriptor wbd, boolean isSystem) { try { webSecurityManagerFactory.createManager(wbd,true, serverContext); String context = WebSecurityManager.getContextID(wbd); SecurityUtil.generatePolicyFile(context); if (isSystem && context.equals("__admingui/__admingui")) { websecurityProbeProvider.policyCreationEvent(context); } } catch (Exception ce) { _logger.log(Level.SEVERE, "policy.configure", ce); throw new RuntimeException(ce); } }
private void generatePolicy(WebBundleDescriptor wbd) { String name = null; ClassLoader oldTcc = Thread.currentThread().getContextClassLoader(); try { //TODO: workaround here. Once fixed in V3 we should be able to use //Context ClassLoader instead. ClassLoaderHierarchy hierarchy = habitat.getComponent(ClassLoaderHierarchy.class); ClassLoader tcc = hierarchy.getCommonClassLoader(); Thread.currentThread().setContextClassLoader(tcc); policyLoader.loadPolicy(); WebSecurityManagerFactory wsmf =habitat.getComponent(WebSecurityManagerFactory.class); // this should create all permissions wsmf.createManager(wbd,true,serverContext); // for an application the securityRoleMapper should already be // created. I am just creating the web permissions and handing // it to the security component. name = WebSecurityManager.getContextID(wbd); SecurityUtil.generatePolicyFile(name); websecurityProbeProvider.policyCreationEvent(name); } catch (IASSecurityException se) { String msg = "Error in generating security policy for " + name; throw new RuntimeException(msg, se); } finally { Thread.currentThread().setContextClassLoader(oldTcc); } }
/** * Translate Web Bundle Policy * @param webBD * @param remove boolean indicated whether any existing policy statements * are removed form context before translation * @throws DeploymentException */ private void loadPolicy(WebBundleDescriptor webBD, boolean remove) throws DeploymentException { try { if (webBD != null) { if (remove) { String cid = SecurityUtil.getContextID(webBD); WebSecurityManager wsm = wsmf.getManager(cid, null, true); if (wsm != null) { wsm.release(); } } wsmf.createManager(webBD, true, serverContext); } } catch (Exception se) { String msg = "Error in generating security policy for " + webBD.getModuleDescriptor().getModuleName(); throw new DeploymentException(msg, se); } }
/** * Translate Web Bundle Policy * @param webBD * @param remove boolean indicated whether any existing policy statements * are removed form context before translation * @throws DeploymentException */ private void loadPolicy(WebBundleDescriptor webBD, boolean remove) throws DeploymentException { try { if (webBD != null) { if (remove) { String cid = SecurityUtil.getContextID(webBD); WebSecurityManager wsm = wsmf.getManager(cid, null, true); if (wsm != null) { wsm.release(); } } wsmf.createManager(webBD, true, serverContext); } } catch (Exception se) { String msg = "Error in generating security policy for " + webBD.getModuleDescriptor().getModuleName(); throw new DeploymentException(msg, se); } }