當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyStoreSpi類代碼示例

本文整理匯總了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");
    }
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:18,代碼來源:KeyStoreSpiTest.java

示例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);
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:35,代碼來源:KeyStoreEmptyCertChain.java

示例3: MyKeyStore

import java.security.KeyStoreSpi; //導入依賴的package包/類
public MyKeyStore(KeyStoreSpi keyStoreSpi, Provider provider,
        String type) {
    super(keyStoreSpi, provider, type);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:5,代碼來源:KeyStore3Test.java

示例4: MockKeyStore

import java.security.KeyStoreSpi; //導入依賴的package包/類
public MockKeyStore(KeyStoreSpi keyStoreSpi, Provider provider, String type) {
    super(keyStoreSpi, provider, type);            
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:4,代碼來源:KeyStore2Test.java

示例5: tmpKeyStore

import java.security.KeyStoreSpi; //導入依賴的package包/類
public tmpKeyStore(KeyStoreSpi spi, Provider prov, String alg) {
    super(spi, prov, alg);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:4,代碼來源:KeyStore_Impl1Test.java


注:本文中的java.security.KeyStoreSpi類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。