本文整理匯總了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);
}