Keel 2.1RC2

org.keel.util.test
Class TestUserEnvironment

java.lang.Object
  extended byorg.keel.util.test.TestUserEnvironment
All Implemented Interfaces:
UserEnvironment

class TestUserEnvironment
extends java.lang.Object
implements UserEnvironment

A custom implementation of UserEnvironment that can be used for unit-testing purposes.


Field Summary
private  java.util.Map attribs
           
private  java.util.List groups
           
private  java.lang.String loginName
           
private  java.lang.String myDomain
           
private  int uid
           
 
Fields inherited from interface org.keel.services.authentication.UserEnvironment
ANONYMOUS_DOMAIN, ANONYMOUS_GROUPNAME, ANONYMOUS_LOGINNAME, ANONYMOUS_UID, ANONYMOUS_USERDESC, CONTEXT_KEY
 
Constructor Summary
TestUserEnvironment()
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
           
 java.lang.String getDomain()
          Get the DomainPrincipal
 java.util.List getGroups()
          Get the GroupPrincipals
 javax.security.auth.login.LoginContext getLoginContext()
          The login context in this env.
 java.lang.String getLoginName()
          Get the LoginPrincipal
 javax.security.auth.Subject getSubject()
          The JAAS subject from the login context
 int getUid()
          Get the UidPrincipal
 java.lang.String getUserDescrip()
          Get the UserDescripPrincipal
 void reset()
          Used by logout functions to reset the SUbject back to "anonymous"
 void setAttribute(java.lang.String name, java.lang.Object attrib)
           
 void setDomain(java.lang.String newDomain)
           
 void setGroups(java.util.List newGroups)
           
 void setLoginContext(javax.security.auth.login.LoginContext lc)
          After succsful login, store the login context for later use by at least the logout function.
 void setLoginName(java.lang.String newName)
           
 void setUid(int newUid)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loginName

private java.lang.String loginName

groups

private java.util.List groups

uid

private int uid

attribs

private java.util.Map attribs

myDomain

private java.lang.String myDomain
Constructor Detail

TestUserEnvironment

public TestUserEnvironment()
Method Detail

toString

public java.lang.String toString()

setLoginContext

public void setLoginContext(javax.security.auth.login.LoginContext lc)
                     throws AuthorizationException
Description copied from interface: UserEnvironment
After succsful login, store the login context for later use by at least the logout function.

Specified by:
setLoginContext in interface UserEnvironment
Parameters:
lc - The user's JAAS login context
Throws:
AuthorizationException

getLoginContext

public javax.security.auth.login.LoginContext getLoginContext()
                                                       throws AuthorizationException
Description copied from interface: UserEnvironment
The login context in this env.

Specified by:
getLoginContext in interface UserEnvironment
Returns:
The login context
Throws:
AuthorizationException

getSubject

public javax.security.auth.Subject getSubject()
                                       throws AuthorizationException
Description copied from interface: UserEnvironment
The JAAS subject from the login context

Specified by:
getSubject in interface UserEnvironment
Returns:
JAAS Subject
Throws:
AuthorizationException

getLoginName

public java.lang.String getLoginName()
                              throws AuthorizationException
Description copied from interface: UserEnvironment
Get the LoginPrincipal

Specified by:
getLoginName in interface UserEnvironment
Returns:
the login name
Throws:
AuthorizationException

setLoginName

public void setLoginName(java.lang.String newName)

getDomain

public java.lang.String getDomain()
                           throws AuthorizationException
Description copied from interface: UserEnvironment
Get the DomainPrincipal

Specified by:
getDomain in interface UserEnvironment
Returns:
The Keel domain name
Throws:
AuthorizationException

setDomain

public void setDomain(java.lang.String newDomain)

getUserDescrip

public java.lang.String getUserDescrip()
                                throws AuthorizationException
Description copied from interface: UserEnvironment
Get the UserDescripPrincipal

Specified by:
getUserDescrip in interface UserEnvironment
Returns:
A description of the user
Throws:
AuthorizationException

getUid

public int getUid()
           throws AuthorizationException
Description copied from interface: UserEnvironment
Get the UidPrincipal

Specified by:
getUid in interface UserEnvironment
Returns:
The UID
Throws:
AuthorizationException

setUid

public void setUid(int newUid)

getGroups

public java.util.List getGroups()
                         throws AuthorizationException
Description copied from interface: UserEnvironment
Get the GroupPrincipals

Specified by:
getGroups in interface UserEnvironment
Returns:
The list of groups user belongs to
Throws:
AuthorizationException

setGroups

public void setGroups(java.util.List newGroups)

reset

public void reset()
           throws AuthorizationException
Description copied from interface: UserEnvironment
Used by logout functions to reset the SUbject back to "anonymous"

Specified by:
reset in interface UserEnvironment
Throws:
AuthorizationException

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object attrib)
Specified by:
setAttribute in interface UserEnvironment

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface UserEnvironment

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.