Class KeyInfo
java.lang.Object
org.apache.xml.security.utils.ElementProxy
org.apache.xml.security.utils.SignatureElementProxy
org.apache.xml.security.keys.KeyInfo
This class stand for KeyInfo Element that may contain keys, names,
certificates and other public key management information,
such as in-band key distribution or key agreement data.
KeyInfo Element has two basic functions:
One is KeyResolve for getting the public key in signature validation processing.
the other one is toElement for getting the element in signature generation processing.
The
lengthXXX() methods provide access to the internal Key
objects:
- If the
KeyInfowas constructed from an Element (Signature verification), thelengthXXX()methods searches for child elements ofds:KeyInfofor known types. - If the
KeyInfowas constructed from scratch (during Signature generation), thelengthXXX()methods return the number ofXXXsobjects already passed to the KeyInfo
addXXX() methods are used for adding Objects of the
appropriate type to the KeyInfo. This is used during signature
generation.
The itemXXX(int i) methods return the i'th object of the
corresponding type.
The containsXXX() methods return whether the KeyInfo
contains the corresponding type.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<EncryptedKey> private List<KeyResolverSpi> Stores the individual (per-KeyInfo)KeyResolverSpisprivate static final org.slf4j.Loggerprivate static final List<StorageResolver> private booleanprivate List<StorageResolver> Field storageResolversFields inherited from class ElementProxy
baseURI -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMethod addvoidadd(EncryptedKey encryptedKey) Method addEncryptedKeyvoidadd(DEREncodedKeyValue derEncodedKeyValue) Method addvoidadd(KeyInfoReference keyInfoReference) Method addvoidMethod addvoidMethod addvoidadd(DSAKeyValue dsakeyvalue) Method addvoidadd(RSAKeyValue rsakeyvalue) Method addvoidMethod addvoidMethod addPGPDatavoidadd(RetrievalMethod retrievalmethod) Method addvoidMethod addvoidMethod addX509DatavoidMethod addDEREncodedKeyValuevoidMethod addKeyInfoReferencevoidaddKeyName(String keynameString) Method addKeyNamevoidaddKeyValue(PublicKey pk) Method addKeyValuevoidaddKeyValue(Element unknownKeyValueElement) Method addKeyValuevoidaddMgmtData(String mgmtdata) Method addMgmtDatavoidaddRetrievalMethod(String uri, Transforms transforms, String Type) Method addRetrievalMethodvoidaddStorageResolver(StorageResolver storageResolver) Method addStorageResolvervoidaddUnknownElement(Element element) Method addUnknownElementprivate X509CertificateapplyCurrentResolver(String uri, KeyResolverSpi keyResolver) booleanMethod containsDEREncodedKeyValuebooleanMethod containsKeyInfoReferencebooleanMethod containsKeyNamebooleanMethod containsKeyValuebooleanMethod containsMgmtDatabooleanMethod containsPGPDatabooleanMethod containsRetrievalMethodbooleanMethod containsSPKIDatabooleanMethod containsUnknownElementbooleanMethod containsX509DataReturns the localname of the Elements of the sub-class.getId()Returns theIdattributeThis method returns a private key.(package private) PrivateKeySearches the per-KeyInfo KeyResolvers for private keys(package private) PrivateKeySearches the library wide KeyResolvers for Private keysThis method returns the public key.(package private) PublicKeySearches the per-KeyInfo KeyResolvers for public keys(package private) PublicKeySearches the library wide KeyResolvers for public keysThis method returns a secret (symmetric) key.(package private) SecretKeySearches the per-KeyInfo KeyResolvers for secret keys(package private) SecretKeySearches the library wide KeyResolvers for Secret keysMethod getX509Certificate(package private) X509CertificateMethod getX509CertificateFromInternalResolvers(package private) X509CertificateThis method uses each System-wideKeyResolverto search the child elements.booleanisEmpty()Method isEmptyitemDEREncodedKeyValue(int i) Method itemDEREncodedKeyValueitemEncryptedKey(int i) Method itemEncryptedKey(package private) KeyResolverSpiitemInternalKeyResolver(int i) Method itemInternalKeyResolveritemKeyInfoReference(int i) Method itemKeyInfoReferenceitemKeyName(int i) Method itemKeyNameitemKeyValue(int i) Method itemKeyValueitemMgmtData(int i) Method itemMgmtDataitemPGPData(int i) Method itemPGPDataitemRetrievalMethod(int i) Method itemRetrievalMethoditemSPKIData(int i) Method itemSPKIDataitemUnknownElement(int i) Method itemUnknownElementitemX509Data(int i) Method itemX509DataintMethod lengthDEREncodedKeyValue(package private) intMethod lengthInternalKeyResolverintMethod lengthKeyInfoReferenceintMethod lengthKeyNameintMethod lengthKeyValueintMethod lengthMgmtDataintMethod lengthPGPDataintMethod lengthRetrievalMethodintMethod lengthSPKIDataintMethod lengthUnknownElement NOTE possibly buggy.intMethod lengthX509DatavoidregisterInternalKeyResolver(KeyResolverSpi realKeyResolver) This method is used to add a customKeyResolverSpito a KeyInfo object.voidSets theIdattributevoidsetSecureValidation(boolean secureValidation) Set whether secure processing is enabled or not.Methods inherited from class SignatureElementProxy
getBaseNamespaceMethods inherited from class ElementProxy
addBase64Element, addBase64Text, addBigIntegerElement, addReturnToSelf, addText, addTextElement, appendOther, appendSelf, appendSelf, createElementForFamily, createElementForFamilyLocal, createText, getBaseURI, getBigIntegerFromChildElement, getBytesFromTextChild, getDefaultPrefix, getDocument, getElement, getElementPlusReturns, getFirstChild, getLocalAttribute, getTextFromChildElement, getTextFromTextChild, length, registerDefaultPrefixes, setDefaultPrefix, setDocument, setElement, setElement, setLocalAttribute, setLocalIdAttribute, setXPathNamespaceContext
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
x509Datas
-
encryptedKeys
-
nullList
-
storageResolvers
Field storageResolvers -
internalKeyResolvers
Stores the individual (per-KeyInfo)KeyResolverSpis -
secureValidation
private boolean secureValidation
-
-
Constructor Details
-
KeyInfo
-
KeyInfo
Constructor KeyInfo- Parameters:
element-baseURI-- Throws:
XMLSecurityException
-
-
Method Details
-
setSecureValidation
public void setSecureValidation(boolean secureValidation) Set whether secure processing is enabled or not. The default is false. -
setId
-
getId
-
addKeyName
-
add
-
addKeyValue
-
addKeyValue
Method addKeyValue- Parameters:
unknownKeyValueElement-
-
add
-
add
-
add
-
add
-
addMgmtData
-
add
-
add
-
addRetrievalMethod
Method addRetrievalMethod- Parameters:
uri-transforms-Type-
-
add
-
add
-
add
-
add
Method addEncryptedKey- Parameters:
encryptedKey-- Throws:
XMLEncryptionException
-
addDEREncodedKeyValue
Method addDEREncodedKeyValue- Parameters:
pk-- Throws:
XMLSecurityException
-
add
-
addKeyInfoReference
Method addKeyInfoReference- Parameters:
URI-- Throws:
XMLSecurityException
-
add
-
addUnknownElement
-
lengthKeyName
public int lengthKeyName()Method lengthKeyName- Returns:
- the number of the KeyName tags
-
lengthKeyValue
public int lengthKeyValue()Method lengthKeyValue- Returns:
- the number of the KeyValue tags
-
lengthMgmtData
public int lengthMgmtData()Method lengthMgmtData- Returns:
- the number of the MgmtData tags
-
lengthPGPData
public int lengthPGPData()Method lengthPGPData- Returns:
- the number of the PGPDat. tags
-
lengthRetrievalMethod
public int lengthRetrievalMethod()Method lengthRetrievalMethod- Returns:
- the number of the RetrievalMethod tags
-
lengthSPKIData
public int lengthSPKIData()Method lengthSPKIData- Returns:
- the number of the SPKIData tags
-
lengthX509Data
public int lengthX509Data()Method lengthX509Data- Returns:
- the number of the X509Data tags
-
lengthDEREncodedKeyValue
public int lengthDEREncodedKeyValue()Method lengthDEREncodedKeyValue- Returns:
- the number of the DEREncodedKeyValue tags
-
lengthKeyInfoReference
public int lengthKeyInfoReference()Method lengthKeyInfoReference- Returns:
- the number of the KeyInfoReference tags
-
lengthUnknownElement
public int lengthUnknownElement()Method lengthUnknownElement NOTE possibly buggy.- Returns:
- the number of the UnknownElement tags
-
itemKeyName
Method itemKeyName- Parameters:
i-- Returns:
- the asked KeyName element, null if the index is too big
- Throws:
XMLSecurityException
-
itemKeyValue
Method itemKeyValue- Parameters:
i-- Returns:
- the asked KeyValue element, null if the index is too big
- Throws:
XMLSecurityException
-
itemMgmtData
Method itemMgmtData- Parameters:
i-- Returns:
- the asked MgmtData element, null if the index is too big
- Throws:
XMLSecurityException
-
itemPGPData
Method itemPGPData- Parameters:
i-- Returns:
- the asked PGPData element, null if the index is too big
- Throws:
XMLSecurityException
-
itemRetrievalMethod
Method itemRetrievalMethod- Parameters:
i-- Returns:
- the asked RetrievalMethod element, null if the index is too big
- Throws:
XMLSecurityException
-
itemSPKIData
Method itemSPKIData- Parameters:
i-- Returns:
- the asked SPKIData element, null if the index is too big
- Throws:
XMLSecurityException
-
itemX509Data
Method itemX509Data- Parameters:
i-- Returns:
- the asked X509Data element, null if the index is too big
- Throws:
XMLSecurityException
-
itemEncryptedKey
Method itemEncryptedKey- Parameters:
i-- Returns:
- the asked EncryptedKey element, null if the index is too big
- Throws:
XMLSecurityException
-
itemDEREncodedKeyValue
Method itemDEREncodedKeyValue- Parameters:
i-- Returns:
- the asked DEREncodedKeyValue element, null if the index is too big
- Throws:
XMLSecurityException
-
itemKeyInfoReference
Method itemKeyInfoReference- Parameters:
i-- Returns:
- the asked KeyInfoReference element, null if the index is too big
- Throws:
XMLSecurityException
-
itemUnknownElement
Method itemUnknownElement- Parameters:
i- index- Returns:
- the element number of the unknown elements
-
isEmpty
public boolean isEmpty()Method isEmpty- Returns:
- true if the element has no descendants.
-
containsKeyName
public boolean containsKeyName()Method containsKeyName- Returns:
- If the KeyInfo contains a KeyName node
-
containsKeyValue
public boolean containsKeyValue()Method containsKeyValue- Returns:
- If the KeyInfo contains a KeyValue node
-
containsMgmtData
public boolean containsMgmtData()Method containsMgmtData- Returns:
- If the KeyInfo contains a MgmtData node
-
containsPGPData
public boolean containsPGPData()Method containsPGPData- Returns:
- If the KeyInfo contains a PGPData node
-
containsRetrievalMethod
public boolean containsRetrievalMethod()Method containsRetrievalMethod- Returns:
- If the KeyInfo contains a RetrievalMethod node
-
containsSPKIData
public boolean containsSPKIData()Method containsSPKIData- Returns:
- If the KeyInfo contains a SPKIData node
-
containsUnknownElement
public boolean containsUnknownElement()Method containsUnknownElement- Returns:
- If the KeyInfo contains a UnknownElement node
-
containsX509Data
public boolean containsX509Data()Method containsX509Data- Returns:
- If the KeyInfo contains a X509Data node
-
containsDEREncodedKeyValue
public boolean containsDEREncodedKeyValue()Method containsDEREncodedKeyValue- Returns:
- If the KeyInfo contains a DEREncodedKeyValue node
-
containsKeyInfoReference
public boolean containsKeyInfoReference()Method containsKeyInfoReference- Returns:
- If the KeyInfo contains a KeyInfoReference node
-
getPublicKey
This method returns the public key.- Returns:
- If the KeyInfo contains a PublicKey node
- Throws:
KeyResolverException
-
getPublicKeyFromStaticResolvers
Searches the library wide KeyResolvers for public keys- Returns:
- The public key contained in this Node.
- Throws:
KeyResolverException
-
getPublicKeyFromInternalResolvers
Searches the per-KeyInfo KeyResolvers for public keys- Returns:
- The public key contained in this Node.
- Throws:
KeyResolverException
-
getX509Certificate
Method getX509Certificate- Returns:
- The certificate contained in this KeyInfo
- Throws:
KeyResolverException
-
getX509CertificateFromStaticResolvers
This method uses each System-wideKeyResolverto search the child elements. Each combination ofKeyResolverand child element is checked against allStorageResolvers.- Returns:
- The certificate contained in this KeyInfo
- Throws:
KeyResolverException
-
applyCurrentResolver
private X509Certificate applyCurrentResolver(String uri, KeyResolverSpi keyResolver) throws KeyResolverException - Throws:
KeyResolverException
-
getX509CertificateFromInternalResolvers
Method getX509CertificateFromInternalResolvers- Returns:
- The certificate contained in this KeyInfo
- Throws:
KeyResolverException
-
getSecretKey
This method returns a secret (symmetric) key. This is for XML Encryption.- Returns:
- the secret key contained in this KeyInfo
- Throws:
KeyResolverException
-
getSecretKeyFromStaticResolvers
Searches the library wide KeyResolvers for Secret keys- Returns:
- the secret key contained in this KeyInfo
- Throws:
KeyResolverException
-
getSecretKeyFromInternalResolvers
Searches the per-KeyInfo KeyResolvers for secret keys- Returns:
- the secret key contained in this KeyInfo
- Throws:
KeyResolverException
-
getPrivateKey
This method returns a private key. This is for Key Transport in XML Encryption.- Returns:
- the private key contained in this KeyInfo
- Throws:
KeyResolverException
-
getPrivateKeyFromStaticResolvers
Searches the library wide KeyResolvers for Private keys- Returns:
- the private key contained in this KeyInfo
- Throws:
KeyResolverException
-
getPrivateKeyFromInternalResolvers
Searches the per-KeyInfo KeyResolvers for private keys- Returns:
- the private key contained in this KeyInfo
- Throws:
KeyResolverException
-
registerInternalKeyResolver
This method is used to add a customKeyResolverSpito a KeyInfo object.- Parameters:
realKeyResolver-
-
lengthInternalKeyResolver
int lengthInternalKeyResolver()Method lengthInternalKeyResolver- Returns:
- the length of the key
-
itemInternalKeyResolver
Method itemInternalKeyResolver- Parameters:
i- the index- Returns:
- the KeyResolverSpi for the index.
-
addStorageResolver
Method addStorageResolver- Parameters:
storageResolver-
-
getBaseLocalName
Returns the localname of the Elements of the sub-class.- Specified by:
getBaseLocalNamein classElementProxy- Returns:
- the localname of the Elements of the sub-class.
-