Java 类java.security.KeyFactorySpi 实例源码

项目:j2objc    文件:KeyFactorySpiTest.java   
/**
 * Test for <code>KeyFactorySpi</code> constructor
 * Assertion: constructs KeyFactorySpi
 */
public void testKeyFactorySpi() {
    MyKeyFactorySpi keyFSpi = new MyKeyFactorySpi();
    assertTrue(keyFSpi instanceof KeyFactorySpi);

    KeySpec ks = new MyKeySpec();
    KeySpec kss = new MyKeySpec();
    try {
        keyFSpi.engineGeneratePrivate(ks);
        keyFSpi.engineGeneratePublic(ks);
        keyFSpi.engineGetKeySpec(null, java.lang.Class.class);
        keyFSpi.engineTranslateKey(null);
    } catch (Exception e) {
        fail("Unexpected exception");
    }
}
项目:In-the-Box-Fork    文件:KeyFactory2Test.java   
/**
 * @tests java.security.KeyFactory#KeyFactory(java.security.KeyFactorySpi,
 *        java.security.Provider, java.lang.String)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "KeyFactory",
    args = {java.security.KeyFactorySpi.class, java.security.Provider.class, java.lang.String.class}
)
public void test_constructor() {
    KeyFactorySpi kfs = new KeyFactorySpiStub();

    try {
        new KeyFactoryStub(null, null, null);
    } catch (Exception e) {
        fail("Unexpected exception " + e.getMessage());
    }

    Provider[] providers = Security.getProviders("KeyFactory.DSA");
    if (providers != null) {
        for (int i = 0; i < providers.length; i++) {
            KeyFactoryStub kf = new KeyFactoryStub(kfs, providers[i],
                    "algorithm name");
            assertEquals("algorithm name", kf.getAlgorithm());
            assertEquals(providers[i], kf.getProvider());
        }
    } else {
        fail("No providers support KeyFactory.DSA");
    }
}
项目:In-the-Box-Fork    文件:KeyFactorySpiTest.java   
/**
 * Test for <code>KeyFactorySpi</code> constructor
 * Assertion: constructs KeyFactorySpi
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "KeyFactorySpi",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "engineGeneratePrivate",
        args = {java.security.spec.KeySpec.class}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "engineGeneratePublic",
        args = {java.security.spec.KeySpec.class}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "engineTranslateKey",
        args = {java.security.Key.class}
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "",
        method = "engineGetKeySpec",
        args = {java.security.Key.class, java.lang.Class.class}
    )
})
public void testKeyFactorySpi() {
    MyKeyFactorySpi keyFSpi = new MyKeyFactorySpi();
    assertTrue(keyFSpi instanceof KeyFactorySpi);

    KeySpec ks = new MyKeySpec();
    KeySpec kss = new MyKeySpec();
    try {
        keyFSpi.engineGeneratePrivate(ks);
        keyFSpi.engineGeneratePublic(ks);
        keyFSpi.engineGetKeySpec(null, java.lang.Class.class);
        keyFSpi.engineTranslateKey(null);
    } catch (Exception e) {
        fail("Unexpected exception");
    }
}
项目:In-the-Box-Fork    文件:KeyFactory2Test.java   
public KeyFactoryStub(KeyFactorySpi keyFacSpi, Provider provider,
        String algorithm) {
    super(keyFacSpi, provider, algorithm);
}