Class UserContext
- java.lang.Object
-
- org.vx68k.bitbucket.api.client.webapp.UserContext
-
- All Implemented Interfaces:
Serializable
@Named @SessionScoped public class UserContext extends Object implements Serializable
Session-scoped bean for the current user of the session.To enable authentication by OAuth, the deployment descriptor must be configured as follows:
<env-entry> <env-entry-name>bitbucketClientId</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <lookup-name>java:global/env/bitbucketClientId</lookup-name> </env-entry> <env-entry> <env-entry-name>bitbucketClientSecret</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <lookup-name>java:global/env/bitbucketClientSecret</lookup-name> </env-entry>
- Since:
- 5.0
- Author:
- Kaz Nishimura
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringBITBUCKET_CLIENT_IDProperty key for the OAuth client identifier.static StringBITBUCKET_CLIENT_SECRETProperty key for the OAuth client secret.
-
Constructor Summary
Constructors Constructor Description UserContext()Constructs this object with no parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(String errorDescription, String state)Aborts the current authorization flow.booleanequals(Object object)BitbucketClientgetBitbucketClient()Returns theBitbucketClientobject.StringgetBitbucketClientId()Returns the OAuth client identifier for the Bitbucket API.BitbucketUsergetLoggedInUser()Returns the logged-in user.protected static URIgetOrigin(ExternalContext externalContext)Constructs the origin of the server.inthashCode()booleanisLoggedIn()Returnstrueif the current user is logged in.Stringlogin()Performs a login action by redirecting the user agent to the authorization endpoint.voidlogin(String code, String state)Continues the current authorization flow to login.Stringlogout()Performs a logout action by clearing the current Bitbucket service.voidsetBitbucketClientId(String value)Sets the OAuth client identifier for the Bitbucket API.voidsetBitbucketClientSecret(String value)Sets the OAuth client secret for the Bitbucket API.
-
-
-
Field Detail
-
BITBUCKET_CLIENT_ID
public static final String BITBUCKET_CLIENT_ID
Property key for the OAuth client identifier.- See Also:
- Constant Field Values
-
BITBUCKET_CLIENT_SECRET
public static final String BITBUCKET_CLIENT_SECRET
Property key for the OAuth client secret.- See Also:
- Constant Field Values
-
-
Method Detail
-
getBitbucketClient
public BitbucketClient getBitbucketClient()
Returns theBitbucketClientobject.- Returns:
- the
BitbucketClientobject
-
getBitbucketClientId
public String getBitbucketClientId()
Returns the OAuth client identifier for the Bitbucket API. The return value may benullif not configured.- Returns:
- the OAuth client identifier for the Bitbucket API, or
null
-
setBitbucketClientId
public void setBitbucketClientId(String value)
Sets the OAuth client identifier for the Bitbucket API.- Parameters:
value-Stringvalue to which the OAuth client identifier shall be set
-
setBitbucketClientSecret
public void setBitbucketClientSecret(String value)
Sets the OAuth client secret for the Bitbucket API.- Parameters:
value-Stringvalue to which the OAuth client secret shall be set
-
getLoggedInUser
public BitbucketUser getLoggedInUser()
Returns the logged-in user.- Returns:
- the logged-in user
-
isLoggedIn
public boolean isLoggedIn()
Returnstrueif the current user is logged in.- Returns:
trueif logged in, orfalseotherwise
-
getOrigin
protected static URI getOrigin(ExternalContext externalContext)
Constructs the origin of the server.- Parameters:
externalContext-ExternalContextobject- Returns:
URIobject of the origin
-
login
public String login()
Performs a login action by redirecting the user agent to the authorization endpoint.- Returns:
null
-
logout
public String logout()
Performs a logout action by clearing the current Bitbucket service.- Returns:
"home"- Since:
- 2.0
-
login
public void login(String code, String state)
Continues the current authorization flow to login.- Parameters:
code- an authorization codestate- an opaque state string
-
abort
public void abort(String errorDescription, String state)
Aborts the current authorization flow.- Parameters:
errorDescription- an error descriptionstate- an opaque state string
-
-