List of usage examples for java.security Provider getName
public String getName()
From source file:com.zacwolf.commons.crypto._CRYPTOfactory.java
public static void dumpCiphers() { for (Provider provider : Security.getProviders()) { System.out.println(provider.getName()); for (String key : provider.stringPropertyNames()) System.out.println("\t" + key + "\t" + provider.getProperty(key)); }//w w w .j a v a 2 s . c om }
From source file:eu.europa.esig.dss.DSSUtils.java
/** * This method lists all defined security providers. */// w ww .j a v a 2 s .c om public static void printSecurityProvides() { final Provider[] providers = Security.getProviders(); for (final Provider provider : providers) { System.out.println("PROVIDER: " + provider.getName()); final Set<Provider.Service> services = provider.getServices(); for (final Provider.Service service : services) { System.out.println("\tALGORITHM: " + service.getAlgorithm() + " / " + service.getType() + " / " + service.getClassName()); } } }
From source file:at.tfr.securefs.Configuration.java
@PostConstruct public void init() { if (log.isDebugEnabled()) { for (Provider p : Security.getProviders()) { try { log.debug("Provider: " + p.getClass() + ", Name=" + p.getName() + ", Info=" + p.getInfo()); final Set<Service> services = p.getServices(); if (services == null) { log.debug("Provider has no services: " + p); } else { for (Service s : services) { log.debug("Service: " + s.getClassName() + ", " + s.getAlgorithm() + ", "); }/*from w ww.j ava 2 s.c o m*/ } } catch (Throwable t) { log.info("cannot print info: Provider=" + p + " : " + t, t); } } } loadSecureFsProperties(true); keyAlgorithm = secConfig.getString(SECUREFS_SERVER_PFX + KEY_ALGORITHM, keyAlgorithm); log.info("KeyAlgorithm = " + keyAlgorithm); keyStrength = secConfig.getInt(SECUREFS_SERVER_PFX + KEY_STRENGTH, keyStrength); log.info("KeyStrength = " + keyStrength); iterationCount = secConfig.getInt(SECUREFS_SERVER_PFX + ITERATION_COUNT, iterationCount); log.info("IterationCount = " + iterationCount); cipherAlgorithm = secConfig.getString(SECUREFS_SERVER_PFX + CIPHER_ALGORITHM, cipherAlgorithm); log.info("CipherAlgorithm = " + cipherAlgorithm); paddingCipherAlgorithm = secConfig.getString(SECUREFS_SERVER_PFX + PADDING_CIPHER_ALGORITHM, paddingCipherAlgorithm); log.info("PaddingCipherAlgorithm = " + paddingCipherAlgorithm); salt = secConfig.getString(SECUREFS_SERVER_PFX + SALT, salt); log.info("Salt = " + salt); cacheName = secConfig.getString(SECUREFS_SERVER_PFX + CACHE_NAME, cacheName); log.info("CacheName = " + cacheName); restrictedToBasePath = secConfig.getBoolean(SECUREFS_SERVER_PFX + RESTRICTED_TO_BASE_PATH, restrictedToBasePath); log.info("RestrictedToBasePath = " + restrictedToBasePath); preProcessing = secConfig.getBoolean(SECUREFS_SERVER_PFX + PRE_PROCESSING, preProcessing); log.info("PreProcessing = " + preProcessing); test = secConfig.getBoolean(SECUREFS_SERVER_PFX + TEST, test); log.info("Test = " + test); try { String basePathProp = secConfig.getString(SECUREFS_SERVER_PFX + BASE_PATH); if (StringUtils.isNotBlank(basePathProp)) { basePath = Paths.get(basePathProp); } else { basePath = Files.createTempDirectory(SECUREFS); } log.info("BasePath = " + basePath); revokedKeysPath = basePath.resolve(REVOKED_KEYS); } catch (Exception e) { log.warn("cannot open BasePath", e); } try { String tmpPathProp = secConfig.getString(SECUREFS_SERVER_PFX + TMP_PATH); String jbossTmpPathProp = System.getProperty(JBOSS_SERVER_TEMP_DIR); if (StringUtils.isNotBlank(tmpPathProp)) { tmpPath = Paths.get(tmpPathProp); } else if (StringUtils.isNotBlank(jbossTmpPathProp)) { tmpPath = Files.createDirectories(Paths.get(jbossTmpPathProp, SECUREFS)); } else { tmpPath = Files.createTempDirectory(SECUREFS); } log.info("TmpPath = " + tmpPath); } catch (Exception e) { log.warn("cannot open TmpPath", e); } try { schemaPath = Paths.get(secConfig.getString(SECUREFS_SERVER_PFX + SCHEMA_PATH, "/tmp")); log.info("SchemaPath = " + schemaPath); } catch (Exception e) { log.warn("cannot open SchemaPath", e); } try { log.info("ServiceModules : names=" + getServiceModules()); getModuleConfigurations().stream().peek((m) -> log.info("\t" + m)); } catch (Exception e) { log.warn("cannot read ServiceModules", e); } }
From source file:com.alfaariss.oa.profile.aselect.ws.security.OACrypto.java
/** * Retrieve the singleton instance of the certificate factory. * @see org.apache.ws.security.components.crypto.Crypto#getCertificateFactory() *//*from w w w . ja va 2 s. com*/ public CertificateFactory getCertificateFactory() throws WSSecurityException { if (_certFactory == null) { try { Provider provider = _factory.getKeyStore().getProvider(); String sProvider = null; if (provider != null) { sProvider = provider.getName(); } if (sProvider == null || sProvider.length() == 0) { _certFactory = CertificateFactory.getInstance("X.509"); } else { _certFactory = CertificateFactory.getInstance("X.509", provider); } } catch (CertificateException e) { throw new WSSecurityException(WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, "unsupportedCertType", null, e); } } return _certFactory; }
From source file:com.alfaariss.oa.profile.aselect.ws.security.OACrypto.java
/** * Validate a given certificate chain./*from w w w. j a va 2s. c om*/ * @see Crypto#validateCertPath(java.security.cert.X509Certificate[]) */ public boolean validateCertPath(X509Certificate[] certs) throws WSSecurityException { boolean ok = false; try { // Generate cert path List<X509Certificate> certList = Arrays.asList(certs); CertPath path = this.getCertificateFactory().generateCertPath(certList); HashSet<TrustAnchor> set = new HashSet<TrustAnchor>(); if (certs.length == 1) // Use factory certs { String alias = _factory.getAliasForX509Cert(certs[0].getIssuerDN().getName(), certs[0].getSerialNumber()); if (alias == null) { _logger.debug("Certificate not trusted"); return false; } X509Certificate cert = (X509Certificate) _factory.getCertificate(alias); TrustAnchor anchor = new TrustAnchor(cert, cert.getExtensionValue("2.5.29.30")); set.add(anchor); } else { // Add certificates from the keystore Enumeration aliases = _factory.getAliases(); while (aliases.hasMoreElements()) { String alias = (String) aliases.nextElement(); X509Certificate cert = (X509Certificate) _factory.getCertificate(alias); TrustAnchor anchor = new TrustAnchor(cert, cert.getExtensionValue("2.5.29.30")); set.add(anchor); } } PKIXParameters param = new PKIXParameters(set); param.setRevocationEnabled(false); Provider provider = _factory.getKeyStore().getProvider(); String sProvider = null; CertPathValidator certPathValidator = null; if (provider != null) { sProvider = provider.getName(); } if (sProvider == null || sProvider.length() == 0) { certPathValidator = CertPathValidator.getInstance("PKIX"); } else { certPathValidator = CertPathValidator.getInstance("PKIX", sProvider); } certPathValidator.validate(path, param); ok = true; } catch (NoSuchProviderException e) { _logger.warn("No such provider", e); throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } catch (NoSuchAlgorithmException e) { _logger.warn("No such algorithm", e); throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } catch (InvalidAlgorithmParameterException e) { _logger.warn("Invalid algorithm param", e); throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } catch (CertificateException e) { _logger.warn("Invalid certificate", e); throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } catch (ClassCastException e) { _logger.warn("Certificate is not an X509Certificate", e); throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } catch (CertPathValidatorException e) { _logger.warn("Could not validate Cert Path", e); throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } catch (CryptoException e) { throw new WSSecurityException(WSSecurityException.FAILURE, "certpath", new Object[] { e.getMessage() }, e); } return ok; }
From source file:net.lightbody.bmp.proxy.jetty.http.SunJsseListener.java
protected SSLServerSocketFactory createFactory() throws Exception { _keystore = System.getProperty(KEYSTORE_PROPERTY, _keystore); log.info(KEYSTORE_PROPERTY + "=" + _keystore); if (_password == null) _password = Password.getPassword(PASSWORD_PROPERTY, null, null); log.info(PASSWORD_PROPERTY + "=" + _password.toStarString()); if (_keypassword == null) _keypassword = Password.getPassword(KEYPASSWORD_PROPERTY, null, _password.toString()); log.info(KEYPASSWORD_PROPERTY + "=" + _keypassword.toStarString()); KeyStore ks = null;/*from w w w.j a v a 2 s .c o m*/ log.info(KEYSTORE_TYPE_PROPERTY + "=" + _keystore_type); if (_keystore_provider_class != null) { // find provider. // avoid creating another instance if already installed in Security. java.security.Provider[] installed_providers = Security.getProviders(); java.security.Provider myprovider = null; for (int i = 0; i < installed_providers.length; i++) { if (installed_providers[i].getClass().getName().equals(_keystore_provider_class)) { myprovider = installed_providers[i]; break; } } if (myprovider == null) { // not installed yet, create instance and add it myprovider = (java.security.Provider) Class.forName(_keystore_provider_class).newInstance(); Security.addProvider(myprovider); } log.info(KEYSTORE_PROVIDER_CLASS_PROPERTY + "=" + _keystore_provider_class); ks = KeyStore.getInstance(_keystore_type, myprovider.getName()); } else if (_keystore_provider_name != null) { log.info(KEYSTORE_PROVIDER_NAME_PROPERTY + "=" + _keystore_provider_name); ks = KeyStore.getInstance(_keystore_type, _keystore_provider_name); } else { ks = KeyStore.getInstance(_keystore_type); log.info(KEYSTORE_PROVIDER_NAME_PROPERTY + "=[DEFAULT]"); } ks.load(new FileInputStream(new File(_keystore)), _password.toString().toCharArray()); KeyManagerFactory km = KeyManagerFactory.getInstance("SunX509", "SunJSSE"); km.init(ks, _keypassword.toString().toCharArray()); KeyManager[] kma = km.getKeyManagers(); TrustManagerFactory tm = TrustManagerFactory.getInstance("SunX509", "SunJSSE"); if (_useDefaultTrustStore) { tm.init((KeyStore) null); } else { tm.init(ks); } TrustManager[] tma = tm.getTrustManagers(); SSLContext sslc = SSLContext.getInstance("SSL"); sslc.init(kma, tma, SecureRandom.getInstance("SHA1PRNG")); SSLServerSocketFactory ssfc = sslc.getServerSocketFactory(); log.info("SSLServerSocketFactory=" + ssfc); return ssfc; }
From source file:com.twinsoft.convertigo.engine.Engine.java
public static synchronized void start() throws EngineException { if (Engine.theApp == null) { System.out.println("Starting Convertigo Enterprise Mobility Server"); // If the engine has been stopped by the admin, we must reload // properties EnginePropertiesManager.loadProperties(); boolean bProjectsDataCompatibilityMode = Boolean.parseBoolean( EnginePropertiesManager.getProperty(PropertyName.PROJECTS_DATA_COMPATIBILITY_MODE)); if (bProjectsDataCompatibilityMode) { System.out.println("Projects data compatibility mode required"); try { Engine.PROJECTS_PATH = new File(Engine.WEBAPP_PATH + "/projects").getCanonicalPath(); File projectsDir = new File(Engine.PROJECTS_PATH); projectsDir.mkdir();//from w w w . j av a2s . co m } catch (IOException e) { throw new EngineException("Unable to update projects path for compatibility mode", e); } } isStarted = false; isStartFailed = false; RequestableObject.nbCurrentWorkerThreads = 0; Engine.startStopDate = System.currentTimeMillis(); System.out.println("Creating/updating loggers"); String logFile = EnginePropertiesManager.getProperty(PropertyName.LOG4J_APPENDER_CEMSAPPENDER_FILE); System.out.println("Log file: " + logFile); // Main loggers Engine.logConvertigo = Logger.getLogger("cems"); Engine.logEngine = Logger.getLogger("cems.Engine"); Engine.logAdmin = Logger.getLogger("cems.Admin"); Engine.logBeans = Logger.getLogger("cems.Beans"); Engine.logBillers = Logger.getLogger("cems.Billers"); Engine.logEmulators = Logger.getLogger("cems.Emulators"); Engine.logContext = Logger.getLogger("cems.Context"); Engine.logUser = Logger.getLogger("cems.Context.User"); Engine.logUsageMonitor = Logger.getLogger("cems.UsageMonitor"); Engine.logStatistics = Logger.getLogger("cems.Statistics"); Engine.logScheduler = Logger.getLogger("cems.Scheduler"); Engine.logSiteClipper = Logger.getLogger("cems.SiteClipper"); /** #3437 : Disabled ExternalBrowser feature because it's not terminated Engine.logExternalBrowser = Logger.getLogger("cems.ExternalBrowser"); */ Engine.logAudit = Logger.getLogger("cems.Context.Audit"); // Managers Engine.logContextManager = Logger.getLogger("cems.ContextManager"); Engine.logCacheManager = Logger.getLogger("cems.CacheManager"); Engine.logTracePlayerManager = Logger.getLogger("cems.TracePlayerManager"); Engine.logJobManager = Logger.getLogger("cems.JobManager"); Engine.logCertificateManager = Logger.getLogger("cems.CertificateManager"); Engine.logDatabaseObjectManager = Logger.getLogger("cems.DatabaseObjectManager"); Engine.logProxyManager = Logger.getLogger("cems.ProxyManager"); Engine.logDevices = Logger.getLogger("cems.Devices"); Engine.logCouchDbManager = Logger.getLogger("cems.CouchDbManager"); Engine.logSecurityTokenManager = Logger.getLogger("cems.SecurityTokenManager"); // Logger for compatibility issues Engine.log = new LogWrapper(Engine.logConvertigo); LogWrapper.initWrapper(Engine.logEmulators); try { Engine.logEngine.info("==========================================================="); Engine.logEngine.info("Web app home: " + Engine.WEBAPP_PATH); Engine.logEngine.info("User workspace: " + Engine.USER_WORKSPACE_PATH); Engine.logEngine.info("Configuration path: " + Engine.CONFIGURATION_PATH); Engine.logEngine.info("Projects path: " + Engine.PROJECTS_PATH); if (bProjectsDataCompatibilityMode) { Engine.logEngine.warn("Projects data compatibility mode required"); } Engine.logEngine.info("Log: " + Engine.LOG_PATH); if (cloud_customer_name != null) { Engine.logEngine.info("Cloud customer: " + cloud_customer_name); } // Check environment and native dependencies if (!isStudioMode()) { StartupDiagnostics.run(); } // Initializing the engine Engine.theApp = new Engine(); CachedIntrospector.prefetchDatabaseObjectsAsync(); try { Engine.theApp.usageMonitor = new UsageMonitor(); Engine.theApp.usageMonitor.init(); Thread vulture = new Thread(Engine.theApp.usageMonitor); vulture.setName("UsageMonitor"); vulture.setDaemon(true); vulture.start(); } catch (Exception e) { Engine.logEngine.error("Unable to launch the usage monitor.", e); } Engine.theApp.eventManager = new EventManager(); Engine.theApp.eventManager.init(); Engine.theApp.databaseObjectsManager = new DatabaseObjectsManager(); Engine.theApp.databaseObjectsManager.init(); Engine.theApp.sqlConnectionManager = new JdbcConnectionManager(); Engine.theApp.sqlConnectionManager.init(); Engine.theApp.filePropertyManager = new FilePropertyManager(); Engine.theApp.filePropertyManager.init(); try { Engine.theApp.proxyManager = new ProxyManager(); Engine.theApp.proxyManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to launch the proxy manager.", e); } try { Engine.theApp.billingManager = new BillingManager(); Engine.theApp.billingManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to launch the billing manager.", e); } // Initialization of the trace player try { Engine.theApp.tracePlayerManager = new TracePlayerManager(); Engine.theApp.tracePlayerManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to run the trace player.", e); } try { Engine.theApp.minificationManager = new MinificationManager(); Engine.theApp.minificationManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to run the minification manager.", e); } try { Engine.theApp.couchDbManager = new CouchDbManager(); Engine.theApp.couchDbManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to run the couchDbProxy manager.", e); } try { Engine.theApp.pluginsManager = new PluginsManager(); Engine.theApp.pluginsManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to run the plugins manager.", e); } try { Engine.theApp.restApiManager = RestApiManager.getInstance(); Engine.theApp.restApiManager.init(); } catch (Exception e) { Engine.logEngine.error("Unable to run the rest api manager.", e); } Engine.logEngine.info("Current working directory is '" + System.getProperty("user.dir") + "'."); // Creating the Carioca Authentication objects Engine.logEngine.debug("Creating the Carioca Authentication objects"); String cariocaUserName = EnginePropertiesManager .getProperty(PropertyName.CARIOCA_DEFAULT_USER_NAME); String cariocaPassword = EnginePropertiesManager .getProperty(PropertyName.CARIOCA_DEFAULT_USER_PASSWORD); Engine.theApp.authentications = new HashMap<String, Authentication>(); // Initialization of the default TAS properties try { KeyManager.log = new LogWrapper(Engine.logEngine); Authentication auth = Engine.theApp.getAuthenticationObject("", null); auth.login(cariocaUserName, cariocaPassword); } catch (Exception e) { Engine.logEngine.error("The authentication to Carioca has failed (user name: \"" + cariocaUserName + "\", user password: \"" + cariocaPassword + "\").", e); } // TODO : retrieve SOA flag from KeyManager isSOA = true; // Creation of the session manager Engine.theApp.sessionManager = new SessionManager(); Engine.theApp.sessionManager.setLog(new LogWrapper(Engine.logEngine)); Engine.theApp.sessionManager.setProductCode(SessionManager.CONVERTIGO); String s = EnginePropertiesManager.getProperty(PropertyName.CONNECTORS_MONITORING); Engine.theApp.setMonitored(s.equalsIgnoreCase("true")); // Create Projects directory if needed File projectsDirFile = new File(Engine.PROJECTS_PATH); try { if (!projectsDirFile.exists()) projectsDirFile.mkdirs(); } catch (Exception e) { Engine.logEngine.error("An error occured while creating projects directory.", e); } // Starts projects migration process MigrationManager.performProjectsMigration(); // Security providers registration try { File dir = new File(Engine.CERTIFICATES_PATH); String[] files = dir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith((".pkcs11")); } }); if (files != null && files.length > 0) { Engine.logEngine.info("Registering security providers..."); try { Class<?> sunPKCS11Class = Class.forName("sun.security.pkcs11.SunPKCS11"); String file; for (int i = 0; i < files.length; i++) { file = Engine.CERTIFICATES_PATH + "/" + files[i]; try { Constructor<?> constructor = sunPKCS11Class .getConstructor(new Class[] { String.class }); Provider provider = (Provider) constructor.newInstance(new Object[] { file }); Security.addProvider(provider); Engine.logEngine.info("Provider '" + provider.getName() + "' has been successfully registered."); } catch (Exception e) { Engine.logEngine.error("Unable to register security provider from file: " + file + " . Please check that the implementation library is in the Java lib path."); } } } catch (ClassNotFoundException e) { Engine.logEngine.error( "Unable to find sun.security.pkcs11.SunPKCS11 class! PKCS#11 authentication won't be available. You must use JVM 1.5 or higher in order to use PKCS#11 authentication."); } } Provider[] providers = Security.getProviders(); String sProviders = ""; for (int i = 0; i < providers.length; i++) { sProviders += providers[i].getName() + ", "; } Engine.logEngine.debug("Registered providers: " + sProviders); } catch (Exception e) { Engine.logEngine.error("Unable to register security providers.", e); } // Launch the cache manager try { String cacheManagerClassName = EnginePropertiesManager .getProperty(PropertyName.CACHE_MANAGER_CLASS); Engine.logEngine.debug("Cache manager class: " + cacheManagerClassName); Engine.theApp.cacheManager = (CacheManager) Class.forName(cacheManagerClassName).newInstance(); Engine.theApp.cacheManager.init(); Thread vulture = new Thread(Engine.theApp.cacheManager); Engine.theApp.cacheManager.executionThread = vulture; vulture.setName("CacheManager"); vulture.setDaemon(true); vulture.start(); } catch (Exception e) { Engine.logEngine.error("Unable to launch the cache manager.", e); } // Launch the thread manager try { Engine.theApp.threadManager = new ThreadManager(); Engine.theApp.threadManager.init(); Thread vulture = new Thread(Engine.theApp.threadManager); Engine.theApp.threadManager.executionThread = vulture; vulture.setName("ThreadManager"); vulture.setDaemon(true); vulture.start(); } catch (Exception e) { Engine.theApp.threadManager = null; Engine.logEngine.error("Unable to launch the thread manager.", e); } // Launch the context manager try { Engine.theApp.contextManager = new ContextManager(); Engine.theApp.contextManager.init(); Thread vulture = new Thread(Engine.theApp.contextManager); Engine.theApp.contextManager.executionThread = vulture; vulture.setName("ContextManager"); vulture.setDaemon(true); vulture.start(); } catch (Exception e) { Engine.theApp.contextManager = null; Engine.logEngine.error("Unable to launch the context manager.", e); } // Launch the security token manager Engine.theApp.securityTokenManager = new SecurityTokenManager(); Engine.theApp.securityTokenManager.init(); // Initialize the HttpClient try { Engine.logEngine.debug("HttpClient initializing..."); Engine.theApp.httpClient = HttpUtils.makeHttpClient3(true); Engine.theApp.httpClient4 = HttpUtils.makeHttpClient4(true); Engine.logEngine.debug("HttpClient initialized!"); } catch (Exception e) { Engine.logEngine.error("Unable to initialize the HttpClient.", e); } // Initialization of the schedule manager Engine.theApp.schedulerManager = new SchedulerManager(true); // Initialization of the RSA manager Engine.theApp.rsaManager = new RsaManager(); Engine.theApp.rsaManager.init(); // Initialization of the External Browser manager /** #3437 : Disabled ExternalBrowser feature because it's not terminated Engine.theApp.externalBrowserManager = new ExternalBrowserManager(); Engine.theApp.externalBrowserManager.init(); */ // Initialization of the Schema manager Engine.theApp.schemaManager = new SchemaManager(); Engine.theApp.schemaManager.init(); // XUL initialization String xulrunner_url = System.getProperty("org.eclipse.swt.browser.XULRunnerPath"); if (xulrunner_url == null || xulrunner_url.equals("")) { xulrunner_url = EnginePropertiesManager.getProperty(PropertyName.XULRUNNER_URL); } File f = new File(xulrunner_url); if (f.exists()) { xulrunner_url = f.getAbsolutePath(); Engine.logEngine .debug("initMozillaSWT: org.eclipse.swt.browser.XULRunnerPath=" + xulrunner_url); System.setProperty("org.eclipse.swt.browser.XULRunnerPath", xulrunner_url); } else { Engine.logEngine.error("Error in initMozillaSWT: " + xulrunner_url + " doesn't exist, fix it with xulrunner.url"); } if (Engine.isEngineMode() && Engine.isLinux() && "true".equals(EnginePropertiesManager.getProperty(PropertyName.LINUX_LAUNCH_XVNC))) { Engine.logEngine .debug("initMozillaSWT: org.eclipse.swt.browser.XULRunnerPath=" + xulrunner_url); final String display = System.getenv("DISPLAY"); if (display != null) { try { String port = System.getProperty("xvnc.port"); if (port == null) { port = "" + (Integer.parseInt(display.replaceAll(".*:(\\d*)", "$1")) + 5900); System.setProperty("xvnc.port", port); } Engine.logEngine.debug("Xvnc should listen on " + port + " port"); } catch (Exception e) { } try { File vncDir = new File(Engine.WEBAPP_PATH + "/WEB-INF/xvnc"); File Xvnc = new File(vncDir, "/Xvnc"); File fonts = new File(vncDir, "/fonts"); File wm = new File(vncDir, "/matchbox-window-manager"); if (vncDir.exists() && Xvnc.exists() && fonts.exists() && wm.exists()) { for (File file : GenericUtils.<File>asList(Xvnc, wm)) { new ProcessBuilder("/bin/chmod", "u+x", file.getAbsolutePath()).start() .waitFor(); } String depth = EnginePropertiesManager.getProperty(PropertyName.LINUX_XVNC_DEPTH); String geometry = EnginePropertiesManager .getProperty(PropertyName.LINUX_XVNC_GEOMETRY); Engine.logEngine .debug("Xvnc will use depth " + depth + " and geometry " + geometry); Process pr_xvnc = new ProcessBuilder(Xvnc.getAbsolutePath(), display, "-fp", fonts.getAbsolutePath(), "-depth", depth, "-geometry", geometry).start(); Thread.sleep(500); try { int exit = pr_xvnc.exitValue(); InputStream err = pr_xvnc.getErrorStream(); byte[] buf = new byte[err.available()]; err.read(buf); Engine.logEngine.debug("Xvnc failed to run with exit code " + exit + " and this error : <<" + new String(buf, "UTF-8") + ">>"); } catch (Exception e) { new ProcessBuilder(wm.getAbsolutePath()).start(); Engine.logEngine.debug("Xvnc successfully started !"); } } else { Engine.logEngine.info( vncDir.getAbsolutePath() + " not found or incomplet, cannot start Xvnc"); } } catch (Exception e) { Engine.logEngine.info("failed to launch Xvnc (maybe already launched", e); } } else Engine.logEngine .warn("Trying to start Xvnc on Linux without DISPLAY environment variable !"); } // SAP provider registration try { SapJcoDestinationDataProvider.init(); Engine.logEngine.debug("SAP destination provider successfully registered"); } catch (Throwable e) { Engine.logEngine.error("Error while registering SAP destination provider", e); } isStarted = true; Engine.logEngine.info("Convertigo engine started"); } catch (Throwable e) { isStartFailed = true; Engine.logEngine.error("Unable to successfully start the engine.", e); } } else { Engine.logEngine.info("Convertigo engine already started"); } }
From source file:com.meltmedia.cadmium.servlets.ClassLoaderLeakPreventor.java
/** * Deregister custom security providers//from w ww . j av a2s . c o m */ protected void deregisterSecurityProviders() { final Set<String> providersToRemove = new HashSet<String>(); for (java.security.Provider provider : java.security.Security.getProviders()) { if (isLoadedInWebApplication(provider)) { providersToRemove.add(provider.getName()); } } if (!providersToRemove.isEmpty()) { warn("Removing security providers loaded in web app: " + providersToRemove); for (String providerName : providersToRemove) { java.security.Security.removeProvider(providerName); } } }
From source file:com.mirth.connect.server.controllers.DefaultConfigurationController.java
/** * Checks for an existing certificate to use for secure communication between the server and * client. If no certficate exists, this will generate a new one. * /* w ww. j a va 2s .c o m*/ */ private void generateDefaultCertificate(Provider provider, KeyStore keyStore, char[] keyPassword) throws Exception { final String certificateAlias = "mirthconnect"; if (!keyStore.containsAlias(certificateAlias)) { // Common CA and SSL cert attributes Date startDate = new Date(); // time from which certificate is valid Date expiryDate = DateUtils.addYears(startDate, 50); // time after which certificate is not valid KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", provider); keyPairGenerator.initialize(2048); KeyPair caKeyPair = keyPairGenerator.generateKeyPair(); logger.debug("generated new key pair for CA cert using provider: " + provider.getName()); // Generate CA cert X500Name caSubjectName = new X500Name("CN=Mirth Connect Certificate Authority"); SubjectPublicKeyInfo caSubjectKey = new SubjectPublicKeyInfo( ASN1Sequence.getInstance(caKeyPair.getPublic().getEncoded())); X509v3CertificateBuilder certBuilder = new X509v3CertificateBuilder(caSubjectName, BigInteger.ONE, startDate, expiryDate, caSubjectName, caSubjectKey); certBuilder.addExtension(org.bouncycastle.asn1.x509.Extension.basicConstraints, true, new BasicConstraints(0)); ContentSigner sigGen = new JcaContentSignerBuilder("SHA256withRSA").setProvider(provider) .build(caKeyPair.getPrivate()); Certificate caCert = new JcaX509CertificateConverter().setProvider(provider) .getCertificate(certBuilder.build(sigGen)); // Generate SSL cert KeyPair sslKeyPair = keyPairGenerator.generateKeyPair(); logger.debug("generated new key pair for SSL cert using provider: " + provider.getName()); X500Name sslSubjectName = new X500Name("CN=mirth-connect"); SubjectPublicKeyInfo sslSubjectKey = new SubjectPublicKeyInfo( ASN1Sequence.getInstance(sslKeyPair.getPublic().getEncoded())); X509v3CertificateBuilder sslCertBuilder = new X509v3CertificateBuilder(caSubjectName, new BigInteger(50, new SecureRandom()), startDate, expiryDate, sslSubjectName, sslSubjectKey); sslCertBuilder.addExtension(org.bouncycastle.asn1.x509.Extension.authorityKeyIdentifier, false, new AuthorityKeyIdentifier(caCert.getEncoded())); sslCertBuilder.addExtension(org.bouncycastle.asn1.x509.Extension.subjectKeyIdentifier, false, new SubjectKeyIdentifier(sslKeyPair.getPublic().getEncoded())); sigGen = new JcaContentSignerBuilder("SHA256withRSA").setProvider(provider) .build(caKeyPair.getPrivate()); Certificate sslCert = new JcaX509CertificateConverter().setProvider(provider) .getCertificate(sslCertBuilder.build(sigGen)); logger.debug("generated new certificate with serial number: " + ((X509Certificate) sslCert).getSerialNumber()); // add the generated SSL cert to the keystore using the key password keyStore.setKeyEntry(certificateAlias, sslKeyPair.getPrivate(), keyPassword, new Certificate[] { sslCert }); } else { logger.debug("found certificate in keystore"); } }
From source file:com.cloud.network.NetworkModelImpl.java
@Override public List<Service> getElementServices(Provider provider) { NetworkElement element = getElementImplementingProvider(provider.getName()); if (element == null) { throw new InvalidParameterValueException( "Unable to find the Network Element implementing the Service Provider '" + provider.getName() + "'"); }/*w w w . j ava 2s. c o m*/ return new ArrayList<Service>(element.getCapabilities().keySet()); }