List of usage examples for java.lang.management ManagementPermission ManagementPermission
public ManagementPermission(String name)
From source file:org.wso2.carbon.repository.core.internal.RepositoryServiceComponent.java
/** * Activates the Repository Kernel bundle. * * @param context the OSGi component context. *///from w w w. ja v a2s . c om protected void activate(ComponentContext context) { PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantDomain(org.wso2.carbon.base.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); carbonContext.setTenantId(org.wso2.carbon.base.MultitenantConstants.SUPER_TENANT_ID); // Need permissions in order to activate Registry SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { securityManager.checkPermission(new ManagementPermission("control")); } try { bundleContext = context.getBundleContext(); repositoryService = buildRepositoryService(); log.debug("Completed initializing the Registry Kernel"); registrations.push(bundleContext.registerService(new String[] { RepositoryService.class.getName() }, repositoryService, null)); registrations.push(bundleContext.registerService(SimulationService.class.getName(), new DefaultSimulationService(), null)); log.debug("Registry Core bundle is activated "); } catch (Throwable e) { log.error("Failed to activate Registry Core bundle ", e); } }
From source file:org.wso2.carbon.user.core.internal.Activator.java
public void startDeploy(BundleContext bundleContext) throws Exception { // Need permissions in order to instantiate user core SecurityManager secMan = System.getSecurityManager(); /*//from w ww .ja va 2s.com * Read the SSL trust store configurations from the Security.TrustStore * element of the Carbon.xml */ ServerConfiguration config = ServerConfiguration.getInstance(); String type = config.getFirstProperty("Security.TrustStore.Type"); String password = config.getFirstProperty("Security.TrustStore.Password"); String storeFile = new File(config.getFirstProperty("Security.TrustStore.Location")).getAbsolutePath(); // set the SSL trust store System Properties System.setProperty("javax.net.ssl.trustStore", storeFile); System.setProperty("javax.net.ssl.trustStoreType", type); System.setProperty("javax.net.ssl.trustStorePassword", password); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } try { PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); RealmService realmService = new DefaultRealmService(bundleContext); bundleContext.registerService( new String[] { RealmService.class.getName(), UserRealmService.class.getName() }, realmService, null); UserCoreUtil.setRealmService(realmService); } catch (Throwable e) { String msg = "Cannot start User Manager Core bundle"; log.error(msg, e); // do not throw exceptions; } }
From source file:org.wso2.carbon.webapp.mgt.TomcatGenericWebappsDeployer.java
/** * Constructor/*from w w w. j a v a2 s. co m*/ * * @param webContextPrefix The Web context prefix * @param tenantId The tenant ID of the tenant to whom this deployer belongs to * @param tenantDomain The tenant domain of the tenant to whom this deployer belongs to * @param webApplicationsHolderMap WebApplicationsHolder */ public TomcatGenericWebappsDeployer(String webContextPrefix, int tenantId, String tenantDomain, Map<String, WebApplicationsHolder> webApplicationsHolderMap, ConfigurationContext configurationContext) { SecurityManager secMan = System.getSecurityManager(); if (secMan != null) { secMan.checkPermission(new ManagementPermission("control")); } this.tenantId = tenantId; this.tenantDomain = tenantDomain; this.webContextPrefix = webContextPrefix; this.webApplicationsHolderMap = webApplicationsHolderMap; this.configurationContext = configurationContext; }