List of usage examples for java.security Provider getVersion
@Deprecated(since = "9") public double getVersion()
From source file:MainClass.java
public static void main(String[] args) throws Exception { Provider p = Security.getProvider("Rot13Provider"); System.out.println("Provider name: " + p.getName()); System.out.println("Provider version: " + p.getVersion()); System.out.println("Provider information: " + p.getInfo()); Cipher cipher = Cipher.getInstance("ROT13", "Rot13Provider"); System.out.println("Cipher: " + cipher.getAlgorithm()); String testString = "This is a test!"; cipher.init(Cipher.ENCRYPT_MODE, (Key) null, new SecureRandom()); byte[] b1 = cipher.doFinal(testString.getBytes()); cipher.init(Cipher.DECRYPT_MODE, (Key) null, new SecureRandom()); byte[] b2 = cipher.doFinal(b1); System.out.println("Decrypted data as a String: " + new String(b2)); }
From source file:org.jenkinsci.plugins.relution_publisher.configuration.jobs.ArtifactPublisher.java
private void logProviderInformation(final Log log) { log.write(this, "Available security providers:"); final Provider[] providers = Security.getProviders(); for (final Provider provider : providers) { log.write(this, "%s %s", provider.getName(), String.valueOf(provider.getVersion())); }//from w w w . j a va 2 s .com log.write(); }
From source file:org.mule.providers.ldap.LdapSASLConnector.java
protected void doInitialise() throws InitialisationException { // if (isForceJDK14()) // {/*from ww w. jav a 2 s . c o m*/ // logger.debug("forcing JDK 1.4 SASL mode"); Security.addProvider(new com.novell.sasl.client.SaslProvider()); // } /* * else { Provider sunSASL = Security.getProvider("SunSASL"); * * if (sunSASL != null) { logger .debug("SunSASL implementation (JDK >= * 1.5) detected. Use it."); try { Sasl.setSaslClientFactory(new * SaslBridgeClientFactory()); } catch (RuntimeException e) { * logger.warn(e.toString()); } } else { logger .debug("No SunSASL * implementation (JDK >= 1.5 detected. Fall back to JDK 1.4 mode"); * Security.addProvider(new com.novell.sasl.client.SaslProvider()); } } */ if (logger.isDebugEnabled()) { Provider[] ps = Security.getProviders(); for (int i = 0; i < ps.length; i++) { Provider provider = ps[i]; logger.debug(provider.getClass() + "/" + provider.getName() + "/" + provider.getVersion() + "/" + provider.getInfo()); } } if (MECHANISM_DIGEST_EXTERNAL.equals(mechanism)) { try { if (trustAll) { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, trustAll ? TrustAllCertsManager.getTrustAllCertsManager() : null, null); // certificate_unknown ssf = new LDAPJSSESecureSocketFactory(context.getSocketFactory()); } else { if (StringUtils.isEmpty(trustStore)) { throw new InitialisationException(new IllegalArgumentException( "Either trustAll value must be true or the trustStore parameter must be set"), this); } File trustStoreFile = new File(trustStore); if (!trustStoreFile.exists() || !trustStoreFile.canRead()) { throw new InitialisationException(new IllegalArgumentException("truststore file " + trustStoreFile.getAbsolutePath() + " do not exist or is not readable"), this); } System.setProperty("javax.net.ssl.trustStore", trustStore); logger.debug("truststore set to " + trustStoreFile.getAbsolutePath()); ssf = new LDAPJSSESecureSocketFactory(); } // pix path // ssf = new LDAPJSSESecureSocketFactory((SSLSocketFactory) // SSLSocketFactory.getDefault()); // TODO SSL<->TLS (TLS maybe require startTLS() call on lc // ssf = new LDAPJSSEStartTLSFactory(); } catch (KeyManagementException e) { throw new InitialisationException(e, this); } catch (NoSuchAlgorithmException e) { throw new InitialisationException(e, this); } } super.doInitialise(); }