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