org.jboss.reliance.identity
Class Identity

java.lang.Object
  extended by org.jboss.reliance.identity.Identity

public class Identity
extends Object

Simple identity.

Author:
Shane Bryzak, Ales Justin

Field Summary
protected static org.jboss.logging.Logger log
           
static String ROLES_GROUP
           
 
Constructor Summary
Identity()
           
 
Method Summary
 boolean addRole(String role)
          Adds a role to the user's subject, and their security context
 void authenticate()
          Authenticate.
 void authenticate(LoginContext loginContext)
          Authenticate.
 void create()
           
protected  CallbackHandler getDefaultCallbackHandler()
          Creates a callback handler that can handle a standard username/password callback, using the username and password properties.
 String getJaasConfigName()
          Get the jaas config name.
protected  LoginContext getLoginContext()
          Get LoginContext.
 String getPassword()
          Get the password.
 Principal getPrincipal()
          Get the principal.
 Subject getSubject()
          Get the subject.
 String getUsername()
          Get the username.
 boolean hasRole(String role)
          Checks if the authenticated Identity is a member of the specified role.
 boolean isCredentialsSet()
          Are credential set.
 boolean isLoggedIn()
          Is logged in.
 boolean isLoggedIn(boolean attemptLogin)
          Is logged in.
 boolean login()
           
 void logout()
          Logout.
protected  void postAuthenticate()
          Post authentificate.
protected  void preAuthenticate()
          PreAuthentificate.
 void quietLogin()
          Attempts a quiet login, suppressing any login exceptions and not creating any faces messages.
 void removeRole(String role)
          Removes a role from the user's subject and their security context
 void setConfiguration(Configuration configuration)
          Set the configuration.
 void setJaasConfigName(String jaasConfigName)
          Set the jaas config name.
 void setPassword(String password)
          Set the password.
 void setUsername(String username)
          Set the username.
protected  void unAuthenticate()
          Removes all Role objects from the security context, removes the "Roles" group from the user's subject.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.jboss.logging.Logger log

ROLES_GROUP

public static final String ROLES_GROUP
See Also:
Constant Field Values
Constructor Detail

Identity

public Identity()
Method Detail

create

public void create()

login

public boolean login()

logout

public void logout()
Logout.


isCredentialsSet

public boolean isCredentialsSet()
Are credential set.

Returns:
true if credentials set

quietLogin

public void quietLogin()
Attempts a quiet login, suppressing any login exceptions and not creating any faces messages. This method is intended to be used primarily as an internal API call, however has been made public for convenience.


authenticate

public void authenticate()
                  throws LoginException
Authenticate.

Throws:
LoginException - for any login exception

authenticate

public void authenticate(LoginContext loginContext)
                  throws LoginException
Authenticate.

Parameters:
loginContext - the login exception
Throws:
LoginException - for any login exception

preAuthenticate

protected void preAuthenticate()
PreAuthentificate.


postAuthenticate

protected void postAuthenticate()
Post authentificate.


unAuthenticate

protected void unAuthenticate()
Removes all Role objects from the security context, removes the "Roles" group from the user's subject.


isLoggedIn

public boolean isLoggedIn()
Is logged in.

Returns:
true if logged in

isLoggedIn

public boolean isLoggedIn(boolean attemptLogin)
Is logged in.

Parameters:
attemptLogin - try to attempt login
Returns:
true if logged in

hasRole

public boolean hasRole(String role)
Checks if the authenticated Identity is a member of the specified role.

Parameters:
role - String The name of the role to check
Returns:
boolean True if the user is a member of the specified role

addRole

public boolean addRole(String role)
Adds a role to the user's subject, and their security context

Parameters:
role - The name of the role to add
Returns:
true if logged in

removeRole

public void removeRole(String role)
Removes a role from the user's subject and their security context

Parameters:
role - The name of the role to remove

getLoginContext

protected LoginContext getLoginContext()
                                throws LoginException
Get LoginContext.

Returns:
the login context
Throws:
LoginException - for any login exception

getDefaultCallbackHandler

protected CallbackHandler getDefaultCallbackHandler()
Creates a callback handler that can handle a standard username/password callback, using the username and password properties.

Returns:
CallbackHandler instance

getUsername

public String getUsername()
Get the username.

Returns:
username

setUsername

public void setUsername(String username)
Set the username.

Parameters:
username - the username

getPassword

public String getPassword()
Get the password.

Returns:
the password

setPassword

public void setPassword(String password)
Set the password.

Parameters:
password - the password

getPrincipal

public Principal getPrincipal()
Get the principal.

Returns:
the principal

getSubject

public Subject getSubject()
Get the subject.

Returns:
the subject

getJaasConfigName

public String getJaasConfigName()
Get the jaas config name.

Returns:
the jaas config name

setJaasConfigName

public void setJaasConfigName(String jaasConfigName)
Set the jaas config name.

Parameters:
jaasConfigName - the jass config name

setConfiguration

public void setConfiguration(Configuration configuration)
Set the configuration.

Parameters:
configuration - the configuration


Copyright © 2008 JBoss Inc.. All Rights Reserved.