Module org.apache.santuario.xmlsec
Class AgreementMethodImpl
- java.lang.Object
-
- org.apache.xml.security.utils.ElementProxy
-
- org.apache.xml.security.utils.EncryptionElementProxy
-
- org.apache.xml.security.encryption.keys.content.AgreementMethodImpl
-
- All Implemented Interfaces:
AgreementMethod,KeyInfoContent
public class AgreementMethodImpl extends EncryptionElementProxy implements KeyInfoContent, AgreementMethod
The implementation of the AgreementMethod interface. The element contains information about the key agreement algorithm for deriving the encryption key.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<org.w3c.dom.Element>agreementMethodInformationprivate java.lang.StringalgorithmURIprivate byte[]kaNonceprivate KeyDerivationMethodkeyDerivationMethodprotected static java.lang.System.LoggerLOGprivate OriginatorKeyInfooriginatorKeyInfoprivate RecipientKeyInforecipientKeyInfo-
Fields inherited from class org.apache.xml.security.utils.ElementProxy
baseURI
-
-
Constructor Summary
Constructors Constructor Description AgreementMethodImpl(org.w3c.dom.Document doc, java.lang.String algorithm)Constructor AgreementMethodImpl for generating AgreementMethod from scratch based on algorithm URI.AgreementMethodImpl(org.w3c.dom.Document doc, KeyAgreementParameters keyAgreementParameter)Constructor AgreementMethodImpl for generating AgreementMethod from scratch based onKeyAgreementParameters.AgreementMethodImpl(org.w3c.dom.Element element)Constructor AgreementMethodImpl based on XMLElement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAgreementMethodInformation(org.w3c.dom.Element info)Adds additionalAgreementMethodinformation.private KeyDerivationMethodcreateKeyDerivationMethod(KeyAgreementParameters keyAgreementParameter)Method creates aKeyDerivationMethodelement based on parameters:KeyAgreementParameters.java.util.Iterator<org.w3c.dom.Element>getAgreementMethodInformation()Returns additional information regarding theAgreementMethod.java.lang.StringgetAlgorithm()Returns the algorithm URI of thisCryptographicMethod.java.lang.StringgetBaseLocalName()Returns the localname of the Elements of the sub-class.private ConcatKDFParamsImplgetConcatKDFParams(KeyDerivationParameters parameter)Method creates aConcatKDFParamsImplbased onConcatKDFParams.private HKDFParamsImplgetHKDFParams(KeyDerivationParameters parameter)Method creates aHKDFParamsImplbased onHKDFParams.byte[]getKANonce()Returns abytearray.KeyDerivationMethodgetKeyDerivationMethod()Returns KeyDerivationMethod information used in theAgreementMethod.OriginatorKeyInfogetOriginatorKeyInfo()Returns information relating to the originator's shared secret.RecipientKeyInfogetRecipientKeyInfo()Returns information relating to the recipient's shared secret.voidremoveAgreementMethodInformation(org.w3c.dom.Element info)Removes additionalAgreementMethodinformation.voidsetKANonce(byte[] kanonce)Sets the KANonce.jjvoidsetKeyDerivationMethod(KeyDerivationMethod keyDerivationMethod)This method is used to set theKeyDerivationMethodwhen theAgreementMethodis being used to derive a key.voidsetOriginatorKeyInfo(OriginatorKeyInfo keyInfo)Sets the information relating to the originator's shared secret.voidsetOriginatorPublicKey(java.security.PublicKey publicKey)Sets the originator's PublicKey to generate the secretvoidsetRecipientKeyInfo(RecipientKeyInfo keyInfo)Sets the information relating to the recipient's shared secret.-
Methods inherited from class org.apache.xml.security.utils.EncryptionElementProxy
getBaseNamespace
-
Methods inherited from class org.apache.xml.security.utils.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 Detail
-
LOG
protected static final java.lang.System.Logger LOG
-
kaNonce
private byte[] kaNonce
-
agreementMethodInformation
private java.util.List<org.w3c.dom.Element> agreementMethodInformation
-
keyDerivationMethod
private KeyDerivationMethod keyDerivationMethod
-
originatorKeyInfo
private OriginatorKeyInfo originatorKeyInfo
-
recipientKeyInfo
private RecipientKeyInfo recipientKeyInfo
-
algorithmURI
private java.lang.String algorithmURI
-
-
Constructor Detail
-
AgreementMethodImpl
public AgreementMethodImpl(org.w3c.dom.Document doc, KeyAgreementParameters keyAgreementParameter) throws XMLEncryptionExceptionConstructor AgreementMethodImpl for generating AgreementMethod from scratch based onKeyAgreementParameters. The constructor generatesKeyDerivationMethodif given andOriginatorKeyInfobased on originator public key for ECDH-ES key agreement. It generates a placeholder element for RecipientKeyInfo. The recipient key info value must be set later.- Parameters:
doc- theDocumentin whichAgreementMethodwill be placedkeyAgreementParameter- theKeyAgreementParametersfrom whichAgreementMethodwill be generated- Throws:
XMLEncryptionException- if the Key derivation algorithm is not supported or invalid parameters are given.
-
AgreementMethodImpl
public AgreementMethodImpl(org.w3c.dom.Document doc, java.lang.String algorithm)Constructor AgreementMethodImpl for generating AgreementMethod from scratch based on algorithm URI. The constructor builds a placeholder element forKeyDerivationMethod,OriginatorKeyInfoandRecipientKeyInfo. The values for these elements must be set later.- Parameters:
algorithm- the algorithm URI for the key agreement algorithm
-
AgreementMethodImpl
public AgreementMethodImpl(org.w3c.dom.Element element) throws XMLSecurityExceptionConstructor AgreementMethodImpl based on XMLElement.- Parameters:
element- the XMLElementcontaining AgreementMethod information- Throws:
XMLSecurityException- if the AgreementMethod element has invalid XML structure
-
-
Method Detail
-
getKANonce
public byte[] getKANonce()
Returns abytearray.- Specified by:
getKANoncein interfaceAgreementMethod- Returns:
- a
bytearray.
-
setKANonce
public void setKANonce(byte[] kanonce)
Sets the KANonce.jj- Specified by:
setKANoncein interfaceAgreementMethod
-
getAgreementMethodInformation
public java.util.Iterator<org.w3c.dom.Element> getAgreementMethodInformation()
Returns additional information regarding theAgreementMethod.- Specified by:
getAgreementMethodInformationin interfaceAgreementMethod- Returns:
- additional information regarding the
AgreementMethod.
-
addAgreementMethodInformation
public void addAgreementMethodInformation(org.w3c.dom.Element info)
Adds additionalAgreementMethodinformation.- Specified by:
addAgreementMethodInformationin interfaceAgreementMethod- Parameters:
info- aElementthat represents additional information specified by
-
removeAgreementMethodInformation
public void removeAgreementMethodInformation(org.w3c.dom.Element info)
Removes additionalAgreementMethodinformation.- Specified by:
removeAgreementMethodInformationin interfaceAgreementMethod- Parameters:
info- aElementthat represents additional information specified by
-
getKeyDerivationMethod
public KeyDerivationMethod getKeyDerivationMethod() throws XMLSecurityException
Returns KeyDerivationMethod information used in theAgreementMethod.- Specified by:
getKeyDerivationMethodin interfaceAgreementMethod- Returns:
- The KeyDerivationMethod information regarding the
AgreementMethod. - Throws:
XMLSecurityException
-
setKeyDerivationMethod
public void setKeyDerivationMethod(KeyDerivationMethod keyDerivationMethod)
This method is used to set theKeyDerivationMethodwhen theAgreementMethodis being used to derive a key. TheKeyDerivationMethodis declared asbut is used in ECDH_ES - Specified by:
setKeyDerivationMethodin interfaceAgreementMethod
-
getOriginatorKeyInfo
public OriginatorKeyInfo getOriginatorKeyInfo() throws XMLSecurityException
Returns information relating to the originator's shared secret.- Specified by:
getOriginatorKeyInfoin interfaceAgreementMethod- Returns:
- information relating to the originator's shared secret.
- Throws:
XMLSecurityException
-
setOriginatorKeyInfo
public void setOriginatorKeyInfo(OriginatorKeyInfo keyInfo)
Sets the information relating to the originator's shared secret.- Specified by:
setOriginatorKeyInfoin interfaceAgreementMethod- Parameters:
keyInfo- information relating to the originator's shared secret.
-
setOriginatorPublicKey
public void setOriginatorPublicKey(java.security.PublicKey publicKey)
Sets the originator's PublicKey to generate the secret- Specified by:
setOriginatorPublicKeyin interfaceAgreementMethod- Parameters:
publicKey- originator's PublicKey
-
getRecipientKeyInfo
public RecipientKeyInfo getRecipientKeyInfo() throws XMLSecurityException
Returns information relating to the recipient's shared secret.- Specified by:
getRecipientKeyInfoin interfaceAgreementMethod- Returns:
- information relating to the recipient's shared secret.
- Throws:
XMLSecurityException
-
setRecipientKeyInfo
public void setRecipientKeyInfo(RecipientKeyInfo keyInfo)
Sets the information relating to the recipient's shared secret.- Specified by:
setRecipientKeyInfoin interfaceAgreementMethod- Parameters:
keyInfo- information relating to the recipient's shared secret.
-
getAlgorithm
public java.lang.String getAlgorithm()
Returns the algorithm URI of thisCryptographicMethod.- Specified by:
getAlgorithmin interfaceAgreementMethod- Returns:
- the algorithm URI of this
CryptographicMethod
-
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.
-
createKeyDerivationMethod
private KeyDerivationMethod createKeyDerivationMethod(KeyAgreementParameters keyAgreementParameter) throws XMLEncryptionException
Method creates aKeyDerivationMethodelement based on parameters:KeyAgreementParameters. The method supports parameter typesConcatKDFParamsandHKDFParams.- Parameters:
keyAgreementParameter- theKeyAgreementParametersfrom whichKeyDerivationMethodwill be generated.- Returns:
- the generated
KeyDerivationMethodelement based onKeyAgreementParameters - Throws:
XMLEncryptionException- if the Key derivation algorithm is not supported or invalid parameters are given.java.lang.IllegalArgumentException- if KeyAgreementParameters is missing or wrong class type for derivation algorithm
-
getConcatKDFParams
private ConcatKDFParamsImpl getConcatKDFParams(KeyDerivationParameters parameter)
Method creates aConcatKDFParamsImplbased onConcatKDFParams.- Parameters:
parameter- theKeyDerivationParametersfrom whichConcatKDFParamsImplwill be generated.- Returns:
- the
ConcatKDFParamsImpl - Throws:
java.lang.IllegalArgumentException- if parameter is not instance ofConcatKDFParams
-
getHKDFParams
private HKDFParamsImpl getHKDFParams(KeyDerivationParameters parameter)
Method creates aHKDFParamsImplbased onHKDFParams.- Parameters:
parameter- theKeyDerivationParameterscontaining HKDF parameters.- Returns:
- the
HKDFParamsImpl - Throws:
java.lang.IllegalArgumentException- if parameter is not instance ofHKDFParams
-
-