java.security.KeyStoreSpi Java Examples

The following examples show how to use java.security.KeyStoreSpi. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KeyStoreSpiTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_engineEntryInstanceOf() throws Exception {

        KeyStoreSpi ksSpi = new MyKeyStoreSpi();

        assertTrue(ksSpi.engineEntryInstanceOf(
                "test_engineEntryInstanceOf_Alias1",
                KeyStore.PrivateKeyEntry.class));

        assertFalse(ksSpi.engineEntryInstanceOf(
                "test_engineEntryInstanceOf_Alias2",
                KeyStore.SecretKeyEntry.class));

        assertFalse(ksSpi.engineEntryInstanceOf(
                "test_engineEntryInstanceOf_Alias3",
                KeyStore.TrustedCertificateEntry.class));

        try {
            ksSpi.engineEntryInstanceOf(null, KeyStore.TrustedCertificateEntry.class);
            fail();
        } catch (NullPointerException expected) {
        }

        assertFalse(ksSpi.engineEntryInstanceOf("test_engineEntryInstanceOf_Alias1", null));
    }
 
Example #2
Source File: TlsHelperTest.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
    days = 360;
    keySize = 2048;
    keyPairAlgorithm = "RSA";
    signingAlgorithm = "SHA1WITHRSA";
    keyPairGenerator = KeyPairGenerator.getInstance(keyPairAlgorithm);
    keyPairGenerator.initialize(keySize);
    Constructor<KeyStore> keyStoreConstructor = KeyStore.class.getDeclaredConstructor(KeyStoreSpi.class, Provider.class, String.class);
    keyStoreConstructor.setAccessible(true);
    keyStore = keyStoreConstructor.newInstance(keyStoreSpi, keyStoreProvider, "faketype");
    keyStore.load(null, null);
    file = File.createTempFile("keystore", "file");
    when(outputStreamFactory.create(file)).thenReturn(tmpFileOutputStream);
}
 
Example #3
Source File: KeyStoreSpiTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("cast")
public void test_KeyStoreSpi() {

    try {
        MyKeyStoreSpi ksSpi = new MyKeyStoreSpi();
        assertNotNull(ksSpi);
        assertTrue(ksSpi instanceof KeyStoreSpi);
    } catch (Exception ex) {
        fail("Unexpected exception");
    }
}
 
Example #4
Source File: TlsHelperTest.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
    days = 360;
    keySize = 2048;
    keyPairAlgorithm = "RSA";
    signingAlgorithm = "SHA1WITHRSA";
    keyPairGenerator = KeyPairGenerator.getInstance(keyPairAlgorithm);
    keyPairGenerator.initialize(keySize);
    Constructor<KeyStore> keyStoreConstructor = KeyStore.class.getDeclaredConstructor(KeyStoreSpi.class, Provider.class, String.class);
    keyStoreConstructor.setAccessible(true);
    keyStore = keyStoreConstructor.newInstance(keyStoreSpi, keyStoreProvider, "faketype");
    keyStore.load(null, null);
    file = File.createTempFile("keystore", "file");
    when(outputStreamFactory.create(file)).thenReturn(tmpFileOutputStream);
}