org.fosstrak.epcis.captureclient
Class CaptureClient

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

public class CaptureClient
extends Object
implements X509TrustManager, HostnameVerifier

This client provides access to an EPCIS Capture Interface. EPCIS events will be sent to the capture interface using HTTP POST requests. This client supports the following authentication options: HTTP BASIC AUTH and HTTPS with client certificate.

Author:
Marco Steybe

Constructor Summary
CaptureClient()
          Constructs a new CaptureClient using a default URL and no authentication.
CaptureClient(String url)
          Constructs a new CaptureClient using the given URL and no authentication.
CaptureClient(String url, Object[] authOptions)
          Constructs a new CaptureClient using the given URL and authentication options.
 
Method Summary
 int capture(Document epcisDoc)
          Sends the given EPCIS Document to the EPCIS capture interface.
 int capture(InputStream xmlStream)
          Sends the XML available from the given InputStream to the EPCIS capture interface.
 int capture(String eventXml)
          Sends the given XML String to the EPCIS capture interface.
 void checkClientTrusted(X509Certificate[] chain, String authType)
           
 void checkServerTrusted(X509Certificate[] chain, String authType)
           
 int dbReset()
          Invokes the non-standardized dbReset operation in the Fosstrak EPCIS capture interface.
 X509Certificate[] getAcceptedIssuers()
           
 Object[] getAuthOptions()
           
 String getCaptureUrl()
           
 boolean verify(String arg0, 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 using a default URL and no authentication.


CaptureClient

public CaptureClient(String url)
Constructs a new CaptureClient using the given URL and no authentication.

Parameters:
url - The URL to the EPCIS Capture Interface.

CaptureClient

public CaptureClient(String url,
                     Object[] authOptions)
Constructs a new CaptureClient using the given URL and authentication options. The following authentication options are supported:

authOptions[0] authOptions[1] authOptions[2]
AuthenticationType.BASIC username password
AuthenticationType.HTTPS_WITH_CLIENT_CERT keystore file password

Parameters:
url - The URL to the EPCIS Capture Interface.
authOptions - The authentication options as described above.
Method Detail

capture

public int capture(InputStream xmlStream)
            throws CaptureClientException
Sends the XML available from the given InputStream to the EPCIS capture interface. Please see the Fosstrak User-Guide for more information and code samples.

Parameters:
xmlStream - An input stream providing an EPCISDocument with a list of events.
Returns:
The HTTP response code from the repository.
Throws:
CaptureClientException - If an error sending the document occurred.

capture

public int capture(String eventXml)
            throws CaptureClientException
Sends the given XML String to the EPCIS capture interface. Please see the Fosstrak User-Guide for more information and code samples.

Parameters:
eventXml - The XML String with the EPCISDocument and a list of events.
Returns:
The HTTP response code from the repository.
Throws:
CaptureClientException - If an error sending the document occurred.

capture

public int capture(Document epcisDoc)
            throws CaptureClientException
Sends the given EPCIS Document to the EPCIS capture interface. Please see the Fosstrak User-Guide for more information and code samples.

Parameters:
epcisDoc - The EPCIS Document with a list of events.
Returns:
The HTTP response code from the repository.
Throws:
IOException - If an error sending the document occurred.
javax.xml.bind.JAXBException - If an error serializing the given document into XML occurred.
CaptureClientException

dbReset

public int dbReset()
            throws CaptureClientException
Invokes the non-standardized dbReset operation in the Fosstrak EPCIS capture interface. It deletes 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:
CaptureClientException - If a communication error occurred.

getCaptureUrl

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

getAuthOptions

public Object[] getAuthOptions()

checkClientTrusted

public void checkClientTrusted(X509Certificate[] chain,
                               String authType)
                        throws CertificateException
Specified by:
checkClientTrusted in interface X509TrustManager
Throws:
CertificateException

checkServerTrusted

public void checkServerTrusted(X509Certificate[] chain,
                               String authType)
                        throws CertificateException
Specified by:
checkServerTrusted in interface X509TrustManager
Throws:
CertificateException

getAcceptedIssuers

public X509Certificate[] getAcceptedIssuers()
Specified by:
getAcceptedIssuers in interface X509TrustManager

verify

public boolean verify(String arg0,
                      SSLSession arg1)
Specified by:
verify in interface HostnameVerifier


Copyright © 2010. All Rights Reserved.