Package org.apache.shindig.auth

Examples of org.apache.shindig.auth.SecurityTokenCodec


      // BasicCrypter. 6 is the magic number that is private static final in
      // BasicBlobCrypterSecurityToken
      container = tokenParts[6];
    }
   
    SecurityTokenCodec codec = getCodec(container);
    if(codec == null) {
      //Shindig is really bad about making sure containers are encoded before they
      //are placed on URLs.  It basically makes the assumption that container ids do
      //not need to be encoded and just sticks them on the URLs.  This is the case when
      //it makes the request to the /rpc endpoint so just to be sure lets encode the container
      //and try to look up the token type
      try {
        String encodedContainer = URLEncoder.encode(container, "UTF-8");
        codec = getCodec(encodedContainer);
        if(codec!= null) {
          //Since the container was not properly encoded make sure it is correct in the token parameters
          putContainerInTokenParams(tokenParameters, encodedContainer);
        } else {
          throw new RuntimeException("Could not find security token codec for container " + container);
        }
      } catch (UnsupportedEncodingException e) {
        log.logp(Level.WARNING, CLASS, method, "Error while encoding container.");
      }
    }
     
    return codec.createToken(tokenParameters);
  }
View Full Code Here


    assertEquals("foo", orderedEnums.getJSONObject(3).getString("value"));
  }

  @Test
  public void testTokenOneGadget() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    Capture<SecurityToken> tokenCapture = new Capture<SecurityToken>();
    EasyMock.expect(codec.encodeToken(EasyMock.capture(tokenCapture))).andReturn(TOKEN);
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL);
    RpcHandler operation = registry.getRpcHandler(request);
View Full Code Here

    assertEquals(GadgetsHandler.FAILURE_METADATA, gadget.getString("error"));
  }

  @Test
  public void testTokenOneGadgetFailure() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    EasyMock.expect(codec.encodeToken(EasyMock.isA(SecurityToken.class)))
        .andThrow(new SecurityTokenException("blah"));
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL);
View Full Code Here

    assertEquals(FakeProcessor.SPEC_TITLE2, modulePrefs2.getString("title"));
  }

  @Test
  public void testTokenMultipleGadgetsWithSuccessAndFailure() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    EasyMock.expect(codec.encodeToken(EasyMock.isA(SecurityToken.class)))
        .andReturn(TOKEN);
    EasyMock.expect(codec.encodeToken(EasyMock.isA(SecurityToken.class)))
        .andThrow(new SecurityTokenException("blah"));
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL, GADGET2_URL);
View Full Code Here

    verify();
  }

  @Test
  public void testMetadataOneGadgetRequestTokenTTLParam() throws Exception {
    SecurityTokenCodec codec = createMock(SecurityTokenCodec.class);
    expect(codec.getTokenTimeToLive()).andReturn(42).anyTimes();
    replay(codec);

    registerGadgetsHandler(codec);
    setupGadgetAdminStore();
    setupMockRegistry(Lists.newArrayList("core"));
View Full Code Here

    verify();
  }

  @Test
  public void testTokenOneGadget() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    Capture<SecurityToken> authContextCapture = new Capture<SecurityToken>();
    EasyMock.expect(codec.encodeToken(EasyMock.capture(authContextCapture))).andReturn(TOKEN)
            .anyTimes();
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL);
View Full Code Here

    assertEquals(500, gadget.getJSONObject("error").getInt("code"));
  }

  @Test
  public void testTokenOneGadgetFailure() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    EasyMock.expect(codec.encodeToken(EasyMock.isA(SecurityToken.class))).andThrow(
            new SecurityTokenException("blah"));
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL);
View Full Code Here

    verify();
  }

  @Test
  public void testTokenMultipleGadgetsWithSuccessAndFailure() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    EasyMock.expect(codec.encodeToken(EasyMock.isA(SecurityToken.class))).andReturn(TOKEN);
    EasyMock.expect(codec.encodeToken(EasyMock.isA(SecurityToken.class))).andThrow(
            new SecurityTokenException("blah"));
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL, GADGET2_URL);
View Full Code Here

    verify();
  }

  @Test
  public void testMetadataOneGadgetRequestTokenTTLParam() throws Exception {
    SecurityTokenCodec codec = createMock(SecurityTokenCodec.class);
    expect(codec.getTokenTimeToLive()).andReturn(42).anyTimes();
    replay(codec);

    registerGadgetsHandler(codec);
    setupGadgetAdminStore();
    setupMockRegistry(Lists.newArrayList("core"));
View Full Code Here

    verify();
  }

  @Test
  public void testTokenOneGadget() throws Exception {
    SecurityTokenCodec codec = EasyMock.createMock(SecurityTokenCodec.class);
    Capture<SecurityToken> authContextCapture = new Capture<SecurityToken>();
    EasyMock.expect(codec.encodeToken(EasyMock.capture(authContextCapture))).andReturn(TOKEN)
            .anyTimes();
    replay(codec);

    registerGadgetsHandler(codec);
    JSONObject request = makeTokenRequest(GADGET1_URL);
View Full Code Here

TOP

Related Classes of org.apache.shindig.auth.SecurityTokenCodec

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.