Search in sources :

Example 6 with DelegationTokenManager

use of org.apache.hadoop.security.token.delegation.web.DelegationTokenManager in project hadoop by apache.

the class TestZKDelegationTokenSecretManager method testCancelTokenSingleManager.

@SuppressWarnings("unchecked")
@Test
public void testCancelTokenSingleManager() throws Exception {
    for (int i = 0; i < TEST_RETRIES; i++) {
        DelegationTokenManager tm1 = null;
        String connectString = zkServer.getConnectString();
        Configuration conf = getSecretConf(connectString);
        tm1 = new DelegationTokenManager(conf, new Text("foo"));
        tm1.init();
        Token<DelegationTokenIdentifier> token = (Token<DelegationTokenIdentifier>) tm1.createToken(UserGroupInformation.getCurrentUser(), "foo");
        Assert.assertNotNull(token);
        tm1.cancelToken(token, "foo");
        try {
            verifyTokenFail(tm1, token);
            fail("Expected InvalidToken");
        } catch (SecretManager.InvalidToken it) {
            it.printStackTrace();
        }
        verifyDestroy(tm1, conf);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) DelegationTokenIdentifier(org.apache.hadoop.security.token.delegation.web.DelegationTokenIdentifier) Text(org.apache.hadoop.io.Text) Token(org.apache.hadoop.security.token.Token) SecretManager(org.apache.hadoop.security.token.SecretManager) DelegationTokenManager(org.apache.hadoop.security.token.delegation.web.DelegationTokenManager) Test(org.junit.Test)

Example 7 with DelegationTokenManager

use of org.apache.hadoop.security.token.delegation.web.DelegationTokenManager in project hadoop by apache.

the class TestZKDelegationTokenSecretManager method testRenewTokenSingleManager.

@SuppressWarnings("unchecked")
@Test
public void testRenewTokenSingleManager() throws Exception {
    for (int i = 0; i < TEST_RETRIES; i++) {
        DelegationTokenManager tm1 = null;
        String connectString = zkServer.getConnectString();
        Configuration conf = getSecretConf(connectString);
        tm1 = new DelegationTokenManager(conf, new Text("foo"));
        tm1.init();
        Token<DelegationTokenIdentifier> token = (Token<DelegationTokenIdentifier>) tm1.createToken(UserGroupInformation.getCurrentUser(), "foo");
        Assert.assertNotNull(token);
        tm1.renewToken(token, "foo");
        tm1.verifyToken(token);
        verifyDestroy(tm1, conf);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) DelegationTokenIdentifier(org.apache.hadoop.security.token.delegation.web.DelegationTokenIdentifier) Text(org.apache.hadoop.io.Text) Token(org.apache.hadoop.security.token.Token) DelegationTokenManager(org.apache.hadoop.security.token.delegation.web.DelegationTokenManager) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)7 Text (org.apache.hadoop.io.Text)7 DelegationTokenManager (org.apache.hadoop.security.token.delegation.web.DelegationTokenManager)7 Test (org.junit.Test)7 Token (org.apache.hadoop.security.token.Token)6 DelegationTokenIdentifier (org.apache.hadoop.security.token.delegation.web.DelegationTokenIdentifier)6 SecretManager (org.apache.hadoop.security.token.SecretManager)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 RetryPolicy (org.apache.curator.RetryPolicy)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 ACLProvider (org.apache.curator.framework.api.ACLProvider)1 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)1 ACL (org.apache.zookeeper.data.ACL)1 Id (org.apache.zookeeper.data.Id)1