Package org.apache.syncope.client.lib
Class SyncopeClient
java.lang.Object
org.apache.syncope.client.lib.SyncopeClient
- Direct Known Subclasses:
SyncopeAnonymousClient
Entry point for client access to all REST services exposed by Syncope core; obtain instances via
SyncopeClientFactoryBean.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final RestClientExceptionMapperprotected static final Stringprotected final org.apache.cxf.transports.http.configuration.HTTPClientPolicyprotected static final Loggerprotected static final com.fasterxml.jackson.databind.json.JsonMapperprotected final MediaTypeprotected final org.apache.cxf.jaxrs.client.JAXRSClientFactoryBeanprotected final TLSClientParametersprotected final boolean -
Constructor Summary
ConstructorsConstructorDescriptionSyncopeClient(MediaType mediaType, org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean restClientFactory, RestClientExceptionMapper exceptionMapper, AuthenticationHandler authHandler, boolean useCompression, org.apache.cxf.transports.http.configuration.HTTPClientPolicy httpClientPolicy, TLSClientParameters tlsClientParameters) -
Method Summary
Modifier and TypeMethodDescriptionbatch()Initiates a new Batch request.protected voidcleanup()delegatedBy(String delegating) Requests to invoke services as delegating user.Gives the base address for REST calls.Returns a new instance ofAnyObjectFiqlSearchConditionBuilder, for assisted building of FIQL queries.Returns a new instance ofConnObjectTOFiqlSearchConditionBuilder, for assisted building of FIQL queries.Returns the domain configured for this instance, orSyncopeConstants.MASTER_DOMAINif not set.Returns a new instance ofGroupFiqlSearchConditionBuilder, for assisted building of FIQL queries.getJWT()Returns the JWT in used by this instance, passed with theHttpHeaders.AUTHORIZATIONheader in all requests.static <T> EntityTaggetLatestEntityTag(T service) FetchesETagheader value from latest service run (if available).static OrderByClauseBuilderReturns a new instance ofOrderByClauseBuilder, for assisted building oforderbyclauses.<T> TgetService(Class<T> serviceClass) Creates an instance of the given service class, with configured content type and authentication.Returns a new instance ofUserFiqlSearchConditionBuilder, for assisted building of FIQL queries.static <T> TSets the given header on the give service instance.static <T> TSets theIf-Matchheader on the given service instance.static <T> TifNoneMatch(T service, EntityTag etag) Sets theIf-None-Matchheader on the given service instance.protected voidinit(AuthenticationHandler authHandler) Initializes the providedrestClientFactorywith the authentication capabilities of the providedhandler.voidlogin(AuthenticationHandler handler) (Re)initializes the current instance with the authentication capabilities of the providedhandler.voidlogout()Invalidates the JWT currently in use.protected static <T> TSets theIf-MatchorIf-None-Matchheader on the given service instance.static <T> TnullPriorityAsync(T service, boolean nullPriorityAsync) Asks for asynchronous propagation towards external resources with null priority.static <T> Tprefer(T service, Preference preference) Sets thePreferheader on the give service instance.voidrefresh()Attempts to extend the lifespan of the JWT currently in use.self()
-
Field Details
-
LOG
-
HEADER_SPLIT_PROPERTY
- See Also:
-
MAPPER
protected static final com.fasterxml.jackson.databind.json.JsonMapper MAPPER -
mediaType
-
restClientFactory
protected final org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean restClientFactory -
exceptionMapper
-
useCompression
protected final boolean useCompression -
httpClientPolicy
protected final org.apache.cxf.transports.http.configuration.HTTPClientPolicy httpClientPolicy -
tlsClientParameters
-
-
Constructor Details
-
SyncopeClient
public SyncopeClient(MediaType mediaType, org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean restClientFactory, RestClientExceptionMapper exceptionMapper, AuthenticationHandler authHandler, boolean useCompression, org.apache.cxf.transports.http.configuration.HTTPClientPolicy httpClientPolicy, TLSClientParameters tlsClientParameters)
-
-
Method Details
-
init
Initializes the providedrestClientFactorywith the authentication capabilities of the providedhandler. Currently supports: More can be supported by subclasses.- Parameters:
authHandler- authentication handler
-
cleanup
protected void cleanup() -
getAddress
Gives the base address for REST calls.- Returns:
- the base address for REST calls
-
delegatedBy
Requests to invoke services as delegating user.- Parameters:
delegating- delegating username- Returns:
- this instance, for fluent usage
-
refresh
public void refresh()Attempts to extend the lifespan of the JWT currently in use. -
logout
public void logout()Invalidates the JWT currently in use. -
login
(Re)initializes the current instance with the authentication capabilities of the providedhandler.- Parameters:
handler- authentication handler
-
getUserSearchConditionBuilder
Returns a new instance ofUserFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Returns:
- default instance of
UserFiqlSearchConditionBuilder
-
getGroupSearchConditionBuilder
Returns a new instance ofGroupFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Returns:
- default instance of
GroupFiqlSearchConditionBuilder
-
getAnyObjectSearchConditionBuilder
Returns a new instance ofAnyObjectFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Parameters:
type- any type- Returns:
- default instance of
AnyObjectFiqlSearchConditionBuilder
-
getConnObjectTOFiqlSearchConditionBuilder
Returns a new instance ofConnObjectTOFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Returns:
- default instance of
ConnObjectTOFiqlSearchConditionBuilder
-
getOrderByClauseBuilder
Returns a new instance ofOrderByClauseBuilder, for assisted building oforderbyclauses.- Returns:
- default instance of
OrderByClauseBuilder
-
getJWT
Returns the JWT in used by this instance, passed with theHttpHeaders.AUTHORIZATIONheader in all requests. It can be null (in caseAnonymousAuthenticationHandlerwas used).- Returns:
- the JWT in used by this instance
-
getDomain
Returns the domain configured for this instance, orSyncopeConstants.MASTER_DOMAINif not set.- Returns:
- the domain configured for this instance
-
getService
Creates an instance of the given service class, with configured content type and authentication.- Type Parameters:
T- any service class- Parameters:
serviceClass- service class reference- Returns:
- service instance of the given reference class
-
self
-
header
Sets the given header on the give service instance.- Type Parameters:
T- any service class- Parameters:
service- service class instancekey- HTTP header keyvalues- HTTP header values- Returns:
- given service instance, with given header set
-
prefer
Sets thePreferheader on the give service instance.- Type Parameters:
T- any service class- Parameters:
service- service class instancepreference- preference to be set viaPreferheader- Returns:
- given service instance, with
Preferheader set
-
nullPriorityAsync
public static <T> T nullPriorityAsync(T service, boolean nullPriorityAsync) Asks for asynchronous propagation towards external resources with null priority.- Type Parameters:
T- any service class- Parameters:
service- service class instancenullPriorityAsync- whether asynchronous propagation towards external resources with null priority is requested- Returns:
- service instance of the given reference class, with related header set
-
match
Sets theIf-MatchorIf-None-Matchheader on the given service instance.- Type Parameters:
T- any service class- Parameters:
service- service class instanceetag- ETag valueifNot- if true thenIf-None-Matchis set,If-Matchotherwise- Returns:
- given service instance, with
If-MatchorIf-None-Matchset
-
ifMatch
Sets theIf-Matchheader on the given service instance.- Type Parameters:
T- any service class- Parameters:
service- service class instanceetag- ETag value- Returns:
- given service instance, with
If-Matchset
-
ifNoneMatch
Sets theIf-None-Matchheader on the given service instance.- Type Parameters:
T- any service class- Parameters:
service- service class instanceetag- ETag value- Returns:
- given service instance, with
If-None-Matchset
-
getLatestEntityTag
FetchesETagheader value from latest service run (if available).- Type Parameters:
T- any service class- Parameters:
service- service class instance- Returns:
ETagheader value from latest service run (if available)
-
batch
Initiates a new Batch request. The typical operation flow is:BatchRequest batchRequest = syncopeClient.batch(); batchRequest.getService(UserService.class).create(...); batchRequest.getService(UserService.class).update(...); batchRequest.getService(GroupService.class).update(...); batchRequest.getService(GroupService.class).delete(...); ... BatchResponse batchResponse = batchRequest().commit(); List<BatchResponseItem> items = batchResponse.getItems()
- Returns:
- empty Batch request
-