Class EPPXMLStream

java.lang.Object
com.verisign.epp.util.EPPXMLStream

public class EPPXMLStream extends Object
EPPXMLStream is a utility class for reading and writing EPP messages to/from streams. DOM Document are read and written to the streams. An XML parser is required when reading from the stream. There is one constructor that will create an XML parser per call to read(InputStream) and one that will use a parser pool. Use of a parser pool is recommended.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default Maximum packet size of bytes accepted to ensure that the client is not overrun with an invalid packet or a packet that exceeds the maximum size.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for EPPXMLStream.
    EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends DocumentBuilder> aParserPool)
    Construct EPPXMLStream to use a parser pool and a default transformer pool.
    EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends DocumentBuilder> aParserPool, org.apache.commons.pool2.BaseObjectPool<? extends Transformer> aTransformerPool)
    Construct EPPXMLStream to use a parser pool and a transformer pool.
  • Method Summary

    Modifier and Type
    Method
    Description
    decodePacket(byte[] aPacket)
    Decodes the passed in packet byte[] into a DOM Document.
    read(InputStream aStream)
    Reads an EPP packet from the aStream parameter, parses/validates it, and returns the associated DOM Document.
    byte[]
    Reads an EPP packet from the stream based on a search for the End Of Message (EOM) string (</epp>).
    void
    write(Document aDoc, OutputStream aOutput, EPPMessage aMessage)
    Writes a DOM Document to the output stream.
    void
    writePacket(byte[] aPacket, OutputStream aOutput)
    Writes a packet to the output stream with the inclusion of the EPP four byte header.
    void
    writePacket(byte[] aPacket, OutputStream aOutput, EPPMessage aMessage)
    Writes a packet to the output stream with the inclusion of the EPP four byte header.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MAX_PACKET_SIZE

      public static final int DEFAULT_MAX_PACKET_SIZE
      Default Maximum packet size of bytes accepted to ensure that the client is not overrun with an invalid packet or a packet that exceeds the maximum size. This setting could be made configurable in the future.
      See Also:
  • Constructor Details

    • EPPXMLStream

      public EPPXMLStream()
      Default constructor for EPPXMLStream. When using this constructor, a parser instance will be created on each call to read(InputStream) and a transformer instance will be created on each call to write(Document,OutputStream). .
    • EPPXMLStream

      public EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends DocumentBuilder> aParserPool)
      Construct EPPXMLStream to use a parser pool and a default transformer pool. When using this constructor, a parser instance will be checked out and checked in as needed on each call to read(InputStream). The EPPTransformerPool is used by default for the transformer pool.
      Parameters:
      aParserPool - Parser pool to use
    • EPPXMLStream

      public EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends DocumentBuilder> aParserPool, org.apache.commons.pool2.BaseObjectPool<? extends Transformer> aTransformerPool)
      Construct EPPXMLStream to use a parser pool and a transformer pool. When using this constructor, a parser instance will be checked out and checked in as needed on each call to one of the read methods and a transformer instance is checked out and checked in as needed on each call to one of the write methods.
      Parameters:
      aParserPool - Parser pool to use
      aTransformerPool - Transformer pool to use
  • Method Details

    • readPacket

      public byte[] readPacket(InputStream aStream) throws EPPException, InterruptedIOException, IOException
      Reads an EPP packet from the stream based on a search for the End Of Message (EOM) string (</epp>).
      Parameters:
      aStream - Stream to read packet from
      Returns:
      EPP packet String
      Throws:
      EPPException - Error reading packet from stream. The stream should be closed.
      InterruptedIOException - Time out reading for packet
      IOException - Exception from the input stream
    • read

      Reads an EPP packet from the aStream parameter, parses/validates it, and returns the associated DOM Document. The XML parser is either created per call, or is retrieved from a parser pool when EPPXMLStream(GenericPoolManager) is used. Use of a parser pool is recommended.
      Parameters:
      aStream - Input stream to read for an EPP packet.
      Returns:
      Parsed DOM Document of packet
      Throws:
      EPPException - Error with received packet or end of stream. It is recommended that the stream be closed.
      EPPAssemblerException - Error parsing packet
      IOException - Error reading packet from stream
    • decodePacket

      public Document decodePacket(byte[] aPacket) throws EPPException, IOException
      Decodes the passed in packet byte[] into a DOM Document.
      Parameters:
      aPacket - Input packet to decode to DOM Document.
      Returns:
      Decoded DOM Document
      Throws:
      EPPException - Error decoding the packet.
      IOException - Basic IO error decoding the packet.
    • writePacket

      public void writePacket(byte[] aPacket, OutputStream aOutput, EPPMessage aMessage) throws IOException
      Writes a packet to the output stream with the inclusion of the EPP four byte header.
      Parameters:
      aPacket - Packet to write to the output stream
      aOutput - Output stream to write the packet to
      aMessage - Message object associated with the packet that can be used for filtering the information written to the packet log. Passing null may not filter or may cause performance issues in filtering the log information.
      Throws:
      IOException - Error writing the packet to the output stream
    • writePacket

      public void writePacket(byte[] aPacket, OutputStream aOutput) throws IOException
      Writes a packet to the output stream with the inclusion of the EPP four byte header.
      Parameters:
      aPacket - Packet to write to the output stream
      aOutput - Output stream to write the packet to
      Throws:
      IOException - Error writing the packet to the output stream
    • write

      public void write(Document aDoc, OutputStream aOutput, EPPMessage aMessage) throws EPPException
      Writes a DOM Document to the output stream. The DOM Document will be serialized to XML and written to the output stream.
      Parameters:
      aDoc - DOM Document to write to stream
      aOutput - Output stream to write to
      aMessage - EPPMessage associated with aDoc that is used for packet logging logic. Set to null if unavailable.
      Throws:
      EPPException - Error writing to stream. It is recommended that the stream be closed.