com.jp.protection.pub.pro.network
Class NetworkCheckPacket

java.lang.Object
  extended by com.jp.protection.pub.pro.network.NetworkCheckPacket
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class NetworkCheckPacket
extends java.lang.Object
implements java.io.Externalizable

Defines network check packet that holds all the data required to identify host and license

See Also:
Serialized Form

Field Summary
protected  java.lang.String fHostID
           
protected  long fHostTimestamp
           
protected  java.lang.String fLicenseNumber
           
protected  java.lang.String fProductID
           
protected  java.lang.String fSignature
           
protected  byte fType
           
static byte TYPE_REQUEST
          Defines request type of the packet
static byte TYPE_RESPONSE
          Defines response type of the packet
 
Constructor Summary
NetworkCheckPacket()
           
 
Method Summary
static NetworkCheckPacket createRequest(java.lang.String aProductID, java.lang.String aLicenseNumber, java.lang.String aSignature, java.lang.String aHostID, long aHostTimestamp)
          Creates request
static NetworkCheckPacket createResponse(java.lang.String aProductID, java.lang.String aLicenseNumber, java.lang.String aSignature, java.lang.String aHostID, long aHostTimestamp)
          Creates response packet
 void fromByteArray(byte[] aBytes, int offset, int length)
          Reads packet from array of bytes
 java.lang.String getHostID()
          Returns host identifier
 long getHostTimestamp()
          Returns host timestamp
 java.lang.String getLicenseNumber()
          Return license number
 java.lang.String getProductID()
          Return product identifier
 java.lang.String getSignature()
          Returns signature
 byte getType()
          Return packet type
 void readExternal(java.io.ObjectInput in)
           
protected static java.lang.String readString(java.io.ObjectInput in)
           
 byte[] toByteArray()
          Writes packet to array of bytes
 void writeExternal(java.io.ObjectOutput out)
           
protected static void writeString(java.io.ObjectOutput out, java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fProductID

protected java.lang.String fProductID

fLicenseNumber

protected java.lang.String fLicenseNumber

fHostID

protected java.lang.String fHostID

fHostTimestamp

protected long fHostTimestamp

fType

protected byte fType

TYPE_REQUEST

public static final byte TYPE_REQUEST
Defines request type of the packet

See Also:
Constant Field Values

TYPE_RESPONSE

public static final byte TYPE_RESPONSE
Defines response type of the packet

See Also:
Constant Field Values

fSignature

protected java.lang.String fSignature
Constructor Detail

NetworkCheckPacket

public NetworkCheckPacket()
Method Detail

getHostID

public java.lang.String getHostID()
Returns host identifier

Returns:
host identifier

getHostTimestamp

public long getHostTimestamp()
Returns host timestamp

Returns:
host timestamp

getSignature

public java.lang.String getSignature()
Returns signature

Returns:
signature

getType

public byte getType()
Return packet type

Returns:
packet type as one of TYPE_ constants

getLicenseNumber

public java.lang.String getLicenseNumber()
Return license number

Returns:
license number

getProductID

public java.lang.String getProductID()
Return product identifier

Returns:
product identifier

createRequest

public static NetworkCheckPacket createRequest(java.lang.String aProductID,
                                               java.lang.String aLicenseNumber,
                                               java.lang.String aSignature,
                                               java.lang.String aHostID,
                                               long aHostTimestamp)
Creates request

Parameters:
aProductID - product identifier
aLicenseNumber - license number
aSignature - signature
aHostID - host identifier
aHostTimestamp - host timestamp
Returns:
request packet

createResponse

public static NetworkCheckPacket createResponse(java.lang.String aProductID,
                                                java.lang.String aLicenseNumber,
                                                java.lang.String aSignature,
                                                java.lang.String aHostID,
                                                long aHostTimestamp)
Creates response packet

Parameters:
aProductID - product identifier
aLicenseNumber - license number
aSignature - signature
aHostID - host identifier
aHostTimestamp - host timestamp
Returns:
request packet

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

writeString

protected static void writeString(java.io.ObjectOutput out,
                                  java.lang.String str)
                           throws java.io.IOException
Throws:
java.io.IOException

readString

protected static java.lang.String readString(java.io.ObjectInput in)
                                      throws java.io.IOException
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

toByteArray

public byte[] toByteArray()
                   throws java.io.IOException
Writes packet to array of bytes

Returns:
array of bytes containing externalized form of the packet
Throws:
java.io.IOException - for errors occured during writing

fromByteArray

public void fromByteArray(byte[] aBytes,
                          int offset,
                          int length)
                   throws java.lang.ClassNotFoundException,
                          java.io.IOException
Reads packet from array of bytes

Parameters:
aBytes - array of bytes to read packet from
offset - offset in the array to start reading from
length - length to read
Throws:
java.lang.ClassNotFoundException - if NetworkCheckPacket class is not found
java.io.IOException - form errors occured during reading