Package org.apache.shindig.common.uri

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


        throw new RuntimeException(e);
      }
      String host = "//" +
        (ldDomain == null ? getReqVal(container, UNLOCKED_DOMAIN_KEY) : ldDomain);

      Uri gadgetUri = Uri.parse(host);
      if (gadgetUri.getAuthority() == null
              && gadgetUri.getScheme() == null
              && gadgetUri.getPath().equals(host)) {
        // This is for backwards compatibility with unlocked domains like
        // "unlockeddomain.com"
        gadgetUri = Uri.parse("//" + host);
      }

      // 3. Set the scheme.
      if (StringUtils.isBlank(gadgetUri.getScheme())) {
        uri.setScheme(getScheme(gadget, container));
      } else {
        uri.setScheme(gadgetUri.getScheme());
      }

      // 4. Set the authority.
      uri.setAuthority(gadgetUri.getAuthority());

      // 5. Add the URL.
      uri.addQueryParameter(Param.URL.getKey(), context.getUrl().toString());
    }
View Full Code Here


  public UriStatus validateRenderingUri(Uri inUri) {
    UriBuilder uri = new UriBuilder(inUri);

    String gadgetStr = uri.getQueryParameter(Param.URL.getKey());
    Uri gadgetUri;
    try {
      gadgetUri = Uri.parse(gadgetStr);
    } catch (Exception e) {
      // RuntimeException eg. InvalidArgumentException
      return UriStatus.BAD_URI;
View Full Code Here

    TestDefaultIframeUriManager manager = makeManager(
        false,   // security token beacon not required
        false)// locked domain not required

    // Generate URI, turn into UriBuilder for validation
    Uri result = manager.makeRenderingUri(gadget);
    assertNotNull(result);

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

    TestDefaultIframeUriManager manager = makeManager(
        false,   // security token beacon not required
        false)// locked domain not required

    // Generate URI, turn into UriBuilder for validation
    Uri result = manager.makeRenderingUri(gadget);
    assertNotNull(result);

    UriBuilder uri = new UriBuilder(result);
    assertEquals("0", uri.getQueryParameter(Param.SANITIZE.getKey()));
    assertEquals("1", uri.getQueryParameter(Param.CAJOLE.getKey()));
View Full Code Here

        false,   // security token beacon not required
        false)// locked domain not required
    managerTpl.setTemplatingSignal(tplSignal(true));

    // Templatized results.
    Uri resultTpl = managerTpl.makeRenderingUri(gadget);
    assertNotNull(resultTpl);

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

    TestDefaultIframeUriManager manager = makeManager(
        false,   // security token beacon not required
        false)// locked domain not required

    // Generate URI, turn into UriBuilder for validation
    Uri result = manager.makeRenderingUri(gadget);
    assertNotNull(result);

    UriBuilder uri = new UriBuilder(result);
    assertEquals("http", uri.getScheme());
    assertEquals("example.com", uri.getAuthority());
View Full Code Here

        false,   // security token beacon not required
        false)// locked domain not required
    managerTpl.setTemplatingSignal(tplSignal(true));

    // Generate URI, turn into UriBuilder for validation
    Uri resultTpl = managerTpl.makeRenderingUri(gadget);
    assertNotNull(resultTpl);

    UriBuilder uriTpl = new UriBuilder(resultTpl);
    assertEquals("http", uriTpl.getScheme());
    assertEquals("example.com", uriTpl.getAuthority());
View Full Code Here

  @Test
  public void securityTokenAddedWhenGadgetNeedsItFragment() throws Exception {
    Gadget gadget = mockGadget(SECURITY_TOKEN_FEATURE_NAME);
    TestDefaultIframeUriManager manager = makeManager(false, false);
    manager.setTokenForRendering(false);
    Uri result = manager.makeRenderingUri(gadget);
    assertNotNull(result);
    UriBuilder uri = new UriBuilder(result);
    assertEquals(TYPE_HTML_NUM_BASE_PARAMS, uri.getQueryParameters().size());
    assertEquals(1, uri.getFragmentParameters().size());
    assertEquals(tplKey(Param.SECURITY_TOKEN.getKey()),
View Full Code Here

  @Test
  public void securityTokenAddedWhenGadgetNeedsItQuery() throws Exception {
    Gadget gadget = mockGadget(SECURITY_TOKEN_FEATURE_NAME);
    TestDefaultIframeUriManager manager = makeManager(false, false);
    manager.setTokenForRendering(true);
    Uri result = manager.makeRenderingUri(gadget);
    assertNotNull(result);
    UriBuilder uri = new UriBuilder(result);
    assertEquals(TYPE_HTML_NUM_BASE_PARAMS + 1, uri.getQueryParameters().size());
    assertEquals(0, uri.getFragmentParameters().size());
    assertEquals(tplKey(Param.SECURITY_TOKEN.getKey()),
View Full Code Here

  @Test
  public void securityTokenAddedWhenForced() throws Exception {
    Gadget gadget = mockGadget("foo", "bar");
    TestDefaultIframeUriManager manager = makeManager(true, false)// security token forced
    manager.setTokenForRendering(false);
    Uri result = manager.makeRenderingUri(gadget);
    assertNotNull(result);
    UriBuilder uri = new UriBuilder(result);
    assertEquals(TYPE_HTML_NUM_BASE_PARAMS, uri.getQueryParameters().size());
    assertEquals(1, uri.getFragmentParameters().size());
    assertEquals(tplKey(Param.SECURITY_TOKEN.getKey()),
View Full Code Here

TOP

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

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.