An OSLC client wraps an HTTP client and allows executing requests on OSLC resources.
An OSLC client is the entry point to instantiate for querying and updating content in an OSLC application. The OslcClients class provides methods for instantiating OSLC clients. The type of OSLC client to instantiate depends on the authentication supported by the OSLC remote application.
This section assumes you already configured your MDAccess for OSLC license.
For OSLC applications that expect a user ID and password to be present as BASIC authentication header, use the OslcClients.basic() method to obtain an OSLC client.
Below is an example code of using the Basic OSLC client:
OslcClient client = OslcClients.basic(new UsernamePasswordCredentials("myUser", "myPassword")).create(); ServiceProviderCatalog catalog = new GetServiceProviderCatalog(client, URI.create("http://myserver/myCatalog")).get();
For Jazz based applications, use the OslcClients.jazzForm() method to obtain an OSLC client.
Below is an example code of using the Jazz Form OSLC client:
OslcClient client = OslcClients.jazzForm(new UsernamePasswordCredentials("myUser", "myPassword")).create(); ServiceProviderCatalog catalog = new GetServiceProviderCatalog(client, URI.create("http://myserver/myCatalog")).get();
For OSLC applications which support OAuth, use the OslcClients.oauth() method to obtain an OSLC client.
Below is an example code of using the Jazz Form OSLC client:
Friend friend = Friends.createFriend(new URI("http://myserver/rootservices"), "myConsumerToken", "myConsumerSecret"); OAuthHandler oautHandler = ...; OslcClient client = OslcClients.oauth(new OAuthStore(friend), oautHandler).create(); ServiceProviderCatalog catalog = new GetServiceProviderCatalog(client, URI.create("http://myserver/myCatalog")).get();