Package org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager

Examples of org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation


          .getAllTokens();
      Assert.assertEquals(numTokensPerThread*numThreads, tokenCache.size());
      Iterator<TestDelegationTokenIdentifier> iter = tokenCache.keySet().iterator();
      while (iter.hasNext()) {
        TestDelegationTokenIdentifier id = iter.next();
        DelegationTokenInformation info = tokenCache.get(id);
        Assert.assertTrue(info != null);
        DelegationKey key = dtSecretManager.getKey(id);
        Assert.assertTrue(key != null);
        byte[] storedPassword = dtSecretManager.retrievePassword(id);
        byte[] password = dtSecretManager.createPassword(id, key);
View Full Code Here


    }
  }

  public long getRenewDate(RMDelegationTokenIdentifier ident)
      throws InvalidToken {
    DelegationTokenInformation info = currentTokens.get(ident);
    if (info == null) {
      throw new InvalidToken("token (" + ident.toString()
          + ") can't be found in cache");
    }
    return info.getRenewDate();
  }
View Full Code Here

          .getAllTokens();
      Assert.assertEquals(numTokensPerThread*numThreads, tokenCache.size());
      Iterator<TestDelegationTokenIdentifier> iter = tokenCache.keySet().iterator();
      while (iter.hasNext()) {
        TestDelegationTokenIdentifier id = iter.next();
        DelegationTokenInformation info = tokenCache.get(id);
        Assert.assertTrue(info != null);
        DelegationKey key = dtSecretManager.getKey(id);
        Assert.assertTrue(key != null);
        byte[] storedPassword = dtSecretManager.retrievePassword(id);
        byte[] password = dtSecretManager.createPassword(id, key);
View Full Code Here

    d.readFields(new DataInputStream(new ByteArrayInputStream(
        t.getIdentifier())));
    assertTrue("Usernames don't match",
        clientUgi.getShortUserName().equals(d.getUser().getShortUserName()));

    DelegationTokenInformation tokenInfo = MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE
        .getToken(d);
    assertNotNull("token not in store", tokenInfo);
    assertFalse("duplicate token add",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.addToken(d, tokenInfo));

    // check keys are copied from token store when token is loaded
    TokenStoreDelegationTokenSecretManager anotherManager =
        new TokenStoreDelegationTokenSecretManager(0, 0, 0, 0,
            MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE);
   assertEquals("master keys empty on init", 0,
        anotherManager.getAllKeys().length);
    assertNotNull("token loaded",
        anotherManager.retrievePassword(d));
    anotherManager.renewToken(t, clientUgi.getShortUserName());
    assertEquals("master keys not loaded from store",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getMasterKeys().length,
        anotherManager.getAllKeys().length);

    // cancel the delegation token
    tokenManager.cancelDelegationToken(tokenStrForm);
    assertNull("token not removed from store after cancel",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getToken(d));
    assertFalse("token removed (again)",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.removeToken(d));
    try {
      anotherManager.retrievePassword(d);
      fail("InvalidToken expected after cancel");
    } catch (InvalidToken ex) {
      // expected
    }

    // token expiration
    MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.addToken(d,
        new DelegationTokenInformation(0, t.getPassword()));
    assertNotNull(MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getToken(d));
    anotherManager.removeExpiredTokens();
    assertNull("Expired token not removed",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getToken(d));
View Full Code Here

  }

  @Override
  public boolean addToken(DelegationTokenIdentifier tokenIdentifier,
    DelegationTokenInformation token) {
    DelegationTokenInformation tokenInfo = tokens.putIfAbsent(tokenIdentifier, token);
    return (tokenInfo == null);
  }
View Full Code Here

    return (tokenInfo == null);
  }

  @Override
  public boolean removeToken(DelegationTokenIdentifier tokenIdentifier) {
    DelegationTokenInformation tokenInfo = tokens.remove(tokenIdentifier);
    return tokenInfo != null;
  }
View Full Code Here

          .getAllTokens();
      Assert.assertEquals(numTokensPerThread*numThreads, tokenCache.size());
      Iterator<TestDelegationTokenIdentifier> iter = tokenCache.keySet().iterator();
      while (iter.hasNext()) {
        TestDelegationTokenIdentifier id = iter.next();
        DelegationTokenInformation info = tokenCache.get(id);
        Assert.assertTrue(info != null);
        DelegationKey key = dtSecretManager.getKey(id);
        Assert.assertTrue(key != null);
        byte[] storedPassword = dtSecretManager.retrievePassword(id);
        byte[] password = dtSecretManager.createPassword(id, key);
View Full Code Here

    d.readFields(new DataInputStream(new ByteArrayInputStream(
        t.getIdentifier())));
    assertTrue("Usernames don't match",
        clientUgi.getShortUserName().equals(d.getUser().getShortUserName()));

    DelegationTokenInformation tokenInfo = MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE
        .getToken(d);
    assertNotNull("token not in store", tokenInfo);
    assertFalse("duplicate token add",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.addToken(d, tokenInfo));

    // check keys are copied from token store when token is loaded
    TokenStoreDelegationTokenSecretManager anotherManager =
        new TokenStoreDelegationTokenSecretManager(0, 0, 0, 0,
            MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE);
   assertEquals("master keys empty on init", 0,
        anotherManager.getAllKeys().length);
    assertNotNull("token loaded",
        anotherManager.retrievePassword(d));
    anotherManager.renewToken(t, clientUgi.getShortUserName());
    assertEquals("master keys not loaded from store",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getMasterKeys().length,
        anotherManager.getAllKeys().length);

    // cancel the delegation token
    tokenManager.cancelDelegationToken(tokenStrForm);
    assertNull("token not removed from store after cancel",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getToken(d));
    assertFalse("token removed (again)",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.removeToken(d));
    try {
      anotherManager.retrievePassword(d);
      fail("InvalidToken expected after cancel");
    } catch (InvalidToken ex) {
      // expected
    }

    // token expiration
    MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.addToken(d,
        new DelegationTokenInformation(0, t.getPassword()));
    assertNotNull(MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getToken(d));
    anotherManager.removeExpiredTokens();
    assertNull("Expired token not removed",
        MyHadoopThriftAuthBridge20S.Server.TOKEN_STORE.getToken(d));
View Full Code Here

    assertEquals("expected number keys", 1, ts.getMasterKeys().length);

    // tokens
    DelegationTokenIdentifier tokenId = new DelegationTokenIdentifier(
        new Text("owner"), new Text("renewer"), new Text("realUser"));
    DelegationTokenInformation tokenInfo = new DelegationTokenInformation(
        99, "password".getBytes());
    ts.addToken(tokenId, tokenInfo);
    DelegationTokenInformation tokenInfoRead = ts.getToken(tokenId);
    assertEquals(tokenInfo.getRenewDate(), tokenInfoRead.getRenewDate());
    assertNotSame(tokenInfo, tokenInfoRead);
    Assert.assertArrayEquals(HiveDelegationTokenSupport
        .encodeDelegationTokenInformation(tokenInfo),
        HiveDelegationTokenSupport
            .encodeDelegationTokenInformation(tokenInfoRead));
View Full Code Here

          .getAllTokens();
      Assert.assertEquals(numTokensPerThread*numThreads, tokenCache.size());
      Iterator<TestDelegationTokenIdentifier> iter = tokenCache.keySet().iterator();
      while (iter.hasNext()) {
        TestDelegationTokenIdentifier id = iter.next();
        DelegationTokenInformation info = tokenCache.get(id);
        Assert.assertTrue(info != null);
        DelegationKey key = dtSecretManager.getKey(id);
        Assert.assertTrue(key != null);
        byte[] storedPassword = dtSecretManager.retrievePassword(id);
        byte[] password = dtSecretManager.createPassword(id, key);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation

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.