Java 类java.security.KeyStoreSpi 实例源码
项目:In-the-Box-Fork
文件:KeyStoreSpiTest.java
@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");
}
}
项目:openjdk-jdk10
文件:KeyStoreEmptyCertChain.java
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);
}
}
项目:In-the-Box-Fork
文件:KeyStore3Test.java
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
String type) {
super(keyStoreSpi, provider, type);
}
项目:cn1
文件:KeyStore3Test.java
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
String type) {
super(keyStoreSpi, provider, type);
}
项目:cn1
文件:KeyStore2Test.java
public MockKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) {
super(keyStoreSpi, provider, type);
}
项目:cn1
文件:KeyStore_Impl1Test.java
public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}
项目:freeVM
文件:KeyStore3Test.java
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
String type) {
super(keyStoreSpi, provider, type);
}
项目:freeVM
文件:KeyStore_Impl1Test.java
public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}
项目:freeVM
文件:KeyStore3Test.java
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
String type) {
super(keyStoreSpi, provider, type);
}
项目:freeVM
文件:KeyStore2Test.java
public MockKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) {
super(keyStoreSpi, provider, type);
}
项目:freeVM
文件:KeyStore_Impl1Test.java
public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}