Package org.apache.shindig.common.uri

Examples of org.apache.shindig.common.uri.Uri$UriException


  private void loadTemplateLibraries(GadgetContext context,
      Feature f, List<TagRegistry> registries, List<TemplateLibrary> librariesthrows GadgetException {
    Collection<String> urls = f.getParams().get(REQUIRE_LIBRARY_PARAM);
    if (urls != null) {
      for (String url : urls) {
        Uri uri = Uri.parse(url.trim());
        uri = context.getUrl().resolve(uri);
       
        try {
          TemplateLibrary library = libraryFactory.loadTemplateLibrary(context, uri);
          registries.add(library.getTagRegistry());
View Full Code Here


    if (link.length() == 0) {
      return link;
    }

    try {
      Uri linkUri = processLink(Uri.parse(link));
      Uri uri = context.resolve(linkUri);
      if (rewriterFeature.shouldRewriteURL(uri.toString())) {
        String result = prefix
            + Utf8UrlCoder.encode(uri.toString())
            + ((gadgetUri == null) ? "" : "&gadget=" + Utf8UrlCoder.encode(gadgetUri.toString()))
            + "&fp="
            + rewriterFeature.getFingerprint();
        if (rewriterFeature.getExpires() != null) {
          result += '&' + ProxyBase.REFRESH_PARAM  + '=' + rewriterFeature.getExpires().toString();
        }
        return result;
      } else {
        return uri.toString();
      }
    } catch (IllegalArgumentException use) {
      // Unrecoverable. Just return link
      return link;
    }
View Full Code Here

   */
  public Uri getUriAttribute(String name) {
    String uriAttribute = getAttribute(name);
    if (uriAttribute != null) {
      try {
        Uri uri = Uri.parse(uriAttribute);
        return base.resolve(uri);
      } catch (IllegalArgumentException e) {
        return EMPTY_URI;
      }
    }
View Full Code Here

        "1".equals(gadget.getContext().getParameter("caja"))) {
      return;
    }
    String container = gadget.getContext().getContainer();
    ContentRewriterFeature feature = rewriterFeatureFactory.get(gadget.getSpec(), container);
    Uri contentBase = gadget.getSpec().getUrl();
    View view = gadget.getCurrentView();
    if (view != null && view.getHref() != null) {
      contentBase = view.getHref();
    }
   
View Full Code Here

  public BasicImageRewriter(OptimizerConfig config) {
    this.config = config;
  }

  public HttpResponse rewrite(HttpRequest request, HttpResponse response) {
    Uri uri = request.getUri();

    if (uri == null || request == null || response == null)
      return response;

    try {
      // Check resizing
      Integer resizeQuality = request.getParamAsInteger(PARAM_RESIZE_QUALITY);
      Integer requestedWidth = request.getParamAsInteger(PARAM_RESIZE_WIDTH);
      Integer requestedHeight = request.getParamAsInteger(PARAM_RESIZE_HEIGHT);
      boolean isResizeRequested = (requestedWidth != null || requestedHeight != null);

      // If the path or MIME type don't match, continue
      if (!isSupportedContent(response) && !isImage(uri)) {
        return response;
      }
      if (!isUsableParameter(requestedWidth) || !isUsableParameter(requestedHeight)
          || !isUsableParameter(resizeQuality)) {
        return response;
      }

      // Content header checking is fast so this is fine to do for every response.
      ImageFormat imageFormat = Sanselan
          .guessFormat(new ByteSourceInputStream(response.getResponse(), uri.getPath()));

      if (imageFormat == ImageFormat.IMAGE_FORMAT_UNKNOWN) {
        return enforceUnreadableImageRestrictions(uri, response);
      }

      // Don't handle very small images, but check after parsing format to
      // detect attacks.
      if (response.getContentLength() < config.getMinThresholdBytes()) {
        return response;
      }

      ImageInfo imageInfo = Sanselan.getImageInfo(response.getResponse(), uri.getPath());

      boolean isOversizedImage = isImageTooLarge(imageInfo);
      if (isResizeRequested && isOversizedImage) {
        HttpResponseBuilder rejectedResponseBuilder = new HttpResponseBuilder()
            .setHttpStatusCode(HttpResponse.SC_FORBIDDEN)
View Full Code Here

              "method='" + method + "' param_location='" + location + "'/>";
    }
  }

  Uri parseAuthorizationUrl(Element child, Uri base) throws SpecParserException {
    Uri url = XmlUtil.getHttpUriAttribute(child, URL_ATTR);
    if (url == null) {
      throw new SpecParserException("OAuth/Service/Authorization @url is not valid: " +
          child.getAttribute(URL_ATTR));
    }
    return base.resolve(url);
View Full Code Here

    return base.resolve(url);
  }


  EndPoint parseEndPoint(String where, Element child, Uri base) throws SpecParserException {
    Uri url = XmlUtil.getHttpUriAttribute(child, URL_ATTR);
    if (url == null) {
      throw new SpecParserException("Not an HTTP url: " + child.getAttribute(URL_ATTR));
    }

    Location location = Location.parse(child.getAttribute(PARAM_LOCATION_ATTR));
View Full Code Here

  private void verifyUrl(String url, OAuthResponseParams responseParams)
      throws OAuthRequestException {
    if (url == null) {
      return;
    }
    Uri uri;
    try {
      uri = Uri.parse(url);
    } catch (Throwable t) {
      throw responseParams.oauthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
          "Invalid url: " + url);
    }
    if (!uri.isAbsolute()) {
      throw responseParams.oauthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
          "Invalid url: " + url);
    }
  }
View Full Code Here

  /**
   * Generate a remote content request based on the parameters sent from the client.
   */
  private HttpRequest buildHttpRequest(HttpServletRequest request) throws GadgetException {
    Uri url = validateUrl(request.getParameter(URL_PARAM));

    HttpRequest req = new HttpRequest(url)
        .setContainer(getContainer(request));

    copySanitizedIntegerParams(request, req);
View Full Code Here

    String encoding = request.getCharacterEncoding();
    if (encoding == null) {
      encoding = "UTF-8";
    }

    Uri url = validateUrl(request.getParameter(URL_PARAM));

    HttpRequest req = new HttpRequest(url)
        .setMethod(getParameter(request, METHOD_PARAM, "GET"))
        .setPostBody(getParameter(request, POST_DATA_PARAM, "").getBytes())
        .setContainer(getContainer(request));
View Full Code Here

TOP

Related Classes of org.apache.shindig.common.uri.Uri$UriException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.