Package org.apache.xml.security.keys
Class KeyInfo
- java.lang.Object
-
- org.apache.xml.security.utils.ElementProxy
-
- org.apache.xml.security.utils.SignatureElementProxy
-
- org.apache.xml.security.keys.KeyInfo
-
public class KeyInfo extends SignatureElementProxy
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.
ThelengthXXX()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
TheaddXXX()methods are used for adding Objects of the appropriate type to theKeyInfo. This is used during signature generation.
TheitemXXX(int i)methods return the i'th object of the corresponding type.
ThecontainsXXX()methods return whether the KeyInfo contains the corresponding type.- Author:
- $Author$
- If the
-
-
Field Summary
-
Fields inherited from class org.apache.xml.security.utils.ElementProxy
_baseURI, _constructionElement, _doc, _state, MODE_CREATE, MODE_DECRYPT, MODE_ENCRYPT, MODE_PROCESS, MODE_SIGN, MODE_UNKNOWN, MODE_VERIFY
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.security.PublicKey pk)Method addvoidadd(EncryptedKey encryptedKey)Method addEncryptedKeyvoidadd(KeyName keyname)Method addvoidadd(KeyValue keyvalue)Method addvoidadd(DSAKeyValue dsakeyvalue)Method addvoidadd(RSAKeyValue rsakeyvalue)Method addvoidadd(MgmtData mgmtdata)Method addvoidadd(PGPData pgpdata)Method addPGPDatavoidadd(RetrievalMethod retrievalmethod)Method addvoidadd(SPKIData spkidata)Method addvoidadd(X509Data x509data)Method addX509DatavoidaddKeyName(java.lang.String keynameString)Method addKeyNamevoidaddKeyValue(java.security.PublicKey pk)Method addKeyValuevoidaddKeyValue(org.w3c.dom.Element unknownKeyValueElement)Method addKeyValuevoidaddMgmtData(java.lang.String mgmtdata)Method addMgmtDatavoidaddRetrievalMethod(java.lang.String URI, Transforms transforms, java.lang.String Type)Method addRetrievalMethodvoidaddStorageResolver(StorageResolver storageResolver)Method addStorageResolvervoidaddUnknownElement(org.w3c.dom.Element element)Method addUnknownElementbooleancontainsKeyName()Method containsKeyNamebooleancontainsKeyValue()Method containsKeyValuebooleancontainsMgmtData()Method containsMgmtDatabooleancontainsPGPData()Method containsPGPDatabooleancontainsRetrievalMethod()Method containsRetrievalMethodbooleancontainsSPKIData()Method containsSPKIDatabooleancontainsUnknownElement()Method containsUnknownElementbooleancontainsX509Data()Method containsX509Datajava.lang.StringgetBaseLocalName()Returns the localname of the Elements of the sub-class.java.lang.StringgetId()Returns theIdattributejava.security.PublicKeygetPublicKey()This method returns the public key.javax.crypto.SecretKeygetSecretKey()This method returns a secret (symmetric) key.java.security.cert.X509CertificategetX509Certificate()Method getX509Certificatestatic voidinit()init the keyinfo (Still needed?)booleanisEmpty()Method isEmptyEncryptedKeyitemEncryptedKey(int i)Method itemEncryptedKeyKeyNameitemKeyName(int i)Method itemKeyNameKeyValueitemKeyValue(int i)Method itemKeyValueMgmtDataitemMgmtData(int i)Method itemMgmtDataPGPDataitemPGPData(int i)Method itemPGPDataRetrievalMethoditemRetrievalMethod(int i)Method itemRetrievalMethodSPKIDataitemSPKIData(int i)Method itemSPKIDataorg.w3c.dom.ElementitemUnknownElement(int i)Method itemUnknownElementX509DataitemX509Data(int i)Method itemX509DataintlengthKeyName()Method lengthKeyNameintlengthKeyValue()Method lengthKeyValueintlengthMgmtData()Method lengthMgmtDataintlengthPGPData()Method lengthPGPDataintlengthRetrievalMethod()Method lengthRetrievalMethodintlengthSPKIData()Method lengthSPKIDataintlengthUnknownElement()Method lengthUnknownElement NOTE posibly buggy.intlengthX509Data()Method lengthX509DatavoidregisterInternalKeyResolver(KeyResolverSpi realKeyResolver)This method is used to add a customKeyResolverSpito a KeyInfo object.voidsetId(java.lang.String Id)Sets theIdattribute-
Methods inherited from class org.apache.xml.security.utils.SignatureElementProxy
getBaseNamespace
-
Methods inherited from class org.apache.xml.security.utils.ElementProxy
addBase64Element, addBase64Text, addBigIntegerElement, addText, addTextElement, createElementForFamily, getBaseURI, getBigIntegerFromChildElement, getBytesFromChildElement, getBytesFromTextChild, getDefaultPrefix, getDocument, getElement, getElementPlusReturns, getTextFromChildElement, getTextFromTextChild, guaranteeThatElementInCorrectSpace, length, setDefaultPrefix, setElement, setXPathNamespaceContext
-
-
-
-
Constructor Detail
-
KeyInfo
public KeyInfo(org.w3c.dom.Document doc)
Constructor KeyInfo- Parameters:
doc-
-
KeyInfo
public KeyInfo(org.w3c.dom.Element element, java.lang.String BaseURI) throws XMLSecurityExceptionConstructor KeyInfo- Parameters:
element-BaseURI-- Throws:
XMLSecurityException
-
-
Method Detail
-
setId
public void setId(java.lang.String Id)
Sets theIdattribute- Parameters:
Id- ID
-
getId
public java.lang.String getId()
Returns theIdattribute- Returns:
- the
Idattribute
-
addKeyName
public void addKeyName(java.lang.String keynameString)
Method addKeyName- Parameters:
keynameString-
-
add
public void add(KeyName keyname)
Method add- Parameters:
keyname-
-
addKeyValue
public void addKeyValue(java.security.PublicKey pk)
Method addKeyValue- Parameters:
pk-
-
addKeyValue
public void addKeyValue(org.w3c.dom.Element unknownKeyValueElement)
Method addKeyValue- Parameters:
unknownKeyValueElement-
-
add
public void add(DSAKeyValue dsakeyvalue)
Method add- Parameters:
dsakeyvalue-
-
add
public void add(RSAKeyValue rsakeyvalue)
Method add- Parameters:
rsakeyvalue-
-
add
public void add(java.security.PublicKey pk)
Method add- Parameters:
pk-
-
add
public void add(KeyValue keyvalue)
Method add- Parameters:
keyvalue-
-
addMgmtData
public void addMgmtData(java.lang.String mgmtdata)
Method addMgmtData- Parameters:
mgmtdata-
-
add
public void add(MgmtData mgmtdata)
Method add- Parameters:
mgmtdata-
-
add
public void add(PGPData pgpdata)
Method addPGPData- Parameters:
pgpdata-
-
addRetrievalMethod
public void addRetrievalMethod(java.lang.String URI, Transforms transforms, java.lang.String Type)Method addRetrievalMethod- Parameters:
URI-transforms-Type-
-
add
public void add(RetrievalMethod retrievalmethod)
Method add- Parameters:
retrievalmethod-
-
add
public void add(SPKIData spkidata)
Method add- Parameters:
spkidata-
-
add
public void add(X509Data x509data)
Method addX509Data- Parameters:
x509data-
-
add
public void add(EncryptedKey encryptedKey) throws XMLEncryptionException
Method addEncryptedKey- Parameters:
encryptedKey-- Throws:
XMLEncryptionException
-
addUnknownElement
public void addUnknownElement(org.w3c.dom.Element element)
Method addUnknownElement- Parameters:
element-
-
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
-
lengthUnknownElement
public int lengthUnknownElement()
Method lengthUnknownElement NOTE posibly buggy.- Returns:
- the number of the UnknownElement tags
-
itemKeyName
public KeyName itemKeyName(int i) throws XMLSecurityException
Method itemKeyName- Parameters:
i-- Returns:
- the asked KeyName element, null if the index is too big
- Throws:
XMLSecurityException
-
itemKeyValue
public KeyValue itemKeyValue(int i) throws XMLSecurityException
Method itemKeyValue- Parameters:
i-- Returns:
- the asked KeyValue element, null if the index is too big
- Throws:
XMLSecurityException
-
itemMgmtData
public MgmtData itemMgmtData(int i) throws XMLSecurityException
Method itemMgmtData- Parameters:
i-- Returns:
- the asked MgmtData element, null if the index is too big
- Throws:
XMLSecurityException
-
itemPGPData
public PGPData itemPGPData(int i) throws XMLSecurityException
Method itemPGPData- Parameters:
i-- Returns:
- the asked PGPData element, null if the index is too big
- Throws:
XMLSecurityException
-
itemRetrievalMethod
public RetrievalMethod itemRetrievalMethod(int i) throws XMLSecurityException
Method itemRetrievalMethod- Parameters:
i-- Returns:
- the asked RetrievalMethod element, null if the index is too big
- Throws:
XMLSecurityException
-
itemSPKIData
public SPKIData itemSPKIData(int i) throws XMLSecurityException
Method itemSPKIData- Parameters:
i-- Returns:
- the asked SPKIData element, null if the index is too big
- Throws:
XMLSecurityException
-
itemX509Data
public X509Data itemX509Data(int i) throws XMLSecurityException
Method itemX509Data- Parameters:
i-- Returns:
- the asked X509Data element, null if the index is too big
- Throws:
XMLSecurityException
-
itemEncryptedKey
public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException
Method itemEncryptedKey- Parameters:
i-- Returns:
- the asked EncryptedKey element, null if the index is too big
- Throws:
XMLSecurityException
-
itemUnknownElement
public org.w3c.dom.Element itemUnknownElement(int i)
Method itemUnknownElement- Parameters:
i- index- Returns:
- the element number of the unknown elemens
-
isEmpty
public boolean isEmpty()
Method isEmpty- Returns:
- true if the element has no descedants.
-
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
-
getPublicKey
public java.security.PublicKey getPublicKey() throws KeyResolverExceptionThis method returns the public key.- Returns:
- If the KeyInfo contains a PublicKey node
- Throws:
KeyResolverException
-
getX509Certificate
public java.security.cert.X509Certificate getX509Certificate() throws KeyResolverExceptionMethod getX509Certificate- Returns:
- The certificate contined in this KeyInfo
- Throws:
KeyResolverException
-
getSecretKey
public javax.crypto.SecretKey getSecretKey() throws KeyResolverExceptionThis method returns a secret (symmetric) key. This is for XML Encryption.- Returns:
- the secret key contained in this KeyInfo
- Throws:
KeyResolverException
-
registerInternalKeyResolver
public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver)
This method is used to add a customKeyResolverSpito a KeyInfo object.- Parameters:
realKeyResolver-
-
addStorageResolver
public void addStorageResolver(StorageResolver storageResolver)
Method addStorageResolver- Parameters:
storageResolver-
-
init
public static void init()
init the keyinfo (Still needed?)
-
getBaseLocalName
public java.lang.String getBaseLocalName()
Description copied from class:ElementProxyReturns the localname of the Elements of the sub-class.- Specified by:
getBaseLocalNamein classElementProxy- Returns:
- the localname of the Elements of the sub-class.
-
-