Class KeyInfoHeaderBlock

All Implemented Interfaces:
SecurityHeaderBlock, jakarta.xml.soap.Node, jakarta.xml.soap.SOAPElement, Element, Node

public class KeyInfoHeaderBlock extends SecurityHeaderBlockImpl
Corresponds to the schema representation for a KeyInfo.

 <element name="KeyInfo" type="ds:KeyInfoType"/>
   <complexType name="KeyInfoType" mixed="true">
     <choice maxOccurs="unbounded">
       <element ref="ds:KeyName"/>
       <element ref="ds:KeyValue"/>
       <element ref="ds:RetrievalMethod"/>
       <element ref="ds:X509Data"/>
       <element ref="ds:PGPData"/>
       <element ref="ds:SPKIData"/>
       <element ref="ds:MgmtData"/>
       <element ref="wsse:SecurityTokenReference"/>
       <any processContents="lax" namespace="##other"/>
       <!-- (1,1) elements from (0,unbounded) namespaces -->
     </choice>
     <attribute name="Id" type="ID" use="optional"/>
   </complexType>
 
  • Field Details

  • Constructor Details

    • KeyInfoHeaderBlock

      public KeyInfoHeaderBlock(Document ownerDoc) throws XWSSecurityException
      constructor that creates an empty KeyInfo
      Parameters:
      ownerDoc - the OwnerDocument of the KeyInfo
      Throws:
      XWSSecurityException
    • KeyInfoHeaderBlock

      public KeyInfoHeaderBlock(org.apache.xml.security.keys.KeyInfo keyinfo) throws XWSSecurityException
      constructor that takes Apache KeyInfo
      Parameters:
      keyinfo - the KeyInfo from XML DSIG
      Throws:
      XWSSecurityException
    • KeyInfoHeaderBlock

      public KeyInfoHeaderBlock(jakarta.xml.soap.SOAPElement element) throws XWSSecurityException
      parse and create the KeyInfo element
      Parameters:
      element - the KeyInfo element NOTE : this constructor assumes a fully initialized XML KeyInfo No additions are allowed on the keyinfo, only we can get existing values. For example addkeyName() will have no impact on the KeyInfo will not append a KeyName child to the KeyInfo.
      Throws:
      XWSSecurityException
  • Method Details

    • addKeyName

      public void addKeyName(String keynameString)
      Method addKeyName.
    • addBinarySecret

      public void addBinarySecret(jakarta.xml.soap.SOAPElement binarySecret)
      Method addBinarySecret
    • addKeyName

      public void addKeyName(jakarta.xml.soap.SOAPElement keyname) throws XWSSecurityException
      Method add.
      Throws:
      XWSSecurityException
    • addKeyValue

      public void addKeyValue(PublicKey pk)
      Method addKeyValue
    • addUnknownKeyValue

      public void addUnknownKeyValue(jakarta.xml.soap.SOAPElement unknownKeyValueElement)
      Method addKeyValue
    • addDSAKeyValue

      public void addDSAKeyValue(jakarta.xml.soap.SOAPElement dsakeyvalue) throws XWSSecurityException
      Method add
      Throws:
      XWSSecurityException
    • addRSAKeyValue

      public void addRSAKeyValue(jakarta.xml.soap.SOAPElement rsakeyvalue) throws XWSSecurityException
      Method add
      Throws:
      XWSSecurityException
    • addKeyValue

      public void addKeyValue(jakarta.xml.soap.SOAPElement keyvalue) throws XWSSecurityException
      Method addKeyValue
      Throws:
      XWSSecurityException
    • addMgmtData

      public void addMgmtData(String mgmtdata)
      Method addMgmtData
    • addMgmtData

      public void addMgmtData(jakarta.xml.soap.SOAPElement mgmtdata) throws XWSSecurityException
      Method add
      Throws:
      XWSSecurityException
    • addPGPData

      public void addPGPData(jakarta.xml.soap.SOAPElement pgpdata) throws XWSSecurityException
      Method addPGPData
      Throws:
      XWSSecurityException
    • addRetrievalMethod

      public void addRetrievalMethod(String URI, org.apache.xml.security.transforms.Transforms transforms, String type)
      Method addRetrievalMethod
    • addRetrievalMethod

      public void addRetrievalMethod(jakarta.xml.soap.SOAPElement retrievalmethod) throws XWSSecurityException
      Method addRetrievalMethod
      Throws:
      XWSSecurityException
    • addSPKIData

      public void addSPKIData(jakarta.xml.soap.SOAPElement spkidata) throws XWSSecurityException
      Method add
      Throws:
      XWSSecurityException
    • addX509Data

      public void addX509Data(jakarta.xml.soap.SOAPElement x509data) throws XWSSecurityException
      Method addX509Data
      Throws:
      XWSSecurityException
    • addUnknownElement

      public void addUnknownElement(jakarta.xml.soap.SOAPElement element)
      Method addUnknownElement
    • keyNameCount

      public int keyNameCount()
      Method keyNameCount
    • keyValueCount

      public int keyValueCount()
      Method keyValueCount
    • mgmtDataCount

      public int mgmtDataCount()
      Method mgmtDataCount
    • pgpDataCount

      public int pgpDataCount()
      Method pgpDataCount
    • retrievalMethodCount

      public int retrievalMethodCount()
      Method retrievalMethodCount
    • spkiDataCount

      public int spkiDataCount()
      Method spkiDataCount
    • x509DataCount

      public int x509DataCount()
      Method x509DataCount
    • unknownElementCount

      public int unknownElementCount()
      Method unknownElementCount
    • getKeyName

      public jakarta.xml.soap.SOAPElement getKeyName(int index) throws XWSSecurityException
      Method getKeyName
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getKeyNameString

      public String getKeyNameString(int index) throws XWSSecurityException
      Method getKeyNameString
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getKeyValueElement

      public jakarta.xml.soap.SOAPElement getKeyValueElement(int index) throws XWSSecurityException
      Method getKeyValueElement
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getKeyValue

      public org.apache.xml.security.keys.content.KeyValue getKeyValue(int index) throws XWSSecurityException
      Method getKeyValue
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getMgmtData

      public jakarta.xml.soap.SOAPElement getMgmtData(int index) throws XWSSecurityException
      Method getMgmtData
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getPGPData

      public jakarta.xml.soap.SOAPElement getPGPData(int index) throws XWSSecurityException
      Method getPGPData
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getRetrievalMethod

      public jakarta.xml.soap.SOAPElement getRetrievalMethod(int index) throws XWSSecurityException
      Method getRetrievalMethod
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getSPKIData

      public jakarta.xml.soap.SOAPElement getSPKIData(int index) throws XWSSecurityException
      Method getSPKIData
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getX509DataElement

      public jakarta.xml.soap.SOAPElement getX509DataElement(int index) throws XWSSecurityException
      Method getX509DataElement
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getX509Data

      public org.apache.xml.security.keys.content.X509Data getX509Data(int index) throws XWSSecurityException
      Method getX509Data
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • getUnknownElement

      public jakarta.xml.soap.SOAPElement getUnknownElement(int index) throws XWSSecurityException
      Method getUnknownElement
      Parameters:
      index - 0 is the lowest index
      Throws:
      XWSSecurityException
    • containsKeyName

      public boolean containsKeyName()
      Method containsKeyName
    • containsKeyValue

      public boolean containsKeyValue()
      Method containsKeyValue
    • containsMgmtData

      public boolean containsMgmtData()
      Method containsMgmtData
    • containsPGPData

      public boolean containsPGPData()
      Method containsPGPData
    • containsRetrievalMethod

      public boolean containsRetrievalMethod()
      Method containsRetrievalMethod
    • containsSPKIData

      public boolean containsSPKIData()
      Method containsSPKIData
    • containsUnknownElement

      public boolean containsUnknownElement()
      Method containsUnknownElement
    • containsX509Data

      public boolean containsX509Data()
      Method containsX509Data
    • addSecurityTokenReference

      public void addSecurityTokenReference(SecurityTokenReference reference) throws XWSSecurityException
      Method addSecurityTokenReference
      Throws:
      XWSSecurityException
    • getSecurityTokenReference

      public SecurityTokenReference getSecurityTokenReference(int index) throws XWSSecurityException
      Method getSecurityTokenReference
      Returns:
      the index^th token reference element from the KeyInfo 0 is the lowest index.
      Throws:
      XWSSecurityException
    • securityTokenReferenceCount

      public int securityTokenReferenceCount()
      Method securityTokenReferenceCount
      Returns:
      the count of security token references
    • containsSecurityTokenReference

      public boolean containsSecurityTokenReference()
      Method containsSecurityTokenReference
      Returns:
      true if this KeyInfo contains wsse:SecurityTokenReference's
    • addEncryptedKey

      public void addEncryptedKey(EncryptedKeyToken reference)
      Method addEncryptedKey
    • getEncryptedKey

      public EncryptedKeyToken getEncryptedKey(int index)
      Method getEncryptedKey
      Returns:
      the index^th token reference element from the KeyInfo 0 is the lowest index.
    • encryptedKeyTokenCount

      public int encryptedKeyTokenCount()
      Method encryptedKeyTokenCount
      Returns:
      the count of encrypted key token references
    • containsEncryptedKeyToken

      public boolean containsEncryptedKeyToken()
      Method containsEncryptedKeyToken
      Returns:
      true if this KeyInfo contains wsse:SecurityTokenReference's
    • getBinarySecret

      public BinarySecret getBinarySecret(int index) throws XWSSecurityException
      Throws:
      XWSSecurityException
    • binarySecretCount

      public int binarySecretCount()
      Method binarySecretCount
      Returns:
      the count of binarySecret tokens
    • containsBinarySecret

      public boolean containsBinarySecret()
      Method containsBinarySecret
      Returns:
      true if this KeyInfo contains BinarySecret
    • setId

      public void setId(String id)
      Method setId
    • getId

      public String getId()
      Method getId
      Specified by:
      getId in interface SecurityHeaderBlock
      Overrides:
      getId in class SecurityHeaderBlockImpl
      Returns:
      the id
    • getKeyInfo

      public final org.apache.xml.security.keys.KeyInfo getKeyInfo()
      Method getKeyInfo
      Returns:
      the XML DSIG KeyInfo which is wrapped by this class
    • setBaseURI

      public void setBaseURI(String uri)
      Method setBaseURI : BaseURI accepted by Apache KeyInfo Ctor
      Parameters:
      uri - Base URI to be used as context for all relative URIs.
    • getAsSoapElement

      public jakarta.xml.soap.SOAPElement getAsSoapElement() throws XWSSecurityException
      Method to return the KeyInfo as a SOAPElement.
      Specified by:
      getAsSoapElement in interface SecurityHeaderBlock
      Overrides:
      getAsSoapElement in class SecurityHeaderBlockImpl
      Returns:
      SOAPElement
      Throws:
      XWSSecurityException - If owner soap document is not set.
      See Also:
    • setDocument

      public void setDocument(Document doc)
      setDocument
      Parameters:
      doc - The owner Document of this KeyInfo
    • saveChanges

      public void saveChanges()
      This method should be called when changes are made inside an object through its reference obtained from any of the get methods of this class. As an example, if getKeyInfo() call is made and then changes are made inside the keyInfo, this method should be called to reflect changes when getAsSoapElement() is called finally.
    • fromSoapElement

      public static SecurityHeaderBlock fromSoapElement(jakarta.xml.soap.SOAPElement element) throws XWSSecurityException
      Throws:
      XWSSecurityException
    • addX509Data

      public void addX509Data(org.apache.xml.security.keys.content.X509Data x509Data) throws XWSSecurityException
      Throws:
      XWSSecurityException