Class KeySelector
java.lang.Object
javax.xml.crypto.KeySelector
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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe purpose of the key that is to be selected. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault no-args constructor; intended for invocation by subclasses only. -
Method Summary
Modifier and TypeMethodDescriptionabstract 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 aKeySelectorthat always selects the specified key, regardless of theKeyInfopassed to it.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
KeySelector
protected KeySelector()Default no-args constructor; intended for invocation by subclasses only.
-
-
Method Details
-
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
Returns aKeySelectorthat 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
-