org.fosstrak.epcis.captureclient
Class CaptureClient

java.lang.Object
  extended by org.fosstrak.epcis.captureclient.CaptureClient
All Implemented Interfaces:
javax.net.ssl.HostnameVerifier, javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager

public class CaptureClient
extends java.lang.Object
implements javax.net.ssl.X509TrustManager, javax.net.ssl.HostnameVerifier

This client provides access to the repository's Capture Operations Module through the capture interface. EPCISEvents will be sent to the module using HTTP POST requests.

Author:
Marco Steybe

Constructor Summary
CaptureClient()
          Constructs a new CaptureClient which connects to the Capture Operations Module listening at the default URL, with no authentication.
CaptureClient(java.lang.String url)
          Constructs a new CaptureClient which connects to the Capture Operations Module listening at the specified URL, with no authentication.
CaptureClient(java.lang.String url, java.lang.Object[] authOptions)
          Constructs a new CaptureClient which connects to the Capture Operations Module listening at the given URL.
 
Method Summary
 int capture(org.fosstrak.epcis.model.EPCISDocumentType epcisDoc)
          Send the given EPCISDocumentType to the repository for capturing.
 int capture(java.io.InputStream xmlStream)
          Send the XML available from the given InputStream to the repository for capturing.
 int capture(java.lang.String eventXml)
          Send the given XML String to the repository for capturing.
 void checkClientTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)
           
 void checkServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType)
           
 int dbReset()
          Invokes the dbReset operation in the Capture Module deleting all event data in the EPCIS database.
 java.security.cert.X509Certificate[] getAcceptedIssuers()
           
 java.lang.Object[] getAuthOptions()
           
 java.lang.String getCaptureUrl()
           
 boolean verify(java.lang.String arg0, javax.net.ssl.SSLSession arg1)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaptureClient

public CaptureClient()
Constructs a new CaptureClient which connects to the Capture Operations Module listening at the default URL, with no authentication.


CaptureClient

public CaptureClient(java.lang.String url)
Constructs a new CaptureClient which connects to the Capture Operations Module listening at the specified URL, with no authentication.


CaptureClient

public CaptureClient(java.lang.String url,
                     java.lang.Object[] authOptions)
Constructs a new CaptureClient which connects to the Capture Operations Module listening at the given URL.

Parameters:
url - The URL at which the capture service listens.
authOptions - The authentication options:

authenticationOptions[0] [1] [2]
AuthenticationType.BASIC username password
AuthenticationType.HTTPS_WITH_CLIENT_CERT keystore file password
Method Detail

capture

public int capture(java.io.InputStream xmlStream)
            throws java.lang.Exception
Send the XML available from the given InputStream to the repository for capturing.

Parameters:
xmlStream - A stream providing an EPCISDocument which contains a list of events inside the EPCISBody element.
Returns:
The HTTP response code from the repository.
Throws:
java.io.IOException - If an error sending the document occurred.
java.lang.Exception

capture

public int capture(java.lang.String eventXml)
            throws java.lang.Exception
Send the given XML String to the repository for capturing.

Parameters:
eventXml - The XML String consisting of an EPCISDocument which in turn contains a list of events inside the EPCISBody element.
Returns:
The HTTP response code from the repository.
Throws:
java.io.IOException - If an error sending the document occurred.
java.lang.Exception

capture

public int capture(org.fosstrak.epcis.model.EPCISDocumentType epcisDoc)
            throws java.lang.Exception
Send the given EPCISDocumentType to the repository for capturing.

Parameters:
epcisDoc - The EPCISDocument containing a list of events inside the EPCISBody element.
Returns:
The HTTP response code from the repository.
Throws:
java.io.IOException - If an error sending the document occurred.
javax.xml.bind.JAXBException - If an error serializing the given document into XML occurred.
java.lang.Exception

dbReset

public int dbReset()
            throws java.lang.Exception
Invokes the dbReset operation in the Capture Module deleting all event data in the EPCIS database. This operation is only allowed if the corresponding property is set in the repository's configuration.

Returns:
The response from the capture module.
Throws:
java.io.IOException - If a communication error occurred.
java.lang.Exception

getCaptureUrl

public java.lang.String getCaptureUrl()
Returns:
The URL String at which the Capture Operations Module listens.

getAuthOptions

public java.lang.Object[] getAuthOptions()

checkClientTrusted

public void checkClientTrusted(java.security.cert.X509Certificate[] chain,
                               java.lang.String authType)
                        throws java.security.cert.CertificateException
Specified by:
checkClientTrusted in interface javax.net.ssl.X509TrustManager
Throws:
java.security.cert.CertificateException

checkServerTrusted

public void checkServerTrusted(java.security.cert.X509Certificate[] chain,
                               java.lang.String authType)
                        throws java.security.cert.CertificateException
Specified by:
checkServerTrusted in interface javax.net.ssl.X509TrustManager
Throws:
java.security.cert.CertificateException

getAcceptedIssuers

public java.security.cert.X509Certificate[] getAcceptedIssuers()
Specified by:
getAcceptedIssuers in interface javax.net.ssl.X509TrustManager

verify

public boolean verify(java.lang.String arg0,
                      javax.net.ssl.SSLSession arg1)
Specified by:
verify in interface javax.net.ssl.HostnameVerifier


Copyright © 2009. All Rights Reserved.