当前位置: 首页>>代码示例>>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;未经允许,请勿转载。