|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openmrs.api.context.UserContext
public class UserContext
Represents an OpenMRS User Context which stores the current user information. Only
one User may be authenticated within a UserContext at any given time. The
UserContext should not be accessed directly, but rather used through the Context.
This class should be kept light-weight. There is one instance of this class per user that is
logged into the system.
Context| Constructor Summary | |
|---|---|
UserContext()
Default public constructor |
|
| Method Summary | |
|---|---|
void |
addProxyPrivilege(java.lang.String privilege)
Gives the given privilege to all calls to hasPrivilege. |
User |
authenticate(java.lang.String username,
java.lang.String password,
ContextDAO contextDAO)
Authenticate the user to this UserContext. |
User |
becomeUser(java.lang.String systemId)
Change current authentication to become another user. |
java.util.Set<Role> |
getAllRoles()
Gets all the roles for the (un)authenticated user. |
java.util.Set<Role> |
getAllRoles(User user)
Gets all the roles for a user. |
User |
getAuthenticatedUser()
|
java.util.Locale |
getLocale()
|
boolean |
hasPrivilege(java.lang.String privilege)
Tests whether or not currently authenticated user has a particular privilege |
boolean |
isAuthenticated()
|
void |
logout()
logs out the "active" (authenticated) user within this UserContext |
void |
refreshAuthenticatedUser()
Refresh the authenticated user object in this UserContext. |
void |
removeProxyPrivilege(java.lang.String privilege)
Will remove one instance of privilege from the privileges that are currently proxied |
void |
setLocale(java.util.Locale locale)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public UserContext()
| Method Detail |
|---|
public User authenticate(java.lang.String username,
java.lang.String password,
ContextDAO contextDAO)
throws ContextAuthenticationException
username - String login namepassword - String login passwordcontextDAO - ContextDAO implementation to use for authentication
ContextAuthenticationExceptionContext.authenticate(String,String)public void refreshAuthenticatedUser()
getAuthenticatedUser() User object.
public User becomeUser(java.lang.String systemId)
throws ContextAuthenticationException
systemId -
ContextAuthenticationExceptionpublic User getAuthenticatedUser()
nullpublic boolean isAuthenticated()
public void logout()
authenticate(java.lang.String, java.lang.String, org.openmrs.api.db.ContextDAO)public void addProxyPrivilege(java.lang.String privilege)
try {
Context.addProxyPrivilege("AAA");
Context.get*Service().methodRequiringAAAPrivilege();
}
finally {
Context.removeProxyPrivilege("AAA");
}
privilege - to give to userspublic void removeProxyPrivilege(java.lang.String privilege)
privilege - Privilege to remove in string formpublic void setLocale(java.util.Locale locale)
locale - new locale for this contextpublic java.util.Locale getLocale()
public java.util.Set<Role> getAllRoles()
throws java.lang.Exception
java.lang.Exception
public java.util.Set<Role> getAllRoles(User user)
throws java.lang.Exception
user -
java.lang.Exceptionpublic boolean hasPrivilege(java.lang.String privilege)
privilege -
|
OpenMRS-1.7.x | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||