@Override
  public void intercept(HttpContentRequestImpl proxyRequest, PortletRequest portletRequest) {

    // if the user isn't already authenticated, perform any required
    // authentication pre-processing
    final PortletSession session = portletRequest.getPortletSession();
    synchronized (PortletUtils.getSessionMutex(session)) {
      if (!isAlreadyAuthenticated(portletRequest)) {
        prepareAuthentication(proxyRequest, portletRequest);
      }
      session.setAttribute(AUTHENTICATION_TIMEOUT_KEY, System.currentTimeMillis());
    }
  }
Exemplo n.º 2
0
  /**
   * Serve the resource as specified in the given request to the given response, using the
   * PortletContext's request dispatcher.
   *
   * <p>This is roughly equivalent to Portlet 2.0 GenericPortlet.
   *
   * @param request the current resource request
   * @param response the current resource response
   * @param context the current Portlet's PortletContext
   * @throws PortletException propagated from Portlet API's forward method
   * @throws IOException propagated from Portlet API's forward method
   */
  public static void serveResource(
      ResourceRequest request, ResourceResponse response, PortletContext context)
      throws PortletException, IOException {

    String id = request.getResourceID();
    if (id != null) {
      if (!PortletUtils.isProtectedResource(id)) {
        PortletRequestDispatcher rd = context.getRequestDispatcher(id);
        if (rd != null) {
          rd.forward(request, response);
          return;
        }
      }
      response.setProperty(ResourceResponse.HTTP_STATUS_CODE, "404");
    }
  }