Class OslcClients
- java.lang.Object
-
- com.sodius.oslc.client.OslcClients
-
public class OslcClients extends Object
Provides facilities to instantiate HTTP and OSLC clients.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OslcClientFactory
basic(org.apache.http.auth.Credentials credentials)
Returns a factory to create an OSLC client handling BASIC authentication.static OslcClientFactory
basic(org.apache.http.client.CredentialsProvider credentialsProvider)
Returns a factory to create an OSLC client handling BASIC authentication, with possibly various credentials being used depending on the server to address.static OslcClientFactory
bearer(String token)
Returns a factory to create an OSLC client handling Bearer authentication.static OslcClient
concurrent(OslcClient client)
Returns a thread-safe OSLC client meant to be used with anExecutor
.static OslcClientFactory
concurrent(OslcClientFactory factory)
Returns a factory to create a thread-safe OSLC client meant to be used with anExecutor
.static org.apache.http.client.HttpClient
createHttpClient()
Returns an HTTP client configured to execute HTTPS requests.static OslcClientFactory
jazzAppPassword(org.apache.http.auth.Credentials credentials)
Returns a factory to create an OSLC client handling Jazz Application Password authentication.static OslcClientFactory
jazzForm(org.apache.http.auth.Credentials credentials)
Returns a factory to create an OSLC client to connect to an IBM Jazz server, using FORM based authentication.static OslcClientFactory
jazzForm(org.apache.http.client.CredentialsProvider credentialsProvider)
Returns a factory to create an OSLC client to connect to an IBM Jazz server, using FORM based authentication, with possibly various credentials being used depending on the server to address.static OslcClientFactory
oauth(OAuthStore oauthStore, OAuthHandler oauthHandler)
Returns a factory to create an OSLC client handling OAuth authentication.static OslcClientFactory
oauth2ClientCredentials(org.apache.http.auth.Credentials credentials, URI accessTokenUri)
Returns a factory to create an OSLC client handling OAuth 2.0 Client Credentials authentication.static OslcClientFactory
oauthTwoLegged(FriendProvider friendProvider)
Returns a factory to create a 2-legged OSLC client.static OslcClientFactory
unauthenticated()
Returns a factory to create an authentication-free OSLC client.
-
-
-
Method Detail
-
createHttpClient
public static org.apache.http.client.HttpClient createHttpClient()
Returns an HTTP client configured to execute HTTPS requests.- Returns:
- an HTTP client.
-
basic
public static OslcClientFactory basic(org.apache.http.auth.Credentials credentials)
Returns a factory to create an OSLC client handling BASIC authentication.- Parameters:
credentials
- the credentials to use when executing OSLC requests on the server.- Returns:
- a factory to create an OSLC client handling BASIC authentication.
-
basic
public static OslcClientFactory basic(org.apache.http.client.CredentialsProvider credentialsProvider)
Returns a factory to create an OSLC client handling BASIC authentication, with possibly various credentials being used depending on the server to address.- Parameters:
credentialsProvider
- provides credentials which may vary depending on the targeted host.- Returns:
- a factory to create an OSLC client handling BASIC authentication.
-
bearer
public static OslcClientFactory bearer(String token)
Returns a factory to create an OSLC client handling Bearer authentication.Such authentication can notably be used to connect to IBM Engineering Lifecycle Management (ELM) when deployed with Jazz Authorization Server. The Bearer token in this case is the App Token that an ELM user may generate for a particular usage, for the client to connect to the server on behalf of the user.
- Parameters:
token
- the Bearer token to use for the authorization.- Returns:
- a factory to create an OSLC client handling Bearer authentication.
- Throws:
NullPointerException
- if token isnull
or empty- Since:
- 3.12.0
-
unauthenticated
public static OslcClientFactory unauthenticated()
Returns a factory to create an authentication-free OSLC client.- Returns:
- a factory to create an authentication-free OSLC client.
- Since:
- 1.7.0
-
jazzForm
public static OslcClientFactory jazzForm(org.apache.http.auth.Credentials credentials)
Returns a factory to create an OSLC client to connect to an IBM Jazz server, using FORM based authentication. The authentication is made when the first request is executed on a server.- Parameters:
credentials
- the credentials to use when executing OSLC requests on the server.- Returns:
- a factory to create an OSLC client handling FORM based authentication on a Jazz server.
-
jazzForm
public static OslcClientFactory jazzForm(org.apache.http.client.CredentialsProvider credentialsProvider)
Returns a factory to create an OSLC client to connect to an IBM Jazz server, using FORM based authentication, with possibly various credentials being used depending on the server to address. The authentication is made when the first request is executed on a server.- Parameters:
credentialsProvider
- provides credentials which may vary depending on the targeted host.- Returns:
- a factory to create an OSLC client handling FORM based authentication on a Jazz server.
-
jazzAppPassword
public static OslcClientFactory jazzAppPassword(org.apache.http.auth.Credentials credentials)
Returns a factory to create an OSLC client handling Jazz Application Password authentication.Such authentication can be used to connect to IBM Engineering Lifecycle Management (ELM) when deployed with Jazz Authorization Server and version is 7.0.2 or higher. The user name in the credentials is the identity of the user that generated an Application Password in Jazz Authorization Server, the password is the mentioned Application Password.
- Parameters:
credentials
- the credentials to use when executing OSLC requests on the server.- Returns:
- a factory to create an OSLC client handling Jazz App-Password authentication.
- Throws:
NullPointerException
- if credentials isnull
- Since:
- 3.12.0
-
oauth
public static OslcClientFactory oauth(OAuthStore oauthStore, OAuthHandler oauthHandler)
Returns a factory to create an OSLC client handling OAuth authentication.
An OAuthStore is used to store OAuth approved tokens for a specific user. Instantiate an OAuthStore and OslcClientFactory for each user requesting OSLC resources.
- Parameters:
oauthStore
- the store from where OAuth tokens are requested and kept when approved.oauthHandler
- the handler enabling adapting the support of the OAuth protocol.- Returns:
- a factory to create an OSLC client handling OAuth authentication.
-
oauthTwoLegged
public static OslcClientFactory oauthTwoLegged(FriendProvider friendProvider)
Returns a factory to create a 2-legged OSLC client. Such client enables requesting resources from a remote server provided it supports OAuth 1.0 and that functional users are assigned to consumer keys used by the client.- Parameters:
friendProvider
- provides access to friend applications.- Returns:
- a factory to create a 2-legged OSLC client.
- Since:
- 3.4.0
-
concurrent
public static OslcClientFactory concurrent(OslcClientFactory factory)
Returns a factory to create a thread-safe OSLC client meant to be used with an
Executor
.The returned factory shall be used to instantiate one OslcClient that can safely be shared for parallel requests executions. The OslcClient instantiated by the factory uses a ThreadLocal to ensure one underlying client is used per thread. The OslcClient can safely be used by
Callable
instances executed with anExecutorService
.- Parameters:
factory
- the underlying factory used to create an OSLC client, when a client is first needed for a specific thread.- Returns:
- a factory to create a thread-safe OSLC client meant to be used with an Executor.
-
concurrent
public static OslcClient concurrent(OslcClient client)
Returns a thread-safe OSLC client meant to be used with an
Executor
.The returned OslcClient can safely be shared for parallel requests executions. It uses a ThreadLocal to ensure one underlying client is used per thread. The OslcClient can safely be used by
Callable
instances executed with anExecutorService
.- Parameters:
client
- the OslcClient whose factory can be used to created additional clients (one per thread).- Returns:
- a thread-safe OSLC client.
-
oauth2ClientCredentials
public static OslcClientFactory oauth2ClientCredentials(org.apache.http.auth.Credentials credentials, URI accessTokenUri)
Returns a factory to create an OSLC client handling OAuth 2.0 Client Credentials authentication.
- Parameters:
credentials
- the credentials (client ID and client secret) to use when executing OSLC requests on the server.accessTokenUri
- the URI to validate the credentials and get an access token- Returns:
- a factory to create an OSLC client handling OAuth 2.0 Client Credentials authentication.
- Since:
- 3.3.0
-
-