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 String
BITBUCKET_CLIENT_ID
Property key for the OAuth client identifier.static String
BITBUCKET_CLIENT_SECRET
Property 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 void
abort(String errorDescription, String state)
Aborts the current authorization flow.boolean
equals(Object object)
BitbucketClient
getBitbucketClient()
Returns theBitbucketClient
object.String
getBitbucketClientId()
Returns the OAuth client identifier for the Bitbucket API.BitbucketUser
getLoggedInUser()
Returns the logged-in user.protected static URI
getOrigin(ExternalContext externalContext)
Constructs the origin of the server.int
hashCode()
boolean
isLoggedIn()
Returnstrue
if the current user is logged in.String
login()
Performs a login action by redirecting the user agent to the authorization endpoint.void
login(String code, String state)
Continues the current authorization flow to login.String
logout()
Performs a logout action by clearing the current Bitbucket service.void
setBitbucketClientId(String value)
Sets the OAuth client identifier for the Bitbucket API.void
setBitbucketClientSecret(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 theBitbucketClient
object.- Returns:
- the
BitbucketClient
object
-
getBitbucketClientId
public String getBitbucketClientId()
Returns the OAuth client identifier for the Bitbucket API. The return value may benull
if 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
-String
value 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
-String
value 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()
Returnstrue
if the current user is logged in.- Returns:
true
if logged in, orfalse
otherwise
-
getOrigin
protected static URI getOrigin(ExternalContext externalContext)
Constructs the origin of the server.- Parameters:
externalContext
-ExternalContext
object- Returns:
URI
object 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
-
-