Class NuxeoOAuth2ServiceProvider
- java.lang.Object
-
- org.nuxeo.ecm.platform.oauth2.providers.NuxeoOAuth2ServiceProvider
-
- All Implemented Interfaces:
OAuth2ServiceProvider
- Direct Known Subclasses:
AbstractOAuth2UserEmailProvider
public class NuxeoOAuth2ServiceProvider extends Object implements OAuth2ServiceProvider
-
-
Field Summary
Fields Modifier and Type Field Description static String
CODE_URL_PARAMETER
protected String
description
static String
ERROR_URL_PARAMETER
protected static com.google.api.client.http.HttpTransport
HTTP_TRANSPORT
Global instance of the HTTP transport.protected Long
id
protected static com.google.api.client.json.JsonFactory
JSON_FACTORY
Global instance of the JSON factory.static String
SCHEMA
protected String
serviceName
protected OAuth2ServiceUserStore
serviceUserStore
protected OAuth2TokenStore
tokenStore
protected String
userAuthorizationURL
-
Constructor Summary
Constructors Constructor Description NuxeoOAuth2ServiceProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getAuthorizationCode(javax.servlet.http.HttpServletRequest request)
com.google.api.client.auth.oauth2.AuthorizationCodeFlow
getAuthorizationCodeFlow()
String
getAuthorizationServerURL()
String
getAuthorizationUrl(String serverURL)
Returns the authorization URLString
getAuthorizationUrl(javax.servlet.http.HttpServletRequest request)
Returns the authorization URLprotected String
getCallbackUrl(String serverURL)
protected String
getCallbackUrl(javax.servlet.http.HttpServletRequest request)
String
getClientId()
String
getClientSecret()
OAuth2TokenStore
getCredentialDataStore()
String
getDescription()
protected String
getError(javax.servlet.http.HttpServletRequest request)
Long
getId()
protected String
getOrCreateServiceUser(javax.servlet.http.HttpServletRequest request, String accessToken)
Retrieves or creates a service user.List<String>
getScopes()
String
getServiceName()
protected String
getServiceUserId(String key)
Returns the userId to use for token entries.protected OAuth2ServiceUserStore
getServiceUserStore()
String
getTokenServerURL()
String
getUserAuthorizationURL()
com.google.api.client.auth.oauth2.Credential
handleAuthorizationCallback(javax.servlet.http.HttpServletRequest request)
Handles the authorization response and stores the token(s)boolean
isEnabled()
boolean
isProviderAvailable()
com.google.api.client.auth.oauth2.Credential
loadCredential(String user)
Load a credential from the token store with the userId returned by getServiceUser() as key.void
setAuthorizationServerURL(String authorizationServerURL)
void
setClientId(String clientId)
void
setClientSecret(String clientSecret)
void
setDescription(String description)
void
setEnabled(Boolean enabled)
void
setId(Long id)
void
setScopes(String... scopes)
void
setServiceName(String serviceName)
void
setTokenServerURL(String tokenServerURL)
void
setUserAuthorizationURL(String userAuthorizationURL)
-
-
-
Field Detail
-
SCHEMA
public static final String SCHEMA
- See Also:
- Constant Field Values
-
HTTP_TRANSPORT
protected static final com.google.api.client.http.HttpTransport HTTP_TRANSPORT
Global instance of the HTTP transport.
-
JSON_FACTORY
protected static final com.google.api.client.json.JsonFactory JSON_FACTORY
Global instance of the JSON factory.
-
CODE_URL_PARAMETER
public static final String CODE_URL_PARAMETER
- See Also:
- Constant Field Values
-
ERROR_URL_PARAMETER
public static final String ERROR_URL_PARAMETER
- See Also:
- Constant Field Values
-
serviceName
protected String serviceName
-
id
protected Long id
-
description
protected String description
-
userAuthorizationURL
protected String userAuthorizationURL
-
serviceUserStore
protected OAuth2ServiceUserStore serviceUserStore
-
tokenStore
protected OAuth2TokenStore tokenStore
-
-
Method Detail
-
getAuthorizationUrl
public String getAuthorizationUrl(javax.servlet.http.HttpServletRequest request)
Description copied from interface:OAuth2ServiceProvider
Returns the authorization URL- Specified by:
getAuthorizationUrl
in interfaceOAuth2ServiceProvider
-
getAuthorizationUrl
public String getAuthorizationUrl(String serverURL)
Description copied from interface:OAuth2ServiceProvider
Returns the authorization URL- Specified by:
getAuthorizationUrl
in interfaceOAuth2ServiceProvider
-
getCallbackUrl
protected String getCallbackUrl(javax.servlet.http.HttpServletRequest request)
-
handleAuthorizationCallback
public com.google.api.client.auth.oauth2.Credential handleAuthorizationCallback(javax.servlet.http.HttpServletRequest request)
Description copied from interface:OAuth2ServiceProvider
Handles the authorization response and stores the token(s)- Specified by:
handleAuthorizationCallback
in interfaceOAuth2ServiceProvider
-
loadCredential
public com.google.api.client.auth.oauth2.Credential loadCredential(String user)
Load a credential from the token store with the userId returned by getServiceUser() as key.- Specified by:
loadCredential
in interfaceOAuth2ServiceProvider
-
getServiceUserId
protected String getServiceUserId(String key)
Returns the userId to use for token entries. Should be overriden by subclasses wanting to rely on a different field as key.
-
getOrCreateServiceUser
protected String getOrCreateServiceUser(javax.servlet.http.HttpServletRequest request, String accessToken) throws IOException
Retrieves or creates a service user. Should be overriden by subclasses wanting to rely on a different field as key.- Throws:
IOException
-
getAuthorizationCodeFlow
public com.google.api.client.auth.oauth2.AuthorizationCodeFlow getAuthorizationCodeFlow()
-
getServiceUserStore
protected OAuth2ServiceUserStore getServiceUserStore()
-
getCredentialDataStore
public OAuth2TokenStore getCredentialDataStore()
-
getError
protected String getError(javax.servlet.http.HttpServletRequest request)
-
getAuthorizationCode
protected String getAuthorizationCode(javax.servlet.http.HttpServletRequest request)
-
getServiceName
public String getServiceName()
- Specified by:
getServiceName
in interfaceOAuth2ServiceProvider
-
getId
public Long getId()
- Specified by:
getId
in interfaceOAuth2ServiceProvider
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfaceOAuth2ServiceProvider
-
getTokenServerURL
public String getTokenServerURL()
- Specified by:
getTokenServerURL
in interfaceOAuth2ServiceProvider
-
getUserAuthorizationURL
public String getUserAuthorizationURL()
- Specified by:
getUserAuthorizationURL
in interfaceOAuth2ServiceProvider
-
getClientId
public String getClientId()
- Specified by:
getClientId
in interfaceOAuth2ServiceProvider
-
getClientSecret
public String getClientSecret()
- Specified by:
getClientSecret
in interfaceOAuth2ServiceProvider
-
getScopes
public List<String> getScopes()
- Specified by:
getScopes
in interfaceOAuth2ServiceProvider
-
getAuthorizationServerURL
public String getAuthorizationServerURL()
- Specified by:
getAuthorizationServerURL
in interfaceOAuth2ServiceProvider
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabled
in interfaceOAuth2ServiceProvider
-
setEnabled
public void setEnabled(Boolean enabled)
- Specified by:
setEnabled
in interfaceOAuth2ServiceProvider
-
isProviderAvailable
public boolean isProviderAvailable()
- Specified by:
isProviderAvailable
in interfaceOAuth2ServiceProvider
-
setServiceName
public void setServiceName(String serviceName)
- Specified by:
setServiceName
in interfaceOAuth2ServiceProvider
-
setId
public void setId(Long id)
- Specified by:
setId
in interfaceOAuth2ServiceProvider
-
setDescription
public void setDescription(String description)
- Specified by:
setDescription
in interfaceOAuth2ServiceProvider
-
setTokenServerURL
public void setTokenServerURL(String tokenServerURL)
- Specified by:
setTokenServerURL
in interfaceOAuth2ServiceProvider
-
setUserAuthorizationURL
public void setUserAuthorizationURL(String userAuthorizationURL)
- Specified by:
setUserAuthorizationURL
in interfaceOAuth2ServiceProvider
-
setAuthorizationServerURL
public void setAuthorizationServerURL(String authorizationServerURL)
- Specified by:
setAuthorizationServerURL
in interfaceOAuth2ServiceProvider
-
setClientId
public void setClientId(String clientId)
- Specified by:
setClientId
in interfaceOAuth2ServiceProvider
-
setClientSecret
public void setClientSecret(String clientSecret)
- Specified by:
setClientSecret
in interfaceOAuth2ServiceProvider
-
setScopes
public void setScopes(String... scopes)
- Specified by:
setScopes
in interfaceOAuth2ServiceProvider
-
-