@SuppressWarnings("cast") @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "KeyStoreSpi", args = {} ) public void test_KeyStoreSpi() { try { MyKeyStoreSpi ksSpi = new MyKeyStoreSpi(); assertNotNull(ksSpi); assertTrue(ksSpi instanceof KeyStoreSpi); } catch (Exception ex) { fail("Unexpected exception"); } }
public static void main(String[] args) { try { KeyStore keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI"); keyStore.load(null, null); // Generate a certificate to use for testing CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); gen.generate(2048); Certificate cert = gen.getSelfCertificate(new X500Name("CN=test"), 3600); String alias = "JDK-8172244"; char[] password = "password".toCharArray(); KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); // generate a private key for the certificate kpg.initialize(2048); KeyPair keyPair = kpg.generateKeyPair(); PrivateKey privKey = keyPair.getPrivate(); // need to bypass checks to store the private key without the cert Field spiField = KeyStore.class.getDeclaredField("keyStoreSpi"); spiField.setAccessible(true); KeyStoreSpi spi = (KeyStoreSpi) spiField.get(keyStore); spi.engineSetKeyEntry(alias, privKey, password, new Certificate[0]); keyStore.store(null, null); keyStore.getCertificateAlias(cert); keyStore.deleteEntry(alias); // test passes if no exception is thrown } catch (Exception ex) { throw new RuntimeException(ex); } }
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) { super(keyStoreSpi, provider, type); }
public MockKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) { super(keyStoreSpi, provider, type); }
public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) { super(spi, prov, alg); }