List of usage examples for java.security Security getProviders
public static Provider[] getProviders()
From source file:org.opendaylight.snbi.southplugin.DomainInfo.java
public void printProviders() { Provider[] ps = Security.getProviders(); for (int i = 0; i < ps.length; i++) logger.info("Security Provider " + ps[i].getName()); }
From source file:org.texai.x509.X509Utils.java
/** Logs the cryptography providers. */ public static void logProviders() { LOGGER.info("cryptography providers ..."); final Provider[] providers = Security.getProviders(); for (int i = 0; i != providers.length; i++) { LOGGER.info(" Name: " + providers[i].getName() + StringUtils.makeBlankString(15 - providers[i].getName().length()) + " Version: " + providers[i].getVersion()); }// w ww. j a v a2 s. c om }
From source file:org.viafirma.nucleo.inicio.SecurityProvidersUtils.java
/** * Inicializa los proveedores criptograficos para corregir problemas con las * distintas maquinas virtuales//from www.j a v a 2s. co m */ public static void initProviders() { BouncyCastleProvider bc = new BouncyCastleProvider(); // Eliminamos el proveedor para evitar que se solapen si ya existia uno. Security.removeProvider(bc.getName()); Security.addProvider(bc); log.info("Lista de proveedores disponible:" + Arrays.asList(Security.getProviders())); addHMACAlgorithm(bc, "SHA2", "org.bouncycastle.jce.provider.JCEMac$SHA256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA256"); addHMACAlias(bc, "SHA2", PKCSObjectIdentifiers.id_hmacWithSHA256); Security.addProvider(bc); }
From source file:org.wso2.carbon.security.tls.CarbonTLSDump.java
/** * //from w w w . j ava 2s .co m * @param ctxt */ protected void activate(ComponentContext context) { try { // returns an array containing all the installed providers. the order of the providers in the array is their // preference order. Provider providers[] = Security.getProviders(); StringBuilder buffer = new StringBuilder(); buffer.append(System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("[The list of crypto providers available in the system]" + System.lineSeparator()); buffer.append(System.lineSeparator()); for (int i = 0; i < providers.length; i++) { buffer.append((providers[i].getName() + ":" + providers[i].getClass().getName() + System.lineSeparator())); } // returns the default SSL server socket factory. // the first time this method is called, the security property "ssl.ServerSocketFactory.provider" is // examined. if it is non-null, a class by that name is loaded and instantiated. if that is successful and // the object is an instance of SSLServerSocketFactory, it is made the default SSL server socket factory. // otherwise, this method returns SSLContext.getDefault().getServerSocketFactory(). if that call fails, an // inoperative factory is returned. SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); buffer.append(System.lineSeparator()); buffer.append("[Java Secure Socket Extension (JSSE)]" + System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("JSSE provider name: " + SSLContext.getDefault().getProvider().getName() + System.lineSeparator()); buffer.append("JSSE provider info: " + SSLContext.getDefault().getProvider().getInfo() + System.lineSeparator()); buffer.append("JSSE implementation class name: " + SSLContext.getDefault().getProvider().getClass().getName() + System.lineSeparator()); buffer.append(System.lineSeparator()); // returns a copy of the SSLParameters indicating the default settings for this SSL context. // the parameters will always have the cipher suites and protocols arrays set to non-null values. SSLParameters sslParams = SSLContext.getDefault().getDefaultSSLParameters(); buffer.append("[Configuration data from catalina-server.xml]" + System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("Cipher suites configured in the system: " + System.lineSeparator()); loadFromArray(sslParams.getCipherSuites(), buffer); buffer.append(System.lineSeparator()); buffer.append("TLS/SSL protocols configured in the system: " + System.lineSeparator()); loadFromArray(sslParams.getProtocols(), buffer); buffer.append(System.lineSeparator()); buffer.append("Client authentication is required ? " + sslParams.getNeedClientAuth() + System.lineSeparator()); buffer.append( "Client authentication is optional? " + sslParams.getWantClientAuth() + System.lineSeparator()); buffer.append(System.lineSeparator()); buffer.append("[Runtime SSL/TLS details]" + System.lineSeparator()); buffer.append(System.lineSeparator()); // returns the names of the cipher suites which could be enabled for use on an SSL connection created by // this factory. normally, only a subset of these will actually be enabled by default, since this list may // include cipher suites which do not meet quality of service requirements for those defaults. such cipher // suites are useful in specialized applications. String[] availableCiphers = ssf.getSupportedCipherSuites(); buffer.append( "All available cipher suites from the JSSE provider in the system:" + System.lineSeparator()); boolean isJdkPatched = false; for (int i = 0; i < availableCiphers.length; ++i) { if (JAVA_VERSION.equals("1.8") && Java8CipherUtil.TLS_DHE_RSA_WITH_AES_256_GCM_SHA384.equals(availableCiphers[i])) { isJdkPatched = true; } else if (JAVA_VERSION.equals("1.7") && Java7CipherUtil.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384.equals(availableCiphers[i])) { isJdkPatched = true; } buffer.append("\t" + "\t" + availableCiphers[i] + System.lineSeparator()); } buffer.append(System.lineSeparator()); // returns the list of cipher suites which are enabled by default. unless a different list is enabled, // handshaking on an SSL connection will use one of these cipher suites. The minimum quality of service for // these defaults requires confidentiality protection and server authentication (that is, no anonymous // cipher suites). String[] defaultCiphers = ssf.getDefaultCipherSuites(); buffer.append("The list of cipher suites functional in the system with the JSSE provider:" + System.lineSeparator()); for (int i = 0; i < defaultCiphers.length; ++i) { buffer.append("\t" + "\t" + defaultCiphers[i] + System.lineSeparator()); } buffer.append(System.lineSeparator()); buffer.append("Is the JDK patched with JCE unlimited strength jurisdiction policy files ? " + isJdkPatched + System.lineSeparator()); log.info(buffer.toString()); } catch (Throwable e) { log.error(e); } }
From source file:org.xdi.oxauth.model.util.JwtUtil.java
public static void printAlgorithmsAndProviders() { Set<String> algorithms = Security.getAlgorithms("Signature"); for (String algorithm : algorithms) { log.trace("Algorithm (Signature): " + algorithm); }//from w w w. jav a2 s .c om algorithms = Security.getAlgorithms("MessageDigest"); for (String algorithm : algorithms) { log.trace("Algorithm (MessageDigest): " + algorithm); } algorithms = Security.getAlgorithms("Cipher"); for (String algorithm : algorithms) { log.trace("Algorithm (Cipher): " + algorithm); } algorithms = Security.getAlgorithms("Mac"); for (String algorithm : algorithms) { log.trace("Algorithm (Mac): " + algorithm); } algorithms = Security.getAlgorithms("KeyStore"); for (String algorithm : algorithms) { log.trace("Algorithm (KeyStore): " + algorithm); } Provider[] providers = Security.getProviders(); for (Provider provider : providers) { log.trace("Provider: " + provider.getName()); } }
From source file:test.be.fedict.eid.applet.RSATest.java
@Test public void testListSecurityProviders() throws Exception { Provider[] providers = Security.getProviders(); for (Provider provider : providers) { LOG.debug("provider name: " + provider.getName()); LOG.debug("provider info: " + provider.getInfo()); Set<Service> services = provider.getServices(); for (Service service : services) { LOG.debug("\tservice type: " + service.getType()); LOG.debug("\tservice algo: " + service.getAlgorithm()); }/*www . j a va 2s.co m*/ } }
From source file:test.integ.be.agiv.security.Config.java
public Config() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException, NoSuchProviderException { Properties properties = new Properties(); properties.load(Config.class.getResourceAsStream("/agiv.properties")); this.username = properties.getProperty("username"); this.password = properties.getProperty("password"); this.pkcs12Path = properties.getProperty("pkcs12.path"); this.pkcs12Password = properties.getProperty("pkcs12.password"); Provider[] providers = Security.getProviders(); for (Provider provider : providers) { LOG.debug("security provider: " + provider.getName()); }/*w ww. ja va 2 s . c o m*/ if (null != this.pkcs12Path) { InputStream pkcs12InputStream = new FileInputStream(pkcs12Path); KeyStore keyStore = KeyStore.getInstance("PKCS12", "SunJSSE"); keyStore.load(pkcs12InputStream, pkcs12Password.toCharArray()); Enumeration<String> aliases = keyStore.aliases(); String alias = aliases.nextElement(); this.certificate = (X509Certificate) keyStore.getCertificate(alias); this.privateKey = (PrivateKey) keyStore.getKey(alias, this.pkcs12Password.toCharArray()); } else { this.certificate = null; this.privateKey = null; } }