Search in sources :

Example 51 with Provider

use of java.security.Provider in project jdk8u_jdk by JetBrains.

the class TestJSSE method client.

public static void client(int testPort, String testProtocols, String testCipher, String... exception) throws Exception {
    String expectedException = exception.length >= 1 ? exception[0] : null;
    out.println("=========================================");
    out.println(" Testing - https://" + LOCAL_IP + ":" + testPort);
    out.println(" Testing - Protocol : " + testProtocols);
    out.println(" Testing - Cipher : " + testCipher);
    Provider p = new sun.security.ec.SunEC();
    Security.insertProviderAt(p, 1);
    try {
        CipherTestUtils.main(new JSSEFactory(LOCAL_IP, testPort, testProtocols, testCipher, "client JSSE"), "client", expectedException);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Provider(java.security.Provider)

Example 52 with Provider

use of java.security.Provider in project jdk8u_jdk by JetBrains.

the class CaseSensitiveServices method main.

public static void main(String[] args) throws Exception {
    Provider p = new CaseSensitiveServices();
    System.out.println(p.getServices());
    if (p.getServices().size() != 3) {
        throw new Exception("services.size() should be 3");
    }
    Service s = testService(p, "MessageDigest", "fOO");
    String val = s.getAttribute("Xyz");
    if ("aBc".equals(val) == false) {
        throw new Exception("Wrong value: " + val);
    }
    testService(p, "MessageDigest", "fU");
    testService(p, "MessageDigest", "BAR");
    testService(p, "MessageDigest", "baz");
    System.out.println("OK");
}
Also used : Provider(java.security.Provider)

Example 53 with Provider

use of java.security.Provider in project jdk8u_jdk by JetBrains.

the class ProviderVersionCheck method main.

public static void main(String[] arg) throws Exception {
    boolean failure = false;
    for (Provider p : Security.getProviders()) {
        System.out.print(p.getName() + " ");
        if (p.getVersion() != 1.8d) {
            System.out.println("failed. " + "Version received was " + p.getVersion());
            failure = true;
        } else {
            System.out.println("passed.");
        }
    }
    if (failure) {
        throw new Exception("Provider(s) failed to have the expected " + "version value.");
    }
}
Also used : Exception(java.lang.Exception) Provider(java.security.Provider)

Example 54 with Provider

use of java.security.Provider in project jdk8u_jdk by JetBrains.

the class FinalizeHalf method main.

public static void main(String[] args) throws Throwable {
    List<Consumer<Key>> methods = new ArrayList<>();
    methods.add((Key k) -> k.getEncoded());
    methods.add((Key k) -> k.toString());
    for (String algo : new String[] { "DiffieHellman", "DSA", "RSA" }) {
        for (Provider provider : Security.getProviders()) {
            for (boolean priv : new boolean[] { true, false }) {
                for (Consumer<Key> method : methods) {
                    test(algo, provider, priv, method);
                }
            }
        }
    }
    if (failures > 0) {
        throw new RuntimeException(failures + " test(s) failed.");
    }
}
Also used : Consumer(java.util.function.Consumer) ArrayList(java.util.ArrayList) Key(java.security.Key) Provider(java.security.Provider)

Example 55 with Provider

use of java.security.Provider in project symmetric-ds by JumpMind.

the class AbstractCommandLauncher method configureCrypto.

protected void configureCrypto(CommandLine line) throws Exception {
    if (line.hasOption(OPTION_KEYSTORE_PASSWORD)) {
        System.setProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD, line.getOptionValue(OPTION_KEYSTORE_PASSWORD));
    }
    if (line.hasOption(OPTION_KEYSTORE_TYPE)) {
        System.setProperty(SystemConstants.SYSPROP_KEYSTORE_TYPE, line.getOptionValue(OPTION_KEYSTORE_TYPE));
    }
    if (line.hasOption(OPTION_JCE_PROVIDER)) {
        Provider provider = (Provider) Class.forName(line.getOptionValue(OPTION_JCE_PROVIDER)).newInstance();
        Security.addProvider(provider);
    }
}
Also used : Provider(java.security.Provider)

Aggregations

Provider (java.security.Provider)243 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)49 ArrayList (java.util.ArrayList)26 MessageDigest (java.security.MessageDigest)21 List (java.util.List)20 Key (java.security.Key)19 KeyStore (java.security.KeyStore)19 Service (java.security.Provider.Service)15 ExemptionMechanism (javax.crypto.ExemptionMechanism)14 SpiEngUtils (org.apache.harmony.security.tests.support.SpiEngUtils)14 InvalidKeyException (java.security.InvalidKeyException)13 SecureRandom (java.security.SecureRandom)13 IOException (java.io.IOException)12 NoSuchProviderException (java.security.NoSuchProviderException)12 SecretKey (javax.crypto.SecretKey)12 KeyStoreException (java.security.KeyStoreException)11 CertificateException (java.security.cert.CertificateException)11 Cipher (javax.crypto.Cipher)11 KeyGenerator (javax.crypto.KeyGenerator)11 MyExemptionMechanismSpi.tmpKey (org.apache.harmony.crypto.tests.support.MyExemptionMechanismSpi.tmpKey)11