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

java.lang.Object
  extended by com.jp.protection.pub.pro.network.NetworkCheck

public class NetworkCheck
extends java.lang.Object

This class provides tracking of the licenses usage over the network using broadcast communication.


Field Summary
protected  int fCheckHostPolicy
           
protected  int fDefaultCheckHostPolicy
           
protected  java.net.InetAddress fGroup
           
protected  java.lang.String fHostID
           
protected  long fHostTimestamp
           
protected  java.lang.String fLicenseNumber
           
protected  java.net.MulticastSocket fMulticastSocket
           
protected  int fNumberCopies
           
protected  java.lang.String fProductID
           
protected  java.util.HashSet fResponceAddresses
           
protected  int fResponseCount
           
protected  java.lang.Thread fRunnerTread
           
protected  boolean fRunning
           
protected  java.lang.String fSignature
           
protected  int fSocketBufferSize
           
protected  java.lang.String fSocketGroupName
           
protected  int fSocketPortNumber
           
protected  int fSocketTimeout
           
protected  int fSocketTimeToLive
           
protected  boolean fVerbose
           
static int POLICY_ANY_HOST
          Defines that only responses came from any hosts should be counted
static int POLICY_DIFFERENT_HOST
          Defines that only responses came from the different hosts should be counted
static int POLICY_SAME_HOST
          Defines that only responses came from the same hosts should be counted
static java.lang.String SIGNATURE
           
static int SOCKET_BUFFER_SIZE
           
static java.lang.String SOCKET_GROUP_NAME
           
static int SOCKET_PORT_NUMBER
           
static int SOCKET_TIME_TO_LIVE
           
static int SOCKET_TIMEOUT
           
 
Constructor Summary
NetworkCheck()
          Creates a new instance of the NetworkCheck
 
Method Summary
 void addNetworkCheckListener(NetworkCheckListener l)
          Removes listener from the listeners list
 void check()
          Starts network check (if not started), clears all collected responces and sends request over the network.
protected  boolean checkHost(NetworkCheckPacket packet)
           
protected  boolean checkResponse(NetworkCheckPacket packet)
           
protected  void createMulticastSocket()
           
protected  void fireNumberCopiesViolation(NetworkCheck param1, int param2)
           
 int getCheckHostPolicy()
          Returns check host policy value
 int getDefaultCheckHostPolicy()
          Returns default check host policy value.
protected  java.net.InetAddress getGroup()
           
 java.lang.String getLicenseNumber()
          Returns license number to track
 int getNumberCopies()
          Returns license number of copies
 java.lang.String getProductID()
          Returns product identifier to track
 int getResponseCount()
          Returns number of collected responses
 java.lang.String getSignature()
          Returns signature value
 int getSocketBufferSize()
          Returns socket buffer size value.
 java.lang.String getSocketGroupName()
          Returns socket group name to join.
 int getSocketPortNumber()
          Returns socket port number.
 int getSocketTimeout()
          Returns socket timeout value
 int getSocketTimeToLive()
          Return socket time to live value.
protected  boolean isRunning()
           
 boolean isVerbose()
          Checks whether Network Check runs in verbose mode.
protected  void processDatagramPacket(java.net.DatagramPacket aDatagramPacket)
           
protected  void releaseMulticastSocket()
           
 void removeNetworkCheckListener(NetworkCheckListener l)
          Adds a new listener to the listeners list
protected  void send(NetworkCheckPacket aPacket)
           
protected  void sendRequest(java.lang.String aProductID, java.lang.String aLicenseNumber)
           
protected  void sendResponse(java.lang.String aProductID, java.lang.String aLicenseNumber)
           
 void setCheckHostPolicy(int aCheckHostPolicy)
          Specifies check host policy value as one of POLICY_ constants
 void setDefaultCheckHostPolicy(int aDefaultCheckHostPolicy)
          Specifies default check host policy value as one of POLICY_ constants.
 void setLicenseNumber(java.lang.String aLicenseNumber)
          Specifies license number to track
 void setNumberCopies(int aNumberCopies)
          Specifies license number of copies
 void setProductID(java.lang.String aProductID)
          Specifies product identifier to track
 void setSignature(java.lang.String aSignature)
          Specifies signature value to unique identify particular vendor.
 void setSocketBufferSize(int aSocketBufferSize)
          Specifies socket buffer size value.
 void setSocketGroupName(java.lang.String aSocketGroupName)
          Specifies socket group name to join.
 void setSocketPortNumber(int aSocketPortNumber)
          Specifies socket port number.
 void setSocketTimeout(int aSocketTimeout)
          Specifies socket timeout value.
 void setSocketTimeToLive(int aSocketTimeToLive)
          Specifies socket time to live.
 void setVerbose(boolean aVerbose)
          Specifies that Network Check should be run in verbose mode.
 void start()
          Starts listening responses from the network
 void stop()
          Stops listening responses from the network
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOCKET_PORT_NUMBER

public static final int SOCKET_PORT_NUMBER
See Also:
Constant Field Values

SOCKET_TIME_TO_LIVE

public static final int SOCKET_TIME_TO_LIVE
See Also:
Constant Field Values

SOCKET_GROUP_NAME

public static final java.lang.String SOCKET_GROUP_NAME
See Also:
Constant Field Values

SOCKET_BUFFER_SIZE

public static final int SOCKET_BUFFER_SIZE
See Also:
Constant Field Values

SOCKET_TIMEOUT

public static final int SOCKET_TIMEOUT
See Also:
Constant Field Values

SIGNATURE

public static java.lang.String SIGNATURE

fSocketPortNumber

protected int fSocketPortNumber

fSocketTimeToLive

protected int fSocketTimeToLive

fSocketGroupName

protected java.lang.String fSocketGroupName

fSocketBufferSize

protected int fSocketBufferSize

fSocketTimeout

protected int fSocketTimeout

fHostID

protected java.lang.String fHostID

fHostTimestamp

protected long fHostTimestamp

fSignature

protected java.lang.String fSignature

fMulticastSocket

protected java.net.MulticastSocket fMulticastSocket

fRunnerTread

protected java.lang.Thread fRunnerTread

fRunning

protected boolean fRunning

fResponceAddresses

protected java.util.HashSet fResponceAddresses

fProductID

protected java.lang.String fProductID

fLicenseNumber

protected java.lang.String fLicenseNumber

fNumberCopies

protected int fNumberCopies

fGroup

protected java.net.InetAddress fGroup

fVerbose

protected boolean fVerbose

POLICY_SAME_HOST

public static final int POLICY_SAME_HOST
Defines that only responses came from the same hosts should be counted

See Also:
Constant Field Values

POLICY_DIFFERENT_HOST

public static final int POLICY_DIFFERENT_HOST
Defines that only responses came from the different hosts should be counted

See Also:
Constant Field Values

POLICY_ANY_HOST

public static final int POLICY_ANY_HOST
Defines that only responses came from any hosts should be counted

See Also:
Constant Field Values

fDefaultCheckHostPolicy

protected int fDefaultCheckHostPolicy

fCheckHostPolicy

protected int fCheckHostPolicy

fResponseCount

protected int fResponseCount
Constructor Detail

NetworkCheck

public NetworkCheck()
Creates a new instance of the NetworkCheck

Method Detail

getSocketTimeout

public int getSocketTimeout()
Returns socket timeout value

Returns:
socket timeout value (SOCKET_TIMEOUT by default)

setSocketTimeout

public void setSocketTimeout(int aSocketTimeout)
Specifies socket timeout value. The new value will be applied only after the restart of Network Check.

Parameters:
aSocketTimeout - socket timeout value to set.

getSocketBufferSize

public int getSocketBufferSize()
Returns socket buffer size value.

Returns:
socket buffer size value (SOCKET_BUFFER_SIZE by default).

setSocketBufferSize

public void setSocketBufferSize(int aSocketBufferSize)
Specifies socket buffer size value. The new value will be applied only after the restart of Network Check.

Parameters:
aSocketBufferSize - socket buffer size to set.

getSocketGroupName

public java.lang.String getSocketGroupName()
Returns socket group name to join.

Returns:
socket group name to join (SOCKET_GROUP_NAME by default).

setSocketGroupName

public void setSocketGroupName(java.lang.String aSocketGroupName)
Specifies socket group name to join. The new value will be applied only after the restart of Network Check.

Parameters:
aSocketGroupName - socket group name to set

getSocketTimeToLive

public int getSocketTimeToLive()
Return socket time to live value.

Returns:
socket time to live value (SOCKET_TIME_TO_LIVE by default).

setSocketTimeToLive

public void setSocketTimeToLive(int aSocketTimeToLive)
Specifies socket time to live. The new value will be applied only after the restart of Network Check.

Parameters:
aSocketTimeToLive - socket time to live set.

getSocketPortNumber

public int getSocketPortNumber()
Returns socket port number.

Returns:
socket port number (SOCKET_PORT_NUMBER by default).

setSocketPortNumber

public void setSocketPortNumber(int aSocketPortNumber)
Specifies socket port number. The new value will be applied only after the restart of Network Check.

Parameters:
aSocketPortNumber - socket port number to set.

start

public void start()
Starts listening responses from the network


stop

public void stop()
Stops listening responses from the network


isRunning

protected boolean isRunning()

getProductID

public java.lang.String getProductID()
Returns product identifier to track

Returns:
product identifier to track

setProductID

public void setProductID(java.lang.String aProductID)
Specifies product identifier to track

Parameters:
aProductID - product identifier to set

getLicenseNumber

public java.lang.String getLicenseNumber()
Returns license number to track

Returns:
license number to track

setLicenseNumber

public void setLicenseNumber(java.lang.String aLicenseNumber)
Specifies license number to track

Parameters:
aLicenseNumber - license number to set.

getNumberCopies

public int getNumberCopies()
Returns license number of copies

Returns:
license number of copies

setNumberCopies

public void setNumberCopies(int aNumberCopies)
Specifies license number of copies

Parameters:
aNumberCopies - license number of copies to set

check

public void check()
Starts network check (if not started), clears all collected responces and sends request over the network.


send

protected void send(NetworkCheckPacket aPacket)

createMulticastSocket

protected void createMulticastSocket()

getGroup

protected java.net.InetAddress getGroup()
                                 throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

releaseMulticastSocket

protected void releaseMulticastSocket()

isVerbose

public boolean isVerbose()
Checks whether Network Check runs in verbose mode.

Returns:
true if Network Check runs in verbose mode, false otherwise.

setVerbose

public void setVerbose(boolean aVerbose)
Specifies that Network Check should be run in verbose mode. If Network Check run in verbose mode all exceptions stack traces and error messages, if any, will be printed to stderr. Otherwise there is no output in order to prevent the code flow analysis.

Parameters:
aVerbose - true if Network Check should run in verbose mode, false otherwise.

processDatagramPacket

protected void processDatagramPacket(java.net.DatagramPacket aDatagramPacket)

getCheckHostPolicy

public int getCheckHostPolicy()
Returns check host policy value

Returns:
check host policy value as one of POLICY_ constants

setCheckHostPolicy

public void setCheckHostPolicy(int aCheckHostPolicy)
Specifies check host policy value as one of POLICY_ constants

Parameters:
aCheckHostPolicy - check host policy to set

getDefaultCheckHostPolicy

public int getDefaultCheckHostPolicy()
Returns default check host policy value. This value is used by the License Host to initialize Network Check when no appropriate value explicitly specified for the license.

Returns:
default check host policy value as one of POLICY_ constants

setDefaultCheckHostPolicy

public void setDefaultCheckHostPolicy(int aDefaultCheckHostPolicy)
Specifies default check host policy value as one of POLICY_ constants. This value will be used by the License Host to initialize Network Check when no appropriate value explicitly specified for the license.

Parameters:
aDefaultCheckHostPolicy - default check host policy to set

checkResponse

protected boolean checkResponse(NetworkCheckPacket packet)

checkHost

protected boolean checkHost(NetworkCheckPacket packet)

getResponseCount

public int getResponseCount()
Returns number of collected responses

Returns:
number of collected responses

sendResponse

protected void sendResponse(java.lang.String aProductID,
                            java.lang.String aLicenseNumber)

sendRequest

protected void sendRequest(java.lang.String aProductID,
                           java.lang.String aLicenseNumber)

getSignature

public java.lang.String getSignature()
Returns signature value

Returns:
signature value (SIGNATURE by default).

setSignature

public void setSignature(java.lang.String aSignature)
Specifies signature value to unique identify particular vendor.

Parameters:
aSignature - signature to set

removeNetworkCheckListener

public void removeNetworkCheckListener(NetworkCheckListener l)
Adds a new listener to the listeners list

Parameters:
l - listener to add

addNetworkCheckListener

public void addNetworkCheckListener(NetworkCheckListener l)
Removes listener from the listeners list

Parameters:
l - listener to remove

fireNumberCopiesViolation

protected void fireNumberCopiesViolation(NetworkCheck param1,
                                         int param2)