KeySelector (Java SE 10 & JDK 10 )
- java.lang.Object
-
- javax.xml.crypto.KeySelector
-
public abstract class KeySelector extends Object
A selector that finds and returns a key using the data contained in a
KeyInfoobject. An example of an implementation of this class is one that searches aKeyStorefor trusted keys that match information contained in aKeyInfo.Whether or not the returned key is trusted and the mechanisms used to determine that is implementation-specific.
- Since:
- 1.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeySelector.PurposeThe purpose of the key that is to be selected.
-
Constructor Summary
Constructors Modifier Constructor Description protectedKeySelector()Default no-args constructor; intended for invocation by subclasses only.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract KeySelectorResultselect(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)Attempts to find a key that satisfies the specified constraints.
static KeySelectorsingletonKeySelector(Key key)Returns a
KeySelectorthat always selects the specified key, regardless of theKeyInfopassed to it.
-
-
-
Method Detail
-
select
public abstract KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException
Attempts to find a key that satisfies the specified constraints.
- Parameters:
keyInfo- aKeyInfo(may benull)purpose- the key's purpose (KeySelector.Purpose.SIGN,KeySelector.Purpose.VERIFY,KeySelector.Purpose.ENCRYPT, orKeySelector.Purpose.DECRYPT)method- the algorithm method that this key is to be used for. Only keys that are compatible with the algorithm and meet the constraints of the specified algorithm should be returned.context- anXMLCryptoContextthat may contain useful information for finding an appropriate key. If this key selector supports resolvingRetrievalMethodtypes, the context'sbaseURIanddereferencerparameters (if specified) should be used by the selector to resolve and dereference the URI.- Returns:
- the result of the key selector
- Throws:
KeySelectorException- if an exceptional condition occurs while attempting to find a key. Note that an inability to find a key is not considered an exception (nullshould be returned in that case). However, an error condition (ex: network communications failure) that prevented theKeySelectorfrom finding a potential key should be considered an exception.ClassCastException- if the data type ofmethodis not supported by this key selector
-
singletonKeySelector
public static KeySelector singletonKeySelector(Key key)
Returns a
KeySelectorthat always selects the specified key, regardless of theKeyInfopassed to it.- Parameters:
key- the sole key to be stored in the key selector- Returns:
- a key selector that always selects the specified key
- Throws:
NullPointerException- ifkeyisnull
-
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.