public abstract class Login extends Object
Constructor and Description |
---|
Login() |
Modifier and Type | Method and Description |
---|---|
Login |
addScopes(String... scopes)
Adds the given scopes to the OAuth2 login request.
|
AsyncResource<Login> |
connect()
Connects to the login service asynchronously, automatically logging in
if not yet logged in.
|
protected Oauth2 |
createOauth2()
Creates the oauth2 to be used to login in case no native login is available
for this service.
|
void |
doLogin()
Logs in the user.
|
void |
doLogin(LoginCallback callback)
Initiates login using the given single-use callback.
|
void |
doLogout()
Logs out the current user
|
AccessToken |
getAccessToken()
The AccessToken of this service
|
abstract boolean |
isNativeLoginSupported()
Returns true if this service supports native login.
|
boolean |
isPreferRedirectPrompt()
A flag used by the javascript port to indicate that the login will use a redirect
for the prompt instead of a popup.
|
boolean |
isUserLoggedIn()
Indicates if the user is currently logged in
|
boolean |
nativeIsLoggedIn()
Indicates if the user is currently logged in.
|
void |
nativelogin()
Logs in the current user natively.
|
void |
nativeLogout()
Logs out the current user natively.
|
void |
setAccessToken(AccessToken token)
Sets the Login access token
|
void |
setCallback(LoginCallback lc)
Sets the login callback that will receive event callback notification
from the API
|
void |
setClientId(String id)
The client id (appid) which asks to connect
|
void |
setClientSecret(String secret)
The client secret
|
void |
setOauth2URL(String oauth2URL)
The oauth2 URL
|
void |
setPreferRedirectPrompt(boolean preferRedirectPrompt)
A flag used by the javascript port to indicate that the login will use a redirect
for the prompt instead of a popup.
|
void |
setRedirectURI(String URI)
The redirect URI
|
void |
setScope(String scope)
The authentication scope
|
void |
validateToken()
This method tries to validate the last access token if exists, if the
last token is not valid anymore it will try to login the user in order to
get a fresh token
The method blocks until a valid token has been granted
|
protected abstract boolean |
validateToken(String token)
Returns true if the previous granted access token is still valid otherwise
false.
|
public Login addScopes(String... scopes)
scopes
- Scopes to add.setScope(java.lang.String)
public AsyncResource<Login> connect()
public void doLogin(LoginCallback callback)
callback
- Callback to be called if login succeeds or fails.public void doLogin()
public void doLogout()
public boolean isUserLoggedIn()
public boolean nativeIsLoggedIn()
public void nativelogin()
public void nativeLogout()
public abstract boolean isNativeLoginSupported()
public AccessToken getAccessToken()
public void validateToken() throws IOException
IOException
protected abstract boolean validateToken(String token)
token
- the access token to checkpublic void setAccessToken(AccessToken token)
public void setCallback(LoginCallback lc)
lc
- the login callback or null to remove the existing login
callbackpublic void setClientId(String id)
clientId
- public void setClientSecret(String secret)
clientSecret
- public void setRedirectURI(String URI)
redirectURI
- public void setScope(String scope)
public void setOauth2URL(String oauth2URL)
protected Oauth2 createOauth2()
public boolean isPreferRedirectPrompt()
public void setPreferRedirectPrompt(boolean preferRedirectPrompt)
preferRedirectPrompt
- the preferRedirectPrompt to set