Package org.apache.shindig.common.uri

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


    assertEquals(UriStatus.VALID_UNVERSIONED, manager.validateRenderingUri(uri));
  }

  @Test
  public void versionerVersionInvalid() throws Exception {
    Uri uri = makeValidationTestUri(LD_PREFIX + LD_SUFFIX, "in-version");
    DefaultIframeUriManager manager = makeManager(false, false);
    manager.setVersioner(mockVersioner("test-version", false))// Invalid, if present.
    assertEquals(UriStatus.INVALID_VERSION, manager.validateRenderingUri(uri));
  }
View Full Code Here


  }

  @Test
  public void versionerVersionMatch() throws Exception {
    String version = "abcdefg";
    Uri uri = makeValidationTestUri(LD_PREFIX + LD_SUFFIX, version);
    DefaultIframeUriManager manager = makeManager(false, false);
    manager.setVersioner(mockVersioner(version, true));
    assertEquals(UriStatus.VALID_VERSIONED, manager.validateRenderingUri(uri));
  }
View Full Code Here

            .build())
        .commit();
    LockedDomainService ldService = new HashLockedDomainService(config, true, prefixGen);
    TestDefaultIframeUriManager manager = new TestDefaultIframeUriManager(config, ldService);

    Uri testUri = Uri.parse("http://foobar" + LD_SUFFIX + "/?url=http://example.com");

    config.newTransaction().addContainer(ImmutableMap
        .<String, Object>builder()
        .put(ContainerConfig.CONTAINER_KEY, ContainerConfig.DEFAULT_CONTAINER)
        .put(LOCKED_DOMAIN_SUFFIX_KEY, LD_SUFFIX_ALT)
View Full Code Here

                .commit();

    LockedDomainService ldService = new HashLockedDomainService(config, false, prefixGen);
    TestDefaultIframeUriManager manager = new TestDefaultIframeUriManager(config, ldService);

    Uri renderingUri = manager.makeRenderingUri(gadget);
    assertNotNull(renderingUri);

    UriBuilder uri = new UriBuilder(renderingUri);
    assertEquals("", uri.getScheme());
    assertEquals(UNLOCKED_DOMAIN, uri.getAuthority());
View Full Code Here

    }
    return ImmutableList.of();
  }

  private Set<String> retrieveServices(String endpoint) {
    Uri url = Uri.parse(endpoint + "?method=" + SYSTEM_LIST_METHODS_METHOD);
    HttpRequest request = new HttpRequest(url);
    try {
      HttpResponse response = fetcher.fetch(request);
      if (response.getHttpStatusCode() == HttpResponse.SC_OK) {
        return getServicesFromJsonResponse(response.getResponseAsString());
View Full Code Here

    boolean passed = false;

    MessageQueue mq = new SimpleMessageQueue();
    MessageContext mc = new MessageContext();
    Uri contextUri = req.getUri();
    InputSource is = new InputSource(contextUri.toJavaUri());

    PluginMeta pluginMeta = new PluginMeta(
            proxyFetcher(req, contextUri), proxyUriPolicy(req));
    PluginCompiler compiler = new PluginCompiler(BuildInfo.getInstance(),
            pluginMeta, mq);
    compiler.setMessageContext(mc);

    // Parse the javascript
    try {
      StringReader strReader = new StringReader(resp.getContent());
      CharProducer cp = CharProducer.Factory.create(strReader, is);
      JsTokenQueue tq = new JsTokenQueue(new JsLexer(cp), is);
      ParseTreeNode input = new Parser(tq, mq).parse();
      tq.expectEmpty();

      compiler.addInput(AncestorChain.instance(input).node, contextUri.toJavaUri());
    } catch (ParseException e) {
      // Don't bother continuing.
      resp.setContent("");
      return;
    }
View Full Code Here

      }
    }
  }

  private UriPolicy proxyUriPolicy(HttpRequest request) {
    final Uri contextUri = request.getUri();
    final Gadget stubGadget = DomWalker.makeGadget(request);

    return new UriPolicy() {
      public String rewriteUri(ExternalReference ref, UriEffect effect,
          LoaderType loader, Map<String, ?> hints) {

        Uri resourceUri = Uri.fromJavaUri(ref.getUri());
        if (contextUri != null) {
          resourceUri = contextUri.resolve(resourceUri);
        }

        ProxyUriManager.ProxyUri proxyUri = new ProxyUriManager.ProxyUri(
View Full Code Here

  }

  private UriFetcher proxyFetcher(final HttpRequest req, final Uri contextUri) {
    return new UriFetcher() {
      public FetchedData fetch(ExternalReference ref, String mimeType) throws UriFetchException {
        Uri resourceUri = Uri.fromJavaUri(ref.getUri());
        if (contextUri != null) {
          resourceUri = contextUri.resolve(resourceUri);
        }

        HttpRequest request = new HttpRequest(resourceUri)
View Full Code Here

  }

  protected void injectBaseTag(Gadget gadget, Node headTag) {
    GadgetContext context = gadget.getContext();
    if (containerConfig.getBool(context.getContainer(), INSERT_BASE_ELEMENT_KEY)) {
      Uri base = gadget.getSpec().getUrl();
      View view = gadget.getCurrentView();
      if (view != null && view.getHref() != null) {
        base = view.getHref();
      }
      Element baseTag = headTag.getOwnerDocument().createElement("base");
      baseTag.setAttribute("href", base.toString());
      headTag.insertBefore(baseTag, headTag.getFirstChild());
    }
  }
View Full Code Here

    OAuthAccessor accessor = accessorInfo.getAccessor();

    if (accessor.consumer.serviceProvider.accessTokenURL == null) {
      throw new OAuthRequestException(OAuthError.BAD_OAUTH_TOKEN_URL, "access token");
    }
    Uri accessTokenUri = Uri.parse(accessor.consumer.serviceProvider.accessTokenURL);
    HttpRequest request = new HttpRequest(accessTokenUri);
    request.setMethod(accessorInfo.getHttpMethod().toString());
    if (accessorInfo.getHttpMethod() == HttpMethod.POST) {
      request.setHeader("Content-Type", OAuth.FORM_ENCODED);
    }

    List<Parameter> msgParams = Lists.newArrayList();
    msgParams.add(new Parameter(OAuth.OAUTH_TOKEN, accessor.requestToken));
    if (accessorInfo.getSessionHandle() != null) {
      msgParams.add(new Parameter(OAuthConstants.OAUTH_SESSION_HANDLE,
          accessorInfo.getSessionHandle()));
    }
    String receivedCallback = realRequest.getOAuthArguments().getReceivedCallbackUrl();
    if (!StringUtils.isBlank(receivedCallback)) {
      try {
        Uri parsed = Uri.parse(receivedCallback);
        String verifier = parsed.getQueryParameter(OAuth.OAUTH_VERIFIER);
        if (verifier != null) {
          msgParams.add(new Parameter(OAuth.OAUTH_VERIFIER, verifier));
        }
      } catch (IllegalArgumentException e) {
        throw new OAuthRequestException(OAuthError.INVALID_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.