Class KeySelector
- 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 KeyInfo
object. An example of an implementation of this class is one that searches a KeyStore
for trusted keys that match information contained in a KeyInfo
.
Whether or not the returned key is trusted and the mechanisms used to determine that is implementation-specific.
- Since:
- 1.6
Nested Classes
Modifier and Type | Class | Description |
---|---|---|
static class | KeySelector.Purpose | The purpose of the key that is to be selected. |
Constructors
Modifier | Constructor | Description |
---|---|---|
protected | KeySelector() | Default no-args constructor; intended for invocation by subclasses only. |
Methods
Modifier and Type | Method | Description |
---|---|---|
abstract KeySelectorResult | select(KeyInfo keyInfo,
KeySelector.Purpose purpose,
AlgorithmMethod method,
XMLCryptoContext context) | Attempts to find a key that satisfies the specified constraints. |
static KeySelector | singletonKeySelector(Key key) | Returns a |
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructors
KeySelector
protected KeySelector()
Default no-args constructor; intended for invocation by subclasses only.
Methods
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
- anXMLCryptoContext
that may contain useful information for finding an appropriate key. If this key selector supports resolvingRetrievalMethod
types, the context'sbaseURI
anddereferencer
parameters (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 (null
should be returned in that case). However, an error condition (ex: network communications failure) that prevented theKeySelector
from finding a potential key should be considered an exception. -
ClassCastException
- if the data type ofmethod
is not supported by this key selector
singletonKeySelector
public static KeySelector singletonKeySelector(Key key)
Returns a KeySelector
that always selects the specified key, regardless of the KeyInfo
passed 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
- ifkey
isnull
© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/java.xml.crypto/javax/xml/crypto/KeySelector.html