List of usage examples for java.security Security removeProvider
public static synchronized void removeProvider(String name)
From source file:com.jtechme.apphub.FDroidApp.java
public static void disableSpongyCastleOnLollipop() { if (Build.VERSION.SDK_INT == 21) { Security.removeProvider(spongyCastleProvider.getName()); }//from w w w . jav a2 s . com }
From source file:be.fedict.hsm.model.KeyStoreLoaderBean.java
private Map<String, PrivateKeyEntry> loadPKCS11(KeyStoreEntity keyStoreEntity) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException, UnrecoverableEntryException { File tmpConfigFile = File.createTempFile("pkcs11-", ".conf"); tmpConfigFile.deleteOnExit();/* www . ja v a 2s .co m*/ PrintWriter configWriter = new PrintWriter(new FileOutputStream(tmpConfigFile)); configWriter.println("name=HSM-" + keyStoreEntity.getId()); String path = keyStoreEntity.getPath(); LOG.debug("PKCS11 path: " + path); LOG.debug("slot list index: " + keyStoreEntity.getSlotListIndex()); configWriter.println("library=" + path); configWriter.println("slotListIndex=" + keyStoreEntity.getSlotListIndex()); configWriter.close(); SunPKCS11 sunPKCS11 = new SunPKCS11(tmpConfigFile.getAbsolutePath()); LOG.debug("adding SunPKCS11 JCA provider: " + sunPKCS11.getName()); /* * Reloads also need to work properly. */ Security.removeProvider(sunPKCS11.getName()); Security.addProvider(sunPKCS11); KeyStore keyStore = KeyStore.getInstance("PKCS11", sunPKCS11); if (null != keyStoreEntity.getPassword()) { keyStore.load(null, keyStoreEntity.getPassword().toCharArray()); } else { keyStore.load(null, null); } String keyStorePassword = keyStoreEntity.getPassword(); return loadKeys(keyStoreEntity, keyStore, keyStorePassword); }
From source file:be.fgov.kszbcss.rhq.websphere.WebSpherePluginLifecycleListener.java
public void shutdown() { try {//from w w w . j av a 2 s . c om configManager.removeSSLConfigFromMap(SSL_CONFIG_ALIAS, sslConfig); } catch (Exception ex) { log.error("Unable to remove SSL configuration", ex); } System.getProperties().remove("com.ibm.CORBA.ConfigURL"); System.getProperties().remove("com.ibm.ssl.defaultAlias"); ConfigQueryServiceFactory.destroy(); TrustStoreManager.destroy(); configManager = null; sslConfig = null; Security.removeProvider(CustomProvider.NAME); // Shut down the ORB to prevent class loader leaks and to avoid reconnection // issues if the plugin is restarted later. log.info("Shutting down ORB"); orb.shutdown(false); orb = null; // Also reset the ORB singleton holder; otherwise we will have an issue if the // plugin is restarted later (and the GlobalORBFactory class is loaded from the // system class loader). synchronized (GlobalORBFactory.class) { try { Field orbField = GlobalORBFactory.class.getDeclaredField("orb"); orbField.setAccessible(true); orbField.set(null, null); } catch (Exception ex) { log.error( "Failed to remove singleton ORB instance; this will cause a failure to restart the plugin", ex); } } }
From source file:org.guanxi.sp.engine.Bootstrap.java
/** * Called by Spring when application events occur. At the moment we handle: * ContextClosedEvent/* w w w . j a v a 2s.co m*/ * ContextRefreshedEvent * RequestHandledEvent * * This is where we inject the job controllers into the application context, each one * under it's own key. * * To understand the different events see * http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#context-functionality-events * * @param applicationEvent Spring application event */ public void onApplicationEvent(ApplicationEvent applicationEvent) { /* * ContextClosedEvent * Published when the ApplicationContext is closed, using the * close() method on the ConfigurableApplicationContext * interface. "Closed" here means that all singleton beans are * destroyed. A closed context has reached its end of life; it * cannot be refreshed or restarted. */ if (applicationEvent instanceof ContextClosedEvent) { if (okToUnloadBCProvider) { Provider[] providers = Security.getProviders(); /* Although addProvider() returns the ID of the newly installed provider, * we can't rely on this. If another webapp removes a provider from the list of * installed providers, all the other providers shuffle up the list by one, thus * invalidating the ID we got from addProvider(). */ try { for (int i = 0; i < providers.length; i++) { if (providers[i].getName().equalsIgnoreCase(Guanxi.BOUNCY_CASTLE_PROVIDER_NAME)) { Security.removeProvider(Guanxi.BOUNCY_CASTLE_PROVIDER_NAME); } } // Stop the jobs scheduler.shutdown(); } catch (SecurityException se) { /* We'll end up here if a security manager is installed and it refuses us * permission to remove the BouncyCastle provider */ } catch (SchedulerException se) { logger.error("Could not stop jobs", se); } } } /* * ContextRefreshedEvent * Published when the ApplicationContext is initialised or * refreshed, e.g. using the refresh() method on the * ConfigurableApplicationContext interface. "Initialised" * here means that all beans are loaded, post-processor * beans are detected and activated, singletons are * pre-instantiated, and the ApplicationContext object is * ready for use. A refresh may be triggered multiple times, * as long as the context hasn't been closed - provided that * the chosen ApplicationContext actually supports such * "hot" refreshes (which e.g. XmlWebApplicationContext does * but GenericApplicationContext doesn't). */ else if (applicationEvent instanceof ContextRefreshedEvent) { // Advertise the application as available for business servletContext.setAttribute(Guanxi.CONTEXT_ATTR_ENGINE_CONFIG, config); logger.info("init : " + config.getId()); } }
From source file:org.guanxi.idp.Bootstrap.java
/** * Called by Spring when application events occur. At the moment we handle: * ContextClosedEvent//from ww w.jav a2 s .c o m * ContextRefreshedEvent * RequestHandledEvent * * This is where we inject the job controllers into the application context, each one * under it's own key. * * @param applicationEvent Spring application event */ public void onApplicationEvent(ApplicationEvent applicationEvent) { if (applicationEvent instanceof ContextRefreshedEvent) { logger.info("Bootstrap init"); // Inject the metadata farm to handle all source of metadata servletContext.setAttribute(Guanxi.CONTEXT_ATTR_IDP_ENTITY_FARM, entityFarm); } if (applicationEvent instanceof ContextClosedEvent) { if (okToUnloadBCProvider) { Provider[] providers = Security.getProviders(); /* Although addProvider() returns the ID of the newly installed provider, * we can't rely on this. If another webapp removes a provider from the list of * installed providers, all the other providers shuffle up the list by one, thus * invalidating the ID we got from addProvider(). */ try { for (int i = 0; i < providers.length; i++) { if (providers[i].getName().equalsIgnoreCase(Guanxi.BOUNCY_CASTLE_PROVIDER_NAME)) { Security.removeProvider(Guanxi.BOUNCY_CASTLE_PROVIDER_NAME); } } // Stop the jobs scheduler.shutdown(); } catch (SecurityException se) { /* We'll end up here if a security manager is installed and it refuses us * permission to remove the BouncyCastle provider */ } catch (SchedulerException se) { logger.error("Could not stop jobs", se); } } } if (applicationEvent instanceof RequestHandledEvent) { } }
From source file:com.google.code.commons.checksum.digest.TestDigestUtils.java
@After public void removeBouncyCastleProvider() throws Exception { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); }
From source file:org.fdroid.fdroid.FDroidApp.java
public static void disableSpongyCastleOnLollipop() { if (Build.VERSION.SDK_INT == 21) { Security.removeProvider(SPONGYCASTLE_PROVIDER.getName()); }/*from w w w . j a v a 2s . c o m*/ }
From source file:org.jboss.as.test.integration.logging.syslogserver.TLSSyslogServer.java
/** * Removes Bouncy Castle from Security Manager. *//*from w w w . j ava 2s.c o m*/ public void removeBouncyCastle() { try { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } catch (SecurityException ex) { LOGGER.warn("Cannot deregister BouncyCastleProvider", ex); } }
From source file:org.jboss.as.test.integration.security.loginmodules.LdapExtLDAPServerSetupTask.java
/** * Stops LDAP server and KDCServer and shuts down the directory service. * * @param managementClient/*from w w w. j a v a 2 s . c o m*/ * @param containerId * @throws Exception * @see org.jboss.as.arquillian.api.ServerSetupTask#tearDown(org.jboss.as.arquillian.container.ManagementClient, * java.lang.String) */ public void tearDown(ManagementClient managementClient, String containerId) throws Exception { ldapServer2.stop(); directoryService2.shutdown(); ldapServer1.stop(); directoryService1.shutdown(); KEYSTORE_FILE.delete(); FileUtils.deleteDirectory(directoryService2.getInstanceLayout().getInstanceDirectory()); FileUtils.deleteDirectory(directoryService1.getInstanceLayout().getInstanceDirectory()); if (removeBouncyCastle) { try { Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME); } catch (SecurityException ex) { LOGGER.warn("Cannot deregister BouncyCastleProvider", ex); } } }