protected Object formBackingObject(HttpServletRequest request) throws Exception {

    RequestContext requestContext = RequestContext.getRequestContext();
    Repository repository = requestContext.getRepository();
    Path uri = requestContext.getResourceURI();
    String token = requestContext.getSecurityToken();
    Resource resource = repository.retrieve(token, uri, false);

    Service service = requestContext.getService();
    String submitURL = service.constructLink(resource, requestContext.getPrincipal());

    EditPublishingCommand command = new EditPublishingCommand(submitURL);
    command.setResource(resource);

    return command;
  }
Esempio n. 2
0
  private AuthenticationChallenge getAuthenticationChallenge(
      HttpServletRequest request, Service service) {
    AuthenticationChallenge challenge = null;
    if (this.rememberAuthMethod) {
      Cookie c = getCookie(request, vrtxAuthSP);
      if (c != null) {
        String id = c.getValue();
        AuthenticationHandler handler = this.authHandlerMap.get(id);
        if (handler != null) {
          Set<?> categories = handler.getCategories();
          if (categories == null) {
            categories = Collections.EMPTY_SET;
          }
          if (handler != null && categories.contains(AUTH_HANDLER_SP_COOKIE_CATEGORY)) {
            challenge = handler.getAuthenticationChallenge();
          }
        }
      }
    }
    if (challenge != null) {
      if (this.spCookieAssertion != null) {
        boolean match = this.spCookieAssertion.matches(request, null, null);
        if (!match) {
          challenge = null;
        }
      }
    }

    if (challenge != null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Using challenge from cookie " + vrtxAuthSP + ": " + challenge);
      }
      return challenge;
    }

    challenge = service.getAuthenticationChallenge();

    if (challenge == null && service.getParent() != null) {
      return getAuthenticationChallenge(request, service.getParent());
    }
    return challenge;
  }
Esempio n. 3
0
  private void addPosterUrl(Resource mediaResource, Map<String, Object> model) {
    if (mediaResource == null) return;
    URL poster = null;
    Property posterImageProp = mediaResource.getProperty(posterImagePropDef);
    Property thumbnail = mediaResource.getProperty(thumbnailPropDef);
    if (posterImageProp != null) {
      poster = createUrl(posterImageProp.getStringValue());
    } else if (thumbnail != null) {
      poster = thumbnailService.constructURL(mediaResource);
      // Work-around for SelectiveProtocolManager URL post-processing which sets
      // URL protocol to "http" for open resources, but this causes mixed-mode
      // in secure page context, since this URL points to an inline element (image).
      if (RequestContext.exists()) {
        if (RequestContext.getRequestContext().getServletRequest().isSecure()) {
          poster.setProtocol("https");
        }
      }
    }

    if (poster != null) {
      model.put("poster", poster);
    }
  }