Class OAuthCMISAuthenticationProvider
- java.lang.Object
-
- org.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider
-
- org.alfresco.cmis.client.authentication.OAuthCMISAuthenticationProvider
-
- All Implemented Interfaces:
Serializable,org.apache.chemistry.opencmis.client.bindings.spi.SessionAwareAuthenticationProvider,org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider
public class OAuthCMISAuthenticationProvider extends org.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProviderAn OpenCMIS OAuth authentication provider. Example connection parameters: org.apache.chemistry.opencmis.binding.spi.type=atompub org.apache.chemistry.opencmis.binding.atompub.url=https://api.alfresco.com/cmis/versions/1.0/atom org.apache.chemistry.opencmis.binding.auth.classname=org.alfresco.cmis.client.authentication.OAuthCMISAuthenticationProvider org.apache.chemistry.opencmis.binding.auth.http.basic=false org.apache.chemistry.opencmis.binding.auth.oauth.accessToken=<access token> org.apache.chemistry.opencmis.binding.compression=true- Author:
- steveglover
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOAuthCMISAuthenticationProvider.AccessToken
-
Field Summary
Fields Modifier and Type Field Description static StringALFRESCO_ACCESS_TOKEN_URLstatic StringALFRESCO_REFRESH_TOKEN_URLstatic StringPARAM_ACCESS_TOKEN
-
Constructor Summary
Constructors Constructor Description OAuthCMISAuthenticationProvider()OAuthCMISAuthenticationProvider(String accessToken)Authenticates with the Alfresco CMIS Public Api with a previously-generated access token (no refresh token support).OAuthCMISAuthenticationProvider(String clientId, String clientSecret, String redirectUrl, String accessTokenUrl, String refreshTokenUrl, String authCode)Authenticates with the Alfresco CMIS Public Api by generating an access token to communicate with the public api.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OAuthCMISAuthenticationProvideralfrescoOAuthProvider(String accessToken)static OAuthCMISAuthenticationProvideralfrescoOAuthProvider(String clientId, String clientSecret, String redirectUrl, String authCode)protected List<String>createBasicAuthHeaderValue(String username, String password)Creates a basic authentication header value from a username and a password.OAuthCMISAuthenticationProvider.AccessTokengetAccessTokenData()protected Map<String,List<String>>getFixedHeaders()Returns the HTTP headers that are sent with all requests.Map<String,List<String>>getHTTPHeaders(String url)ElementgetSOAPHeaders(Object portObject)protected booleanisTrue(String parameterName)Returnstrueif the given parameter exists in the session and is set to true,falseotherwise.voidputResponseHeaders(String url, int statusCode, Map<String,List<String>> headers)voidsetSession(org.apache.chemistry.opencmis.client.bindings.spi.BindingSession session)
-
-
-
Field Detail
-
ALFRESCO_ACCESS_TOKEN_URL
public static final String ALFRESCO_ACCESS_TOKEN_URL
- See Also:
- Constant Field Values
-
ALFRESCO_REFRESH_TOKEN_URL
public static final String ALFRESCO_REFRESH_TOKEN_URL
- See Also:
- Constant Field Values
-
PARAM_ACCESS_TOKEN
public static final String PARAM_ACCESS_TOKEN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OAuthCMISAuthenticationProvider
public OAuthCMISAuthenticationProvider()
-
OAuthCMISAuthenticationProvider
public OAuthCMISAuthenticationProvider(String accessToken)
Authenticates with the Alfresco CMIS Public Api with a previously-generated access token (no refresh token support).- Parameters:
accessToken- The access token
-
OAuthCMISAuthenticationProvider
public OAuthCMISAuthenticationProvider(String clientId, String clientSecret, String redirectUrl, String accessTokenUrl, String refreshTokenUrl, String authCode)
Authenticates with the Alfresco CMIS Public Api by generating an access token to communicate with the public api. Refresh support is provided.- Parameters:
clientId- Client IDclientSecret- secretredirectUrl- redirect URLaccessTokenUrl- access token URLrefreshTokenUrl- refresh token URLauthCode- Authcode
-
-
Method Detail
-
alfrescoOAuthProvider
public static OAuthCMISAuthenticationProvider alfrescoOAuthProvider(String accessToken)
-
alfrescoOAuthProvider
public static OAuthCMISAuthenticationProvider alfrescoOAuthProvider(String clientId, String clientSecret, String redirectUrl, String authCode)
-
getAccessTokenData
public OAuthCMISAuthenticationProvider.AccessToken getAccessTokenData()
-
setSession
public void setSession(org.apache.chemistry.opencmis.client.bindings.spi.BindingSession session)
- Specified by:
setSessionin interfaceorg.apache.chemistry.opencmis.client.bindings.spi.SessionAwareAuthenticationProvider- Overrides:
setSessionin classorg.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider
-
getHTTPHeaders
public Map<String,List<String>> getHTTPHeaders(String url)
- Specified by:
getHTTPHeadersin interfaceorg.apache.chemistry.opencmis.commons.spi.AuthenticationProvider- Overrides:
getHTTPHeadersin classorg.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider
-
putResponseHeaders
public void putResponseHeaders(String url, int statusCode, Map<String,List<String>> headers)
- Specified by:
putResponseHeadersin interfaceorg.apache.chemistry.opencmis.commons.spi.AuthenticationProvider- Overrides:
putResponseHeadersin classorg.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider
-
getSOAPHeaders
public Element getSOAPHeaders(Object portObject)
- Specified by:
getSOAPHeadersin interfaceorg.apache.chemistry.opencmis.commons.spi.AuthenticationProvider- Overrides:
getSOAPHeadersin classorg.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider
-
getFixedHeaders
protected Map<String,List<String>> getFixedHeaders()
Returns the HTTP headers that are sent with all requests. The returned map is mutable but not synchronized!- Returns:
- fixedHeaders
-
createBasicAuthHeaderValue
protected List<String> createBasicAuthHeaderValue(String username, String password)
Creates a basic authentication header value from a username and a password.- Parameters:
username- usernamepassword- password- Returns:
- List<String>
-
isTrue
protected boolean isTrue(String parameterName)
Returnstrueif the given parameter exists in the session and is set to true,falseotherwise.- Parameters:
parameterName- Parameter name- Returns:
- True/False
-
-