Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.portal.portlet.service.impersonation
Interface ImpersonationService

All Superinterfaces:
  PortletService

    public interface ImpersonationService

extends PortletService

Portlet service for JSR compliant portlets to leverage the impersonation functionality of WebSphere Portal.
The following sample shows how to perform the JNDI lookup to acquire a service object:

              com.ibm.portal.portlet.service.PortletServiceHome psh;
              javax.naming.Context ctx = new javax.naming.InitialContext();

              try {
                  psh = (PortletServiceHome) ctx.lookup(ImpersonationService.JNDI_NAME);
              } catch(javax.naming.NameNotFoundException ex) {
                  // error handling
              }

              // obtain the service object and use the service
              ImpersonationService impersonationService = (ImpersonationService) psh.getPortletService(ImpersonationService.class);
              try {
                  impersonationService.doImpersonate(request, response, request.getParameter(FORM_TEXT));
              } catch (Exception e) {
                  // 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:
  6.1

Field Summary
`static java.lang.String` | `JNDI_NAME` The name can be used to lookup the `ImpersonationService` from `JNDI`

Method Summary
`void` | `doImpersonate(ActionRequest actionRequest, ActionResponse actionResponse, java.lang.String impUserDN)` This method starts the impersonation.
`void` | `doImpersonate(ActionRequest actionRequest, ActionResponse actionResponse, User impUser)` This method starts the impersonation.
`void` | `doImpersonate(PortletRequest portletRequest, PortletResponse portletResponse, java.lang.String impUserDN)` Deprecated. since 7.0 use `doImpersonate(ActionRequest, ActionResponse, String)` instead
`void` | `doImpersonate(PortletRequest portletRequest, PortletResponse portletResponse, User impUser)` Deprecated. since 7.0 use `doImpersonate(ActionRequest, ActionResponse, User)` instead
`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(ActionRequest aRequest, ActionResponse aResponse)` This method ends the impersonation.
`void` | `loginOriginalUser(HttpServletRequest aRequest, HttpServletResponse aResponse)` Deprecated. since 7.0 use com.ibm.portal.impersonation.ImpersonationService#loginOriginalUser(HttpServletRequest, HttpServletResponse) instead

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(PortletRequest portletRequest,
                       PortletResponse portletResponse,
                       java.lang.String impUserDN)
                       throws ImpersonationException

  Deprecated. since 7.0 use `doImpersonate(ActionRequest, ActionResponse, String)` instead

  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:
    `portletRequest` - The current `PortletRequest`.
    `portletResponse` - The current `PortletResponse`.
    `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(ActionRequest actionRequest,
                       ActionResponse actionResponse,
                       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:
    `actionRequest` - The current `ActionRequest`.
    `actionResponse` - The current `ActionResponse`.
    `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.
  Since:
    7.0

### doImpersonate

    void doImpersonate(PortletRequest portletRequest,
                       PortletResponse portletResponse,
                       User impUser)
                       throws ImpersonationException

  Deprecated. since 7.0 use `doImpersonate(ActionRequest, ActionResponse, User)` instead

  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:
    `portletRequest` - The current `PortletRequest`.
    `portletResponse` - The current `PortletResponse`.
    `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.

### doImpersonate

    void doImpersonate(ActionRequest actionRequest,
                       ActionResponse actionResponse,
                       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:
    `actionRequest` - The current `ActionRequest`.
    `actionResponse` - The current `ActionResponse`.
    `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.
  Since:
    7.0

### loginOriginalUser

    void loginOriginalUser(HttpServletRequest aRequest,
                           HttpServletResponse aResponse)
                           throws ImpersonationException

  Deprecated. since 7.0 use com.ibm.portal.impersonation.ImpersonationService#loginOriginalUser(HttpServletRequest, HttpServletResponse) instead

  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.

### loginOriginalUser

    void loginOriginalUser(ActionRequest aRequest,
                           ActionResponse aResponse)
                           throws ImpersonationException

  This method ends the impersonation. The original user will be logged in.

  Parameters:
    `portletRequest` - The current `PortletRequest`.
    `portletResponse` - The current `PortletResponse`.
  Throws:
    `ImpersonationException` - If impersonation fails.
  Since:
    6.1.0.1

### 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.
  Since:
    6.1.0.1

### 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(PortletRequest, PortletResponse)` 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.
  Since:
    6.1.0.1
  See Also:
    `isUserImpersonated() to evaluate if impersonation has been executed`

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD