- 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 aKeyInfo
object. An example of an implementation of this class is one that searchs aKeyStore
for 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 and Description static class
KeySelector.Purpose
The purpose of the key that is to be selected.
-
Constructor Summary
Constructors Modifier Constructor and Description protected
KeySelector()
Default no-args constructor; intended for invocation by subclasses only.
-
Method Summary
Methods Modifier and Type Method and 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 aKeySelector
that always selects the specified key, regardless of theKeyInfo
passed to it.
-
-
-
Constructor Detail
-
KeySelector
protected KeySelector()
Default no-args constructor; intended for invocation by subclasses only.
-
-
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
- 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 aKeySelector
that always selects the specified key, regardless of theKeyInfo
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
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/xml/crypto/keyselector.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.