本文整理汇总了Java中java.security.KeyStoreSpi类的典型用法代码示例。如果您正苦于以下问题:Java KeyStoreSpi类的具体用法?Java KeyStoreSpi怎么用?Java KeyStoreSpi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyStoreSpi类属于java.security包,在下文中一共展示了KeyStoreSpi类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_KeyStoreSpi
import java.security.KeyStoreSpi; //导入依赖的package包/类
@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");
}
}
示例2: main
import java.security.KeyStoreSpi; //导入依赖的package包/类
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);
}
}
示例3: MyKeyStore
import java.security.KeyStoreSpi; //导入依赖的package包/类
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
String type) {
super(keyStoreSpi, provider, type);
}
示例4: MockKeyStore
import java.security.KeyStoreSpi; //导入依赖的package包/类
public MockKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) {
super(keyStoreSpi, provider, type);
}
示例5: tmpKeyStore
import java.security.KeyStoreSpi; //导入依赖的package包/类
public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) {
super(spi, prov, alg);
}