Class AuthenticatedWebResourceProvider
- java.lang.Object
-
- com.atlassian.confluence.rest.client.authentication.AuthenticatedWebResourceProvider
-
- All Implemented Interfaces:
AutoCloseable
@ExperimentalApi public class AuthenticatedWebResourceProvider extends Object implements AutoCloseable
Provides authenticatedWebResources for Remote API clients.Clients should call
setAuthContext(String, char[])to set the active user before making remote requests, andclearAuthContext()when the user authentication is no longer needed.//TODO make this an interface before making public - CRA-627
-
-
Constructor Summary
Constructors Constructor Description AuthenticatedWebResourceProvider(com.sun.jersey.api.client.Client client, String baseUrl, String path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAuthContext()Clears the current authenticated user, if any.voidclose()static AuthenticatedWebResourceProvidercreateWithNewClient(String baseUrl)Helper method to create new AuthenticatedWebResourceProviders using a default client and no extra base WebResource path.StringgetUsername()com.sun.jersey.api.client.WebResource.BuildernewJsonResource(String path)Returns a new web resource accepting JSON.com.sun.jersey.api.client.WebResourcenewRestWebResource()voidsetAuthContext(String username, char[] password)Authenticates a user to make remote requests with.
-
-
-
Method Detail
-
createWithNewClient
public static AuthenticatedWebResourceProvider createWithNewClient(String baseUrl)
Helper method to create new AuthenticatedWebResourceProviders using a default client and no extra base WebResource path.
-
newRestWebResource
public com.sun.jersey.api.client.WebResource newRestWebResource()
-
newJsonResource
public com.sun.jersey.api.client.WebResource.Builder newJsonResource(String path)
Returns a new web resource accepting JSON.
-
setAuthContext
public void setAuthContext(String username, char[] password)
Authenticates a user to make remote requests with.- Parameters:
username- the login username of the userpassword- the password of the user
-
clearAuthContext
public void clearAuthContext()
Clears the current authenticated user, if any.
-
getUsername
public String getUsername()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-