Tree PREV CLASS NEXT CLASS SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD com.ibm.portal.impersonation
Interface ImpersonationService
public interface ImpersonationServiceThis Interface can be used to access the impersonation functionality of WebSphere Portal.
An instance can be retrieved using a JNDI lookup for the following JNDI name portal:service/impersonation/ImpersonationService.
The name is also available via a constant of the Interface itself ImpersonationService.JNDI_NAME
The following sample shows how to perform the JNDI lookup to acquire a service object:com.ibm.portal.impersonation.ImpersonationService impersonationService; javax.naming.Context ctx = new javax.naming.InitialContext(); try { impersonationService = (ImpersonationService) ctx.lookup(ImpersonationService.JNDI_NAME); } catch(javax.naming.NameNotFoundException ex) { // error handling }NOTE: This API may only be used in the scope of an HTTP request in WebSphere Portal, i.e. within a theme. The API can not be invoked directly by a custom servlet.
- Since:
- 7.0
Field Summary static java.lang.String JNDI_NAME
The name can be used to lookup theImpersonationService from JNDI
Method Summary void doImpersonate(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse, java.lang.String impUserDN)
This method starts the impersonation.void doImpersonate(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse, User impUser)
This method starts the impersonation.User getOriginalUser()
This method returns the original user that has logged in.boolean isUserImpersonated()
This method indicates whether the current user has been impersonated or he is acting on its own behalf.void loginOriginalUser(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse)
This method ends the impersonation.
Field Detail JNDI_NAME
static final java.lang.String JNDI_NAME
- The name can be used to lookup the
ImpersonationService from JNDI
- See Also:
- Constant Field Values
Method Detail doImpersonate
void doImpersonate(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse, java.lang.String impUserDN) throws ImpersonationException
- This method starts the impersonation. The already logged in user will impersonate the user given by impUserDN. The original user will be logged out. Nested impersonations are not supported, that is if the current user is already impersonated (isUserImpersonated() returns true), an ImpersonationExcetion will be thrown.
- Parameters:
- aRequest - The current HttpServletRequest.
- aResponse - The current HttpServletResponse.
- impUserDN - The user DN to be impersonated
- Throws:
- ImpersonationException - If impersonation fails, e.g. if the current user is already impersonated or does not have sufficient privileges to perform the impersonation.
doImpersonate
void doImpersonate(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse, User impUser) throws ImpersonationException
- This method starts the impersonation. The already logged in user will impersonate the specified user. The original user will be logged out. Nested impersonations are not supported, that is if the current user is already impersonated (isUserImpersonated() returns true), an ImpersonationExcetion will be thrown.
- Parameters:
- aRequest - The current HttpServletRequest.
- aResponse - The current HttpServletResponse.
- impUser - The user to be impersonated
- Throws:
- ImpersonationException - If impersonation fails, e.g. if the current user is already impersonated or does not have sufficient privileges to perform the impersonation.
loginOriginalUser
void loginOriginalUser(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse) throws ImpersonationException
- This method ends the impersonation. The original user will be logged in.
- Parameters:
- servletRequest - The current HttpServletRequest.
- servletResponse - The current HttpServletResponse.
- Throws:
- ImpersonationException - If impersonation fails.
isUserImpersonated
boolean isUserImpersonated() throws ImpersonationException
- This method indicates whether the current user has been impersonated or he is acting on its own behalf.
- Returns:
- true if the current user has been impersonated by another user, false otherwise.
- Throws:
- ImpersonationException - if impersonation status could not be determined.
getOriginalUser
User getOriginalUser() throws ImpersonationException
- This method returns the original user that has logged in. If no impersonation has been executed, this is the current user. If an impersonation has been executed, the original user that is returned is the one who initiated the impersonation and who will be logged in when loginOriginalUser(HttpServletRequest, HttpServletResponse) is be called.
- Returns:
- the original user that has logged in and potentially impersonated another user.
- Throws:
- ImpersonationException - if the original user could not be determined.
- See Also:
- isUserImpersonated() to evaluate if impersonation has been executed
Tree PREV CLASS NEXT CLASS SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD