Package org.javlo.service.social
Class AbstractSocialNetwork
- java.lang.Object
-
- org.javlo.service.social.AbstractSocialNetwork
-
- All Implemented Interfaces:
ISocialNetwork
- Direct Known Subclasses:
Facebook
,Google
,Linkedin
,Pushbullet
,Twitter
public abstract class AbstractSocialNetwork extends Object implements ISocialNetwork
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,String>
data
-
Fields inherited from interface org.javlo.service.social.ISocialNetwork
POPUP_URI_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description AbstractSocialNetwork()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.apache.oltu.oauth2.client.request.OAuthClientRequest
buildAuthenticationRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder builder)
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest
buildTokenRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder builder)
protected void
configureAuthenticationRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder builder, String clientId, ContentContext ctx, boolean popup)
protected void
configureTokenRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder builder, String clientId, String clientSecret, String code)
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder
createAuthenticationRequest()
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder
createTokenRequest()
protected org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse
executeTokenRequest(org.apache.oltu.oauth2.client.OAuthClient oAuthClient, org.apache.oltu.oauth2.client.request.OAuthClientRequest request)
protected void
fillUserInfo(UserInfo userInfo, SocialUser socialUser)
String
getAccessToken(String code, org.apache.oltu.oauth2.client.OAuthClient oAuthClient)
String
getApiKey()
abstract String
getAuthzEndpoint()
String
getClientId()
String
getClientSecret()
Map<String,String>
getData()
String
getLogin()
String
getLoginURL()
String
getRedirectURL()
String
getSigninURL(ContentContext ctx, boolean popup)
protected SocialUser
getSocialUser(String accessToken, org.apache.oltu.oauth2.client.OAuthClient oAuthClient)
SocialUser
getSocialUser(javax.servlet.http.HttpServletRequest request)
protected String
getState(ContentContext ctx)
String
getToken()
abstract String
getTokenEndpoint()
String
getURL()
protected void
login(ContentContext ctx, SocialUser socialUser, boolean admin)
void
performRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean admin)
void
prepare(ContentContext ctx)
prepare social network for renderingvoid
set(String key, String value)
void
setApiKey(String clientSecret)
void
setClientId(String clientId)
void
setClientSecret(String clientSecret)
void
setLogin(String login)
void
setRedirectURL(String redirectURL)
void
setToken(String token)
void
setURL(String url)
void
update(Map map)
update value with a map.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.javlo.service.social.ISocialNetwork
getName
-
-
-
-
Method Detail
-
prepare
public void prepare(ContentContext ctx) throws Exception
Description copied from interface:ISocialNetwork
prepare social network for rendering- Specified by:
prepare
in interfaceISocialNetwork
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
Exception
-
getToken
public String getToken()
- Specified by:
getToken
in interfaceISocialNetwork
-
getLogin
public String getLogin()
- Specified by:
getLogin
in interfaceISocialNetwork
-
getURL
public String getURL()
- Specified by:
getURL
in interfaceISocialNetwork
-
getData
public Map<String,String> getData()
- Specified by:
getData
in interfaceISocialNetwork
-
setToken
public void setToken(String token)
- Specified by:
setToken
in interfaceISocialNetwork
-
setURL
public void setURL(String url)
- Specified by:
setURL
in interfaceISocialNetwork
-
setLogin
public void setLogin(String login)
- Specified by:
setLogin
in interfaceISocialNetwork
-
set
public void set(String key, String value)
- Specified by:
set
in interfaceISocialNetwork
-
update
public void update(Map map)
Description copied from interface:ISocialNetwork
update value with a map.- Specified by:
update
in interfaceISocialNetwork
-
getClientId
public String getClientId()
- Specified by:
getClientId
in interfaceISocialNetwork
-
setClientId
public void setClientId(String clientId)
- Specified by:
setClientId
in interfaceISocialNetwork
-
getClientSecret
public String getClientSecret()
- Specified by:
getClientSecret
in interfaceISocialNetwork
-
setClientSecret
public void setClientSecret(String clientSecret)
- Specified by:
setClientSecret
in interfaceISocialNetwork
-
getApiKey
public String getApiKey()
- Specified by:
getApiKey
in interfaceISocialNetwork
-
setApiKey
public void setApiKey(String clientSecret)
- Specified by:
setApiKey
in interfaceISocialNetwork
-
getState
protected String getState(ContentContext ctx) throws Exception
- Throws:
Exception
-
getAuthzEndpoint
public abstract String getAuthzEndpoint()
-
getTokenEndpoint
public abstract String getTokenEndpoint()
-
getSigninURL
public String getSigninURL(ContentContext ctx, boolean popup) throws Exception
- Specified by:
getSigninURL
in interfaceISocialNetwork
- Throws:
Exception
-
createAuthenticationRequest
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder createAuthenticationRequest()
-
configureAuthenticationRequest
protected void configureAuthenticationRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder builder, String clientId, ContentContext ctx, boolean popup) throws Exception
- Throws:
Exception
-
buildAuthenticationRequest
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest buildAuthenticationRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder builder) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
-
getRedirectURL
public String getRedirectURL()
- Specified by:
getRedirectURL
in interfaceISocialNetwork
-
setRedirectURL
public void setRedirectURL(String redirectURL)
- Specified by:
setRedirectURL
in interfaceISocialNetwork
-
performRedirect
public void performRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean admin)
- Specified by:
performRedirect
in interfaceISocialNetwork
-
getSocialUser
public SocialUser getSocialUser(javax.servlet.http.HttpServletRequest request)
- Specified by:
getSocialUser
in interfaceISocialNetwork
-
getAccessToken
public String getAccessToken(String code, org.apache.oltu.oauth2.client.OAuthClient oAuthClient) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException, org.apache.oltu.oauth2.common.exception.OAuthProblemException
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
org.apache.oltu.oauth2.common.exception.OAuthProblemException
-
executeTokenRequest
protected org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse executeTokenRequest(org.apache.oltu.oauth2.client.OAuthClient oAuthClient, org.apache.oltu.oauth2.client.request.OAuthClientRequest request) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException, org.apache.oltu.oauth2.common.exception.OAuthProblemException
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
org.apache.oltu.oauth2.common.exception.OAuthProblemException
-
createTokenRequest
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder createTokenRequest()
-
configureTokenRequest
protected void configureTokenRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder builder, String clientId, String clientSecret, String code)
-
buildTokenRequest
protected org.apache.oltu.oauth2.client.request.OAuthClientRequest buildTokenRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder builder) throws org.apache.oltu.oauth2.common.exception.OAuthSystemException
- Throws:
org.apache.oltu.oauth2.common.exception.OAuthSystemException
-
getSocialUser
protected SocialUser getSocialUser(String accessToken, org.apache.oltu.oauth2.client.OAuthClient oAuthClient) throws Exception
- Throws:
Exception
-
login
protected void login(ContentContext ctx, SocialUser socialUser, boolean admin) throws UserAllreadyExistException, IOException
-
fillUserInfo
protected void fillUserInfo(UserInfo userInfo, SocialUser socialUser)
-
getLoginURL
public String getLoginURL()
-
-