- java.lang.Object
-
- javax.xml.crypto.KeySelector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 static classKeySelector.Purpose要选择的键的目的。
-
构造方法摘要
构造方法 Modifier Constructor 描述 protectedKeySelector()默认的无参数构造函数; 仅供子类调用。
-
方法摘要
所有方法 静态方法 接口方法 抽象方法 具体的方法 Modifier and Type 方法 描述 abstract KeySelectorResultselect(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)尝试找到满足指定约束的键。static KeySelectorsingletonKeySelector(Key key)返回一个KeySelector,总是选择指定的键,而不管传递给它的是什么KeyInfo。
-
-
-
方法详细信息
-
select
public abstract KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException
尝试找到满足指定约束的键。- 参数
-
keyInfo- aKeyInfo(可能为null) -
purpose-密钥的目的(KeySelector.Purpose.SIGN,KeySelector.Purpose.VERIFY,KeySelector.Purpose.ENCRYPT,或KeySelector.Purpose.DECRYPT) -
method- 该密钥用于的算法方法。 应该只返回与算法兼容并满足指定算法约束的键。 -
context- 一个XMLCryptoContext,其中可能包含用于查找适当键的有用信息。 如果此密钥选择器支持解析RetrievalMethod类型,则选择器应使用上下文的baseURI和dereferencer参数(如果指定)来解析dereferencer引用URI。 - 结果
- 键选择器的结果
- 异常
-
KeySelectorException- 如果尝试找到密钥时发生异常情况。 请注意,无法找到密钥不被视为异常(在这种情况下应返回null)。 然而,阻止KeySelector找到潜在密钥的错误状况(例如:网络通信故障)应被视为异常。 -
ClassCastException- 如果此键选择器不支持method的数据类型
-
singletonKeySelector
public static KeySelector singletonKeySelector(Key key)
返回KeySelector总是选择指定密钥,不管的KeyInfo传递给它。- 参数
-
key- 要存储在钥匙选择器中的唯一钥匙 - 结果
- 一个总是选择指定键的键选择器
- 异常
-
NullPointerException- ifkeyisnull
-
-