Package org.apache.syncope.client.lib
Class SyncopeClient
- java.lang.Object
-
- org.apache.syncope.client.lib.SyncopeClient
-
public class SyncopeClient extends Object
Entry point for client access to all REST services exposed by Syncope core; obtain instances viaSyncopeClientFactoryBean.
-
-
Field Summary
Fields Modifier and Type Field Description protected RestClientExceptionMapperexceptionMapperprotected static StringHEADER_SPLIT_PROPERTYprotected static org.slf4j.LoggerLOGprotected static com.fasterxml.jackson.databind.json.JsonMapperMAPPERprotected javax.ws.rs.core.MediaTypemediaTypeprotected org.apache.cxf.jaxrs.client.JAXRSClientFactoryBeanrestClientFactoryprotected org.apache.cxf.configuration.jsse.TLSClientParameterstlsClientParametersprotected booleanuseCompression
-
Constructor Summary
Constructors Constructor Description SyncopeClient(javax.ws.rs.core.MediaType mediaType, org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean restClientFactory, RestClientExceptionMapper exceptionMapper, AuthenticationHandler handler, boolean useCompression, org.apache.cxf.configuration.jsse.TLSClientParameters tlsClientParameters)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchRequestbatch()Initiates a new Batch request.protected voidcleanup()SyncopeClientdelegatedBy(String delegating)Requests to invoke services as delegating user.StringgetAddress()Gives the base address for REST calls.static org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuildergetAnyObjectSearchConditionBuilder(String type)Returns a new instance ofAnyObjectFiqlSearchConditionBuilder, for assisted building of FIQL queries.static org.apache.syncope.common.lib.search.ConnObjectTOFiqlSearchConditionBuildergetConnObjectTOFiqlSearchConditionBuilder()Returns a new instance ofConnObjectTOFiqlSearchConditionBuilder, for assisted building of FIQL queries.StringgetDomain()Returns the domain configured for this instance, orSyncopeConstants.MASTER_DOMAINif not set.static org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuildergetGroupSearchConditionBuilder()Returns a new instance ofGroupFiqlSearchConditionBuilder, for assisted building of FIQL queries.StringgetJWT()Returns the JWT in used by this instance, passed with theHttpHeaders.AUTHORIZATIONheader in all requests.static <T> javax.ws.rs.core.EntityTaggetLatestEntityTag(T service)FetchesETagheader value from latest service run (if available).static org.apache.syncope.common.lib.search.OrderByClauseBuildergetOrderByClauseBuilder()Returns 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.static org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuildergetUserSearchConditionBuilder()Returns a new instance ofUserFiqlSearchConditionBuilder, for assisted building of FIQL queries.org.apache.commons.lang3.tuple.Pair<String,String>gitAndBuildInfo()static <T> Theader(T service, String key, Object... values)Sets the given header on the give service instance.static <T> TifMatch(T service, javax.ws.rs.core.EntityTag etag)Sets theIf-Matchheader on the given service instance.static <T> TifNoneMatch(T service, javax.ws.rs.core.EntityTag etag)Sets theIf-None-Matchheader on the given service instance.protected com.fasterxml.jackson.databind.JsonNodeinfo()protected voidinit(AuthenticationHandler handler)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> Tmatch(T service, javax.ws.rs.core.EntityTag etag, boolean ifNot)Sets 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.org.apache.syncope.common.lib.info.NumbersInfonumbers()org.apache.syncope.common.lib.info.PlatformInfoplatform()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.org.apache.commons.lang3.tuple.Triple<Map<String,Set<String>>,List<String>,org.apache.syncope.common.lib.to.UserTO>self()org.apache.syncope.common.lib.info.SystemInfosystem()
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
HEADER_SPLIT_PROPERTY
protected static final String HEADER_SPLIT_PROPERTY
- See Also:
- Constant Field Values
-
MAPPER
protected static final com.fasterxml.jackson.databind.json.JsonMapper MAPPER
-
mediaType
protected final javax.ws.rs.core.MediaType mediaType
-
restClientFactory
protected final org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean restClientFactory
-
exceptionMapper
protected final RestClientExceptionMapper exceptionMapper
-
useCompression
protected final boolean useCompression
-
tlsClientParameters
protected final org.apache.cxf.configuration.jsse.TLSClientParameters tlsClientParameters
-
-
Constructor Detail
-
SyncopeClient
public SyncopeClient(javax.ws.rs.core.MediaType mediaType, org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean restClientFactory, RestClientExceptionMapper exceptionMapper, AuthenticationHandler handler, boolean useCompression, org.apache.cxf.configuration.jsse.TLSClientParameters tlsClientParameters)
-
-
Method Detail
-
init
protected void init(AuthenticationHandler handler)
Initializes the providedrestClientFactorywith the authentication capabilities of the providedhandler. Currently supports: More can be supported by subclasses.- Parameters:
handler- authentication handler
-
cleanup
protected void cleanup()
-
info
protected com.fasterxml.jackson.databind.JsonNode info() throws IOException- Throws:
IOException
-
platform
public org.apache.syncope.common.lib.info.PlatformInfo platform()
-
system
public org.apache.syncope.common.lib.info.SystemInfo system()
-
numbers
public org.apache.syncope.common.lib.info.NumbersInfo numbers()
-
getAddress
public String getAddress()
Gives the base address for REST calls.- Returns:
- the base address for REST calls
-
delegatedBy
public SyncopeClient delegatedBy(String delegating)
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
public void login(AuthenticationHandler handler)
(Re)initializes the current instance with the authentication capabilities of the providedhandler.- Parameters:
handler- authentication handler
-
getUserSearchConditionBuilder
public static org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder getUserSearchConditionBuilder()
Returns a new instance ofUserFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Returns:
- default instance of
UserFiqlSearchConditionBuilder
-
getGroupSearchConditionBuilder
public static org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuilder getGroupSearchConditionBuilder()
Returns a new instance ofGroupFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Returns:
- default instance of
GroupFiqlSearchConditionBuilder
-
getAnyObjectSearchConditionBuilder
public static org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder getAnyObjectSearchConditionBuilder(String type)
Returns a new instance ofAnyObjectFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Parameters:
type- any type- Returns:
- default instance of
AnyObjectFiqlSearchConditionBuilder
-
getConnObjectTOFiqlSearchConditionBuilder
public static org.apache.syncope.common.lib.search.ConnObjectTOFiqlSearchConditionBuilder getConnObjectTOFiqlSearchConditionBuilder()
Returns a new instance ofConnObjectTOFiqlSearchConditionBuilder, for assisted building of FIQL queries.- Returns:
- default instance of
ConnObjectTOFiqlSearchConditionBuilder
-
getOrderByClauseBuilder
public static org.apache.syncope.common.lib.search.OrderByClauseBuilder getOrderByClauseBuilder()
Returns a new instance ofOrderByClauseBuilder, for assisted building oforderbyclauses.- Returns:
- default instance of
OrderByClauseBuilder
-
getJWT
public String getJWT()
Returns the JWT in used by this instance, passed with theHttpHeaders.AUTHORIZATIONheader in all requests. It can be null (in caseNoAuthenticationHandlerorAnonymousAuthenticationHandlerwere used).- Returns:
- the JWT in used by this instance
-
getDomain
public String getDomain()
Returns the domain configured for this instance, orSyncopeConstants.MASTER_DOMAINif not set.- Returns:
- the domain configured for this instance
-
getService
public <T> T getService(Class<T> serviceClass)
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
public org.apache.commons.lang3.tuple.Triple<Map<String,Set<String>>,List<String>,org.apache.syncope.common.lib.to.UserTO> self()
-
header
public static <T> T header(T service, String key, Object... values)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
public static <T> T prefer(T service, Preference preference)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
protected static <T> T match(T service, javax.ws.rs.core.EntityTag etag, boolean ifNot)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
public static <T> T ifMatch(T service, javax.ws.rs.core.EntityTag etag)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
public static <T> T ifNoneMatch(T service, javax.ws.rs.core.EntityTag etag)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
public static <T> javax.ws.rs.core.EntityTag getLatestEntityTag(T service)
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
public BatchRequest 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
-
-