public class IbisClientConnection extends Object implements ClientConnection
ClientConnection.Method
Constructor and Description |
---|
IbisClientConnection(String urlBase,
boolean checkCertificates)
Create a new ClientConnection using the specified URL base, which
should be something like
"https://www.lookup.cam.ac.uk/" . |
Modifier and Type | Method and Description |
---|---|
static IbisClientConnection |
createConnection()
Create a ClientConnection to the Lookup/Ibis web service API at
https://www.lookup.cam.ac.uk/ . |
static IbisClientConnection |
createLocalConnection()
Create a ClientConnection to a Lookup/Ibis web service API running
locally on
https://localhost:8443/ibis/ . |
static IbisClientConnection |
createTestConnection()
Create a ClientConnection to the Lookup/Ibis test web service API at
https://lookup-test.srv.uis.cam.ac.uk/ . |
IbisResult |
invokeMethod(ClientConnection.Method method,
String path,
String[] pathParams,
Object[] queryParams,
Object[] formParams)
Invoke a web service GET, POST, PUT or DELETE method.
|
IbisResult |
invokeMethod(String path,
String[] pathParams,
Object[] queryParams)
Invoke a web service GET method.
|
void |
setPassword(String password)
Set the password to use when connecting to the Lookup/Ibis web service.
|
void |
setUsername(String username)
Set the username to use when connecting to the Lookup/Ibis web service.
|
public IbisClientConnection(String urlBase, boolean checkCertificates) throws GeneralSecurityException, IOException, JAXBException
"https://www.lookup.cam.ac.uk/"
.
It is strongly recommended that certificate checking be enabled.
The connection is initially anonymous, but this may be changed using
setUsername(String)
and setPassword(String)
.
urlBase
- The base URL to the Lookup/Ibis web service API.checkCertificates
- If this is true
the server's
certificates will be checked. Otherwise, the they will not, and the
connection may be insecure.GeneralSecurityException
IOException
JAXBException
createConnection()
,
createTestConnection()
public static IbisClientConnection createConnection() throws GeneralSecurityException, IOException, JAXBException
https://www.lookup.cam.ac.uk/
.
The connection is initially anonymous, but this may be changed using
setUsername(String)
and setPassword(String)
.
GeneralSecurityException
IOException
JAXBException
public static IbisClientConnection createTestConnection() throws GeneralSecurityException, IOException, JAXBException
https://lookup-test.srv.uis.cam.ac.uk/
.
The connection is initially anonymous, but this may be changed using
setUsername(String)
and setPassword(String)
.
NOTE: This test server is not guaranteed to always be available, and the data in it may be out of sync with the data on the live system.
GeneralSecurityException
IOException
JAXBException
public static IbisClientConnection createLocalConnection() throws GeneralSecurityException, IOException, JAXBException
https://localhost:8443/ibis/
.
The connection is initially anonymous, but this may be changed using
setUsername(String)
and setPassword(String)
.
This is intended for testing during development. The local server is assumed to be using self-signed certificates, which will not be checked.
GeneralSecurityException
IOException
JAXBException
public void setUsername(String username)
ClientConnection
This method may be called at any time, and affects all subsequent access using this connection, but should not affect any other ClientConnection objects.
setUsername
in interface ClientConnection
username
- The username to connect as. This should either be
"anonymous" (the default) or the name of a group.public void setPassword(String password)
ClientConnection
setPassword
in interface ClientConnection
password
- The group password.public IbisResult invokeMethod(String path, String[] pathParams, Object[] queryParams) throws IOException, JAXBException
ClientConnection
The path should be the relative path to the method with standard
Java format specifiers for any path parameters, for example
"api/v1/person/%1$s/%2$s"
. Any path parameters specified
are then substituted into the path according to the standard Java
formatting rules.
invokeMethod
in interface ClientConnection
path
- The path to the method to invoke.pathParams
- Any path parameters that should be inserted into
the path in place of any format specifiers.queryParams
- Any query parameters to add as part of the URL's
query string. These are expected to come in pairs {name1, value1,
name2, value2, ...}.IOException
JAXBException
public IbisResult invokeMethod(ClientConnection.Method method, String path, String[] pathParams, Object[] queryParams, Object[] formParams) throws IOException, JAXBException
ClientConnection
The path should be the relative path to the method with standard
Java format specifiers for any path parameters, for example
"api/v1/person/%1$s/%2$s"
. Any path parameters specified
are then substituted into the path according to the standard Java
formatting rules.
invokeMethod
in interface ClientConnection
method
- The method type (GET, POST, PUT or DELETE).path
- The path to the method to invoke.pathParams
- Any path parameters that should be inserted into
the path in place of any format specifiers.queryParams
- Any query parameters to add as part of the URL's
query string. These are expected to come in pairs {name1, value1,
name2, value2, ...}.formParams
- Any form parameters to submit. These are expected
to come in pairs {name1, value1, name2, value2, ...}.IOException
JAXBException