Package com.verisign.epp.util
Class EPPXMLStream
- java.lang.Object
-
- com.verisign.epp.util.EPPXMLStream
-
public class EPPXMLStream extends java.lang.ObjectEPPXMLStreamis 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 toread(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 intDEFAULT_MAX_PACKET_SIZEDefault 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 EPPXMLStream()Default constructor forEPPXMLStream.EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool)ConstructEPPXMLStreamto use a parser pool and a default transformer pool.EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool, org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.transform.Transformer> aTransformerPool)ConstructEPPXMLStreamto use a parser pool and a transformer pool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.DocumentdecodePacket(byte[] aPacket)Decodes the passed in packetbyte[]into a DOMDocument.org.w3c.dom.Documentread(java.io.InputStream aStream)Reads an EPP packet from theaStreamparameter, parses/validates it, and returns the associated DOM Document.byte[]readPacket(java.io.InputStream aStream)Reads an EPP packet from the stream based on a search for the End Of Message (EOM) string (</epp>).voidwrite(org.w3c.dom.Document aDoc, java.io.OutputStream aOutput, EPPMessage aMessage)Writes a DOM Document to the output stream.voidwritePacket(byte[] aPacket, java.io.OutputStream aOutput)Writes a packet to the output stream with the inclusion of the EPP four byte header.voidwritePacket(byte[] aPacket, java.io.OutputStream aOutput, EPPMessage aMessage)Writes a packet to the output stream with the inclusion of the EPP four byte header.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
-
Constructor Detail
-
EPPXMLStream
public EPPXMLStream()
Default constructor forEPPXMLStream. When using this constructor, a parser instance will be created on each call toread(InputStream)and a transformer instance will be created on each call towrite(Document,OutputStream). .
-
EPPXMLStream
public EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool)
ConstructEPPXMLStreamto 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 toread(InputStream). TheEPPTransformerPoolis used by default for the transformer pool.- Parameters:
aParserPool- Parser pool to use
-
EPPXMLStream
public EPPXMLStream(org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.parsers.DocumentBuilder> aParserPool, org.apache.commons.pool2.BaseObjectPool<? extends javax.xml.transform.Transformer> aTransformerPool)ConstructEPPXMLStreamto 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 useaTransformerPool- Transformer pool to use
-
-
Method Detail
-
readPacket
public byte[] readPacket(java.io.InputStream aStream) throws EPPException, java.io.InterruptedIOException, java.io.IOExceptionReads 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.java.io.InterruptedIOException- Time out reading for packetjava.io.IOException- Exception from the input stream
-
read
public org.w3c.dom.Document read(java.io.InputStream aStream) throws EPPAssemblerException, EPPException, java.io.IOExceptionReads an EPP packet from theaStreamparameter, parses/validates it, and returns the associated DOM Document. The XML parser is either created per call, or is retrieved from a parser pool whenEPPXMLStream(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 packetjava.io.IOException- Error reading packet from stream
-
decodePacket
public org.w3c.dom.Document decodePacket(byte[] aPacket) throws EPPException, java.io.IOExceptionDecodes the passed in packetbyte[]into a DOMDocument.- Parameters:
aPacket- Input packet to decode to DOMDocument.- Returns:
- Decoded DOM
Document - Throws:
EPPException- Error decoding the packet.java.io.IOException- Basic IO error decoding the packet.
-
writePacket
public void writePacket(byte[] aPacket, java.io.OutputStream aOutput, EPPMessage aMessage) throws java.io.IOExceptionWrites a packet to the output stream with the inclusion of the EPP four byte header.- Parameters:
aPacket- Packet to write to the output streamaOutput- Output stream to write the packet toaMessage- Message object associated with the packet that can be used for filtering the information written to the packet log. Passingnullmay not filter or may cause performance issues in filtering the log information.- Throws:
java.io.IOException- Error writing the packet to the output stream
-
writePacket
public void writePacket(byte[] aPacket, java.io.OutputStream aOutput) throws java.io.IOExceptionWrites a packet to the output stream with the inclusion of the EPP four byte header.- Parameters:
aPacket- Packet to write to the output streamaOutput- Output stream to write the packet to- Throws:
java.io.IOException- Error writing the packet to the output stream
-
write
public void write(org.w3c.dom.Document aDoc, java.io.OutputStream aOutput, EPPMessage aMessage) throws EPPExceptionWrites 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 streamaOutput- Output stream to write toaMessage-EPPMessageassociated withaDocthat is used for packet logging logic. Set tonullif unavailable.- Throws:
EPPException- Error writing to stream. It is recommended that the stream be closed.
-
-