public abstract class AbstractClient extends Object
This is an abstract class, that implements the basic functions for communication with the IS24-Webservice.
Modifier and Type | Field and Description |
---|---|
static String |
LIVE_API
URL, that points to the webservice in live environment.
|
static String |
RESPONSE_HEADER_API_CLIENT
Name of the custom response header by IS24,
that contains the Consumer Key of the client.
|
static String |
RESPONSE_HEADER_CAUSER_ID
Name of the custom response header by IS24,
that contains the IS24 agent ID.
|
static String |
RESPONSE_HEADER_REQUEST_REFNUM
Name of the custom response header by IS24,
that contains a unique ID of the request, that refers to this response.
|
static String |
RESPONSE_HEADER_RESOURCE_ID
Name of the custom response header by IS24,
that contains the ID of the requested resource.
|
static String |
SANDBOX_API
URL, that points to the webservice in sandbox environment.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractClient(String apiBaseUrl,
String consumerToken,
String consumerSecret)
Create an instance of
AbstractClient . |
Modifier and Type | Method and Description |
---|---|
void |
authorize(Authorization authorization)
Initializes client with access credentials.
|
void |
authorize(String accessToken,
String accessSecret)
Initializes client with access credentials.
|
Authorization |
authorizeAfterVerification(String verificationToken,
String verificationSecret,
String verificationCode)
Initializes client after a succesful verification.
|
Authorization |
authorizeAfterVerification(Verification verification,
String verificationCode)
Initializes client after a succesful verification.
|
protected oauth.signpost.OAuthConsumer |
buildOAuthConsumer(String token,
String secret)
Create an
OAuthConsumer object for access credentials. |
protected oauth.signpost.OAuthProvider |
buildOAuthProvider(String apiBaseUrl)
Create an
OAuthProvider for the IS24-Webservice. |
Verification |
fetchVerification()
Initiate a verification process.
|
Verification |
fetchVerification(String callbackUrl)
Initiate a verification process.
|
String |
getApiBaseUrl()
Return URL of the configured IS24-Webservice.
|
oauth.signpost.OAuthConsumer |
getAuthConsumer()
Return
OAuthConsumer of the client for the current authorization. |
oauth.signpost.OAuthProvider |
getAuthProvider()
Return
OAuthProvider of the client for the current authorization. |
static String |
getEncoding()
Return encoding for transferred data.
|
static String |
getUrlEncodedValue(String value)
Encode a string value for use in an URL according to
RFC 3986.
|
protected abstract Response |
sendVideoUploadRequest(URL url,
RequestMethod method,
String auth,
InputStream input,
String fileName,
long fileSize)
Send a video with an authentication value to the IS24-Webservice.
|
protected abstract Response |
sendXmlAttachmentRequest(URL url,
RequestMethod method,
String xml,
InputStream input,
String fileName,
String mimeType)
Send a XML string together with a file to the IS24-Webservice.
|
protected abstract Response |
sendXmlRequest(URL url,
RequestMethod method,
String xml)
Send a XML string to the IS24-Webservice.
|
public static final String LIVE_API
public static final String SANDBOX_API
public static final String RESPONSE_HEADER_API_CLIENT
public static final String RESPONSE_HEADER_CAUSER_ID
public static final String RESPONSE_HEADER_REQUEST_REFNUM
public static final String RESPONSE_HEADER_RESOURCE_ID
protected AbstractClient(String apiBaseUrl, String consumerToken, String consumerSecret)
AbstractClient
.apiBaseUrl
- base URL of the IS24-Webservice (see LIVE_API
and
SANDBOX_API
)consumerToken
- consumer token, that identifies the application at the IS24-WebserviceconsumerSecret
- consumer secret, that identifies the application at the IS24-Webservicepublic final void authorize(Authorization authorization) throws oauth.signpost.exception.OAuthException
authorization
- Authorization
object, that contains the credentials for permanent
access to the IS24-Webserviceoauth.signpost.exception.OAuthException
- if intitalization of the authorization failedpublic final void authorize(String accessToken, String accessSecret) throws oauth.signpost.exception.OAuthException
accessToken
- token for permanent access to the IS24-WebserviceaccessSecret
- secret for permanent access to the IS24-Webserviceoauth.signpost.exception.OAuthException
- if intitalization of the authorization failedpublic final Authorization authorizeAfterVerification(Verification verification, String verificationCode) throws oauth.signpost.exception.OAuthException
verification
- Verification
object, that contains the credentials for temporary
access to the IS24-Webservice during verificationverificationCode
- verification code, that was received after the verification was finishedAuthorization
object, that contains the access credentials for
future useoauth.signpost.exception.OAuthException
- if intitalization of the authorization failedpublic final Authorization authorizeAfterVerification(String verificationToken, String verificationSecret, String verificationCode) throws oauth.signpost.exception.OAuthException
verificationToken
- token for temporary access to the IS24-Webservice during verificationverificationSecret
- secret for temporary access to the IS24-Webservice during verificationverificationCode
- verification code, that was received after the verification was finishedAuthorization
object, that contains the access credentials for
future useoauth.signpost.exception.OAuthException
- if intitalization of the authorization failedprotected oauth.signpost.OAuthConsumer buildOAuthConsumer(String token, String secret)
OAuthConsumer
object for access credentials.
Different implementations of AbstractClient
may create different
OAuthConsumer
objects.
token
- access or verification tokensecret
- access or verification secretOAuthConsumer
for the provided credentialsprotected oauth.signpost.OAuthProvider buildOAuthProvider(String apiBaseUrl)
OAuthProvider
for the IS24-Webservice.
Different implementations of AbstractClient
may create different
OAuthProvider
objects.
apiBaseUrl
- URL of the IS24-WebserviceOAuthProvider
for the provided URLpublic final Verification fetchVerification() throws oauth.signpost.exception.OAuthException
Verification
that contains informations about the
initiated verification processoauth.signpost.exception.OAuthException
- if initiation failedpublic final Verification fetchVerification(String callbackUrl) throws oauth.signpost.exception.OAuthException
callbackUrl
- the URL, where the user is redirected to, after the verification was
finished / cancelledVerification
that contains informations about the
initiated verification processoauth.signpost.exception.OAuthException
- if initiation failedpublic final String getApiBaseUrl()
public final oauth.signpost.OAuthConsumer getAuthConsumer() throws oauth.signpost.exception.OAuthNotAuthorizedException
OAuthConsumer
of the client for the current authorization.OAuthConsumer
instance of the clientoauth.signpost.exception.OAuthNotAuthorizedException
- if the client is not authorizedpublic final oauth.signpost.OAuthProvider getAuthProvider() throws oauth.signpost.exception.OAuthNotAuthorizedException
OAuthProvider
of the client for the current authorization.OAuthProvider
instance of the clientoauth.signpost.exception.OAuthNotAuthorizedException
- if the client is not authorizedpublic static String getEncoding()
This function always returns XmlUtils.DEFAULT_ENCODING
.
public static String getUrlEncodedValue(String value)
value
- the value to encodeprotected abstract Response sendXmlRequest(URL url, RequestMethod method, String xml) throws IOException, oauth.signpost.exception.OAuthException
This function must be implemendet by specific implementations of
AbstractClient
.
url
- URL of the IS24-Webservice, where the request is sent tomethod
- HTTP method of the outgoing requestxml
- XML string, that is sent to the IS24-WebserviceIOException
- if communication with IS24-Webservice failedoauth.signpost.exception.OAuthException
- if authorization failedprotected abstract Response sendXmlAttachmentRequest(URL url, RequestMethod method, String xml, InputStream input, String fileName, String mimeType) throws IOException, oauth.signpost.exception.OAuthException
This function must be implemendet by specific implementations of
AbstractClient
.
url
- URL of the IS24-Webservice, where the request is sent tomethod
- the HTTP method of the outgoing requestxml
- the XML string, that is sent to the IS24-Webserviceinput
- the file content, that is sent to the IS24-WebservicefileName
- the name of the file, that is sent to the IS24-WebservicemimeType
- the MIME-type of the file, that is sent to the IS24-WebserviceIOException
- if communication with IS24-Webservice failedoauth.signpost.exception.OAuthException
- if authorization failedprotected abstract Response sendVideoUploadRequest(URL url, RequestMethod method, String auth, InputStream input, String fileName, long fileSize) throws IOException, oauth.signpost.exception.OAuthException
This function must be implemendet by specific implementations of
AbstractClient
.
url
- URL of the IS24-Webservice, where the request is sent tomethod
- HTTP method of the outgoing requestauth
- authentication value, that is sent to the IS24-Webserviceinput
- file content, that is sent to the IS24-WebservicefileName
- name of the file, that is sent to the IS24-WebservicefileSize
- size of the file, that is sent to the IS24-Webservice (in bytes)IOException
- if communication with IS24-Webservice failedoauth.signpost.exception.OAuthException
- if authorization failedCopyright © 2015 OpenEstate. All rights reserved.