Class BaseRestDriver<U extends UserIdentityModel,G extends GroupIdentityModel>
java.lang.Object
com.exclamationlabs.connid.base.connector.driver.rest.BaseRestDriver<U,G>
- All Implemented Interfaces:
Driver<U,G>
public abstract class BaseRestDriver<U extends UserIdentityModel,G extends GroupIdentityModel> extends Object implements Driver<U,G>
Abstract class for drivers that need to make calls to RESTful web services
to manage user and group information.
-
Field Summary
Fields Modifier and Type Field Description protected Authenticator
authenticator
protected ConnectorConfiguration
configuration
protected static com.google.gson.GsonBuilder
gsonBuilder
-
Constructor Summary
Constructors Constructor Description BaseRestDriver()
-
Method Summary
Modifier and Type Method Description protected org.apache.http.client.HttpClient
createClient()
Normal HTTP Client.protected <T> T
executeDeleteRequest(String restUri, Class<T> expectedResponseType)
protected <T> T
executeDeleteRequest(String restUri, Class<T> expectedResponseType, Object requestBody)
protected <T> T
executeDeleteRequest(String restUri, Class<T> expectedResponseType, Object requestBody, Map<String,String> additionalHeaders)
protected <T> T
executeDeleteRequest(String restUri, Class<T> expectedResponseType, Map<String,String> additionalHeaders)
protected <T> T
executeGetRequest(String restUri, Class<T> expectedResponseType)
protected <T> T
executeGetRequest(String restUri, Class<T> expectedResponseType, Map<String,String> additionalHeaders)
protected <T> T
executePatchRequest(String restUri, Class<T> expectedResponseType, Object requestBody)
protected <T> T
executePatchRequest(String restUri, Class<T> expectedResponseType, Object requestBody, Map<String,String> additionalHeaders)
protected <T> T
executePostRequest(String restUri, Class<T> expectedResponseType, Object requestBody)
protected <T> T
executePostRequest(String restUri, Class<T> expectedResponseType, Object requestBody, Map<String,String> additionalHeaders)
protected <T> T
executePutRequest(String restUri, Class<T> expectedResponseType, Object requestBody)
protected <T> T
executePutRequest(String restUri, Class<T> expectedResponseType, Object requestBody, Map<String,String> additionalHeaders)
<T> T
executeRequest(org.apache.http.client.methods.HttpRequestBase request, Class<T> returnType)
<T> T
executeRequest(org.apache.http.client.methods.HttpRequestBase request, Class<T> returnType, boolean isRetry)
protected abstract String
getBaseServiceUrl()
This method should return the base Service URL for RESTful endpoints that this driver invokes.protected abstract RestFaultProcessor
getFaultProcessor()
Return the fault processor that will be used to analyze and respond to HTTP error responses.void
initialize(BaseConnectorConfiguration config, Authenticator auth)
Receives the configuration and authenticator objects that may be needed by the driver.protected boolean
usesBearerAuthorization()
Override this and return true if the RESTful services you are calling require Authorization: Bearer [token] in the HTTP header.protected boolean
usesTokenAuthorization()
Override this and return true if the RESTful services you are calling require Authorization: Token token=[token] in the HTTP header.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.exclamationlabs.connid.base.connector.driver.Driver
addGroupToUser, close, createGroup, createUser, deleteGroup, deleteUser, getGroup, getGroups, getRequiredPropertyNames, getUser, getUsers, removeGroupFromUser, test, updateGroup, updateUser
-
Field Details
-
gsonBuilder
protected static com.google.gson.GsonBuilder gsonBuilder -
configuration
-
authenticator
-
-
Constructor Details
-
BaseRestDriver
public BaseRestDriver()
-
-
Method Details
-
initialize
public void initialize(BaseConnectorConfiguration config, Authenticator auth) throws org.identityconnectors.framework.common.exceptions.ConnectorExceptionDescription copied from interface:Driver
Receives the configuration and authenticator objects that may be needed by the driver. In this method, any additional initialization that needs to be done to prep the Driver for repeated usage should also be done.- Specified by:
initialize
in interfaceDriver<U extends UserIdentityModel,G extends GroupIdentityModel>
- Parameters:
config
- Reference to Configuration object so that this driver has access to configuration properties and the access token.auth
- Reference to the Authenticator object in case this Driver needs to make a call to reauthenticate (often because of a timeout or token expiration condition).- Throws:
org.identityconnectors.framework.common.exceptions.ConnectorException
- If a problem occurred that prevented Driver from completing it's initialization.
-
getFaultProcessor
Return the fault processor that will be used to analyze and respond to HTTP error responses. -
createClient
protected org.apache.http.client.HttpClient createClient()Normal HTTP Client. If need arises for a secure HTTPS Client backed by a cert/keystore, etc. such as with FIS, a separate utility class should be added to possibly provide that support (look at FIS codebase for an example). -
usesBearerAuthorization
protected boolean usesBearerAuthorization()Override this and return true if the RESTful services you are calling require Authorization: Bearer [token] in the HTTP header. If true, this header will be added to all requests, with the token coming from value stored in ConnectorConfiguration getCredentialAccessToken(). -
usesTokenAuthorization
protected boolean usesTokenAuthorization()Override this and return true if the RESTful services you are calling require Authorization: Token token=[token] in the HTTP header. If true, this header will be added to all requests, with the token coming from value stored in ConnectorConfiguration getCredentialAccessToken(). -
getBaseServiceUrl
This method should return the base Service URL for RESTful endpoints that this driver invokes. If not used and full URL needs to be fully reconstructed for every different RESTful API call, have this method return empty string (not null).- Returns:
- Empty string or String containing a beginning portion of the RESTful URL that will need to be invoked
-
executeRequest
public <T> T executeRequest(org.apache.http.client.methods.HttpRequestBase request, Class<T> returnType) -
executeRequest
public <T> T executeRequest(org.apache.http.client.methods.HttpRequestBase request, Class<T> returnType, boolean isRetry) -
executeGetRequest
-
executePostRequest
-
executePutRequest
-
executePatchRequest
-
executeDeleteRequest
-
executeDeleteRequest
-
executeGetRequest
-
executePostRequest
-
executePutRequest
-
executePatchRequest
-
executeDeleteRequest
-
executeDeleteRequest
-