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 StringCODE_URL_PARAMETERprotected Stringdescriptionstatic StringERROR_URL_PARAMETERprotected static com.google.api.client.http.HttpTransportHTTP_TRANSPORTGlobal instance of the HTTP transport.protected Longidprotected static com.google.api.client.json.JsonFactoryJSON_FACTORYGlobal instance of the JSON factory.static StringSCHEMAprotected StringserviceNameprotected OAuth2ServiceUserStoreserviceUserStoreprotected OAuth2TokenStoretokenStoreprotected StringuserAuthorizationURL
-
Constructor Summary
Constructors Constructor Description NuxeoOAuth2ServiceProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetAuthorizationCode(javax.servlet.http.HttpServletRequest request)com.google.api.client.auth.oauth2.AuthorizationCodeFlowgetAuthorizationCodeFlow()StringgetAuthorizationServerURL()StringgetAuthorizationUrl(String serverURL)Returns the authorization URLStringgetAuthorizationUrl(javax.servlet.http.HttpServletRequest request)Returns the authorization URLprotected StringgetCallbackUrl(String serverURL)protected StringgetCallbackUrl(javax.servlet.http.HttpServletRequest request)StringgetClientId()StringgetClientSecret()OAuth2TokenStoregetCredentialDataStore()StringgetDescription()protected StringgetError(javax.servlet.http.HttpServletRequest request)LonggetId()protected StringgetOrCreateServiceUser(javax.servlet.http.HttpServletRequest request, String accessToken)Retrieves or creates a service user.List<String>getScopes()StringgetServiceName()protected StringgetServiceUserId(String key)Returns the userId to use for token entries.protected OAuth2ServiceUserStoregetServiceUserStore()StringgetTokenServerURL()StringgetUserAuthorizationURL()com.google.api.client.auth.oauth2.CredentialhandleAuthorizationCallback(javax.servlet.http.HttpServletRequest request)Handles the authorization response and stores the token(s)booleanisEnabled()booleanisProviderAvailable()com.google.api.client.auth.oauth2.CredentialloadCredential(String user)Load a credential from the token store with the userId returned by getServiceUser() as key.voidsetAuthorizationServerURL(String authorizationServerURL)voidsetClientId(String clientId)voidsetClientSecret(String clientSecret)voidsetDescription(String description)voidsetEnabled(Boolean enabled)voidsetId(Long id)voidsetScopes(String... scopes)voidsetServiceName(String serviceName)voidsetTokenServerURL(String tokenServerURL)voidsetUserAuthorizationURL(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:OAuth2ServiceProviderReturns the authorization URL- Specified by:
getAuthorizationUrlin interfaceOAuth2ServiceProvider
-
getAuthorizationUrl
public String getAuthorizationUrl(String serverURL)
Description copied from interface:OAuth2ServiceProviderReturns the authorization URL- Specified by:
getAuthorizationUrlin 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:OAuth2ServiceProviderHandles the authorization response and stores the token(s)- Specified by:
handleAuthorizationCallbackin 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:
loadCredentialin 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:
getServiceNamein interfaceOAuth2ServiceProvider
-
getId
public Long getId()
- Specified by:
getIdin interfaceOAuth2ServiceProvider
-
getDescription
public String getDescription()
- Specified by:
getDescriptionin interfaceOAuth2ServiceProvider
-
getTokenServerURL
public String getTokenServerURL()
- Specified by:
getTokenServerURLin interfaceOAuth2ServiceProvider
-
getUserAuthorizationURL
public String getUserAuthorizationURL()
- Specified by:
getUserAuthorizationURLin interfaceOAuth2ServiceProvider
-
getClientId
public String getClientId()
- Specified by:
getClientIdin interfaceOAuth2ServiceProvider
-
getClientSecret
public String getClientSecret()
- Specified by:
getClientSecretin interfaceOAuth2ServiceProvider
-
getScopes
public List<String> getScopes()
- Specified by:
getScopesin interfaceOAuth2ServiceProvider
-
getAuthorizationServerURL
public String getAuthorizationServerURL()
- Specified by:
getAuthorizationServerURLin interfaceOAuth2ServiceProvider
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceOAuth2ServiceProvider
-
setEnabled
public void setEnabled(Boolean enabled)
- Specified by:
setEnabledin interfaceOAuth2ServiceProvider
-
isProviderAvailable
public boolean isProviderAvailable()
- Specified by:
isProviderAvailablein interfaceOAuth2ServiceProvider
-
setServiceName
public void setServiceName(String serviceName)
- Specified by:
setServiceNamein interfaceOAuth2ServiceProvider
-
setId
public void setId(Long id)
- Specified by:
setIdin interfaceOAuth2ServiceProvider
-
setDescription
public void setDescription(String description)
- Specified by:
setDescriptionin interfaceOAuth2ServiceProvider
-
setTokenServerURL
public void setTokenServerURL(String tokenServerURL)
- Specified by:
setTokenServerURLin interfaceOAuth2ServiceProvider
-
setUserAuthorizationURL
public void setUserAuthorizationURL(String userAuthorizationURL)
- Specified by:
setUserAuthorizationURLin interfaceOAuth2ServiceProvider
-
setAuthorizationServerURL
public void setAuthorizationServerURL(String authorizationServerURL)
- Specified by:
setAuthorizationServerURLin interfaceOAuth2ServiceProvider
-
setClientId
public void setClientId(String clientId)
- Specified by:
setClientIdin interfaceOAuth2ServiceProvider
-
setClientSecret
public void setClientSecret(String clientSecret)
- Specified by:
setClientSecretin interfaceOAuth2ServiceProvider
-
setScopes
public void setScopes(String... scopes)
- Specified by:
setScopesin interfaceOAuth2ServiceProvider
-
-