Class X509KeySelector
- java.lang.Object
-
- javax.xml.crypto.KeySelector
-
- org.certificateservices.messages.csmessages.X509KeySelector
-
- Direct Known Subclasses:
X509KeySelector
public class X509KeySelector extends javax.xml.crypto.KeySelectorCode taken from the SUN Oracle examples. AKeySelectorthat returnsPublicKeys of trustedX509Certificates stored in aKeyStore.This
KeySelectoruses the specifiedKeyStoreto find a trustedX509Certificatethat matches information specified in theKeyInfopassed to theselect(javax.xml.crypto.dsig.keyinfo.KeyInfo, javax.xml.crypto.KeySelector.Purpose, javax.xml.crypto.AlgorithmMethod, javax.xml.crypto.XMLCryptoContext)method. The public key from the first match is returned. If no match,nullis returned. See theselectmethod for more information.NOTE!: This X509KeySelector requires J2SE 1.4 because it uses the java.security.cert.X509CertSelector and javax.security.auth.x500.X500Principal classes to parse X.500 DNs and match on certificate attributes.
-
-
Constructor Summary
Constructors Constructor Description X509KeySelector(java.security.KeyStore keyStore)Creates anX509KeySelector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.xml.crypto.KeySelectorResultselect(javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo, javax.xml.crypto.KeySelector.Purpose purpose, javax.xml.crypto.AlgorithmMethod method, javax.xml.crypto.XMLCryptoContext context)Finds a key from the keystore satisfying the specified constraints.
-
-
-
Constructor Detail
-
X509KeySelector
public X509KeySelector(java.security.KeyStore keyStore) throws java.security.KeyStoreExceptionCreates anX509KeySelector.- Parameters:
keyStore- the keystore- Throws:
java.security.KeyStoreException- if the keystore has not been initializedjava.lang.NullPointerException- ifkeyStoreisnull
-
-
Method Detail
-
select
public javax.xml.crypto.KeySelectorResult select(javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo, javax.xml.crypto.KeySelector.Purpose purpose, javax.xml.crypto.AlgorithmMethod method, javax.xml.crypto.XMLCryptoContext context) throws javax.xml.crypto.KeySelectorExceptionFinds a key from the keystore satisfying the specified constraints.This method compares data contained in
KeyInfoentries with information stored in theKeyStore. The implementation iterates over the KeyInfo types and returns the firstPublicKeyof an X509Certificate in the keystore that is compatible with the specified AlgorithmMethod according to the following rules for each keyinfo type: X509Data X509Certificate: if it contains aKeyUsageextension that asserts thedigitalSignaturebit and matches anX509Certificatein theKeyStore. X509Data X509IssuerSerial: if the serial number and issuer DN match anX509Certificatein theKeyStore. X509Data X509SubjectName: if the subject DN matches anX509Certificatein theKeyStore. X509Data X509SKI: if the subject key identifier matches anX509Certificatein theKeyStore. KeyName: if the keyname matches an alias in theKeyStore. RetrievalMethod: supports rawX509Certificate and X509Data types. If rawX509Certificate type, it must match anX509Certificatein theKeyStore.- Specified by:
selectin classjavax.xml.crypto.KeySelector- Parameters:
keyInfo- aKeyInfo(may benull)purpose- the key's purposemethod- 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-XMLCryptoContextthat may contain additional useful information for finding an appropriate key- Returns:
- a key selector result
- Throws:
javax.xml.crypto.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.java.lang.ClassCastException- if the data type ofmethodis not supported by this key selector
-
-