Package play.libs

Class XML

java.lang.Object
play.libs.XML

public class XML extends Object
XML utils
  • Constructor Details

    • XML

      public XML()
  • Method Details

    • newDocumentBuilderFactory

      public static DocumentBuilderFactory newDocumentBuilderFactory()
    • newDocumentBuilder

      public static DocumentBuilder newDocumentBuilder()
    • serialize

      public static String serialize(Document document)
      Serialize to XML String
      Parameters:
      document - The DOM document
      Returns:
      The XML String
    • getDocument

      public static Document getDocument(File file)
      Parse an XML file to DOM
      Parameters:
      file - The XML file
      Returns:
      null if an error occurs during parsing.
    • getDocument

      public static Document getDocument(String xml)
      Parse an XML string content to DOM
      Parameters:
      xml - The XML string
      Returns:
      null if an error occurs during parsing.
    • getDocument

      public static Document getDocument(InputStream stream)
      Parse an XML coming from an input stream to DOM
      Parameters:
      stream - The XML stream
      Returns:
      null if an error occurs during parsing.
    • validSignature

      public static boolean validSignature(Document document, Key publicKey)
      Check the xmldsig signature of the XML document.
      Parameters:
      document - the document to test
      publicKey - the public key corresponding to the key pair the document was signed with
      Returns:
      true if a correct signature is present, false otherwise
    • sign

      public static Document sign(Document document, RSAPublicKey publicKey, RSAPrivateKey privateKey)
      Sign the XML document using xmldsig.
      Parameters:
      document - the document to sign; it will be modified by the method.
      publicKey - the public key from the key pair to sign the document.
      privateKey - the private key from the key pair to sign the document.
      Returns:
      the signed document for chaining.