Class OslcClients


  • public class OslcClients
    extends Object
    Provides facilities to instantiate HTTP and OSLC clients.
    • 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.
      • 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.
      • 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 an ExecutorService.

        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 an ExecutorService.

        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