本文整理汇总了Java中org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java TestDelegationTokenIdentifier类的具体用法?Java TestDelegationTokenIdentifier怎么用?Java TestDelegationTokenIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestDelegationTokenIdentifier类属于org.apache.hadoop.security.token.delegation.TestDelegationToken包,在下文中一共展示了TestDelegationTokenIdentifier类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDecodeIdentifier
import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
public void testDecodeIdentifier() throws IOException {
TestDelegationTokenSecretManager secretManager =
new TestDelegationTokenSecretManager(0, 0, 0, 0);
secretManager.startThreads();
TestDelegationTokenIdentifier id = new TestDelegationTokenIdentifier(
new Text("owner"), new Text("renewer"), new Text("realUser"));
Token<TestDelegationTokenIdentifier> token =
new Token<TestDelegationTokenIdentifier>(id, secretManager);
TokenIdentifier idCopy = token.decodeIdentifier();
assertNotSame(id, idCopy);
assertEquals(id, idCopy);
}
示例2: getDelegationToken
import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
@Override // MiniProtocol
public Token<TestDelegationTokenIdentifier> getDelegationToken(Text renewer)
throws IOException {
String owner = UserGroupInformation.getCurrentUser().getUserName();
String realUser =
UserGroupInformation.getCurrentUser().getRealUser() == null ? "":
UserGroupInformation.getCurrentUser().getRealUser().getUserName();
TestDelegationTokenIdentifier tokenId =
new TestDelegationTokenIdentifier(
new Text(owner), renewer, new Text(realUser));
return new Token<TestDelegationTokenIdentifier>(tokenId, secretManager);
}
示例3: connectToServerAndGetDelegationToken
import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
void connectToServerAndGetDelegationToken(
final Configuration conf, final InetSocketAddress addr) throws IOException {
MiniProtocol client = null;
try {
UserGroupInformation current = UserGroupInformation.getCurrentUser();
UserGroupInformation proxyUserUgi =
UserGroupInformation.createProxyUserForTesting(
MINI_USER, current, GROUP_NAMES);
try {
client = proxyUserUgi.doAs(new PrivilegedExceptionAction<MiniProtocol>() {
@Override
public MiniProtocol run() throws IOException {
MiniProtocol p = RPC.getProxy(MiniProtocol.class,
MiniProtocol.versionID, addr, conf);
Token<TestDelegationTokenIdentifier> token;
token = p.getDelegationToken(new Text(RENEWER));
currentUgi = UserGroupInformation.createUserForTesting(MINI_USER,
GROUP_NAMES);
SecurityUtil.setTokenService(token, addr);
currentUgi.addToken(token);
return p;
}
});
} catch (InterruptedException e) {
Assert.fail(Arrays.toString(e.getStackTrace()));
}
} finally {
RPC.stopProxy(client);
}
}
示例4: connectToServerAndGetDelegationToken
import org.apache.hadoop.security.token.delegation.TestDelegationToken.TestDelegationTokenIdentifier; //导入依赖的package包/类
void connectToServerAndGetDelegationToken(
final Configuration conf, final InetSocketAddress addr) throws IOException {
MiniProtocol client = null;
try {
UserGroupInformation current = UserGroupInformation.getCurrentUser();
UserGroupInformation proxyUserUgi =
UserGroupInformation.createProxyUserForTesting(
MINI_USER, current, GROUP_NAMES);
try {
client = proxyUserUgi.doAs(new PrivilegedExceptionAction<MiniProtocol>() {
public MiniProtocol run() throws IOException {
MiniProtocol p = (MiniProtocol) RPC.getProxy(MiniProtocol.class,
MiniProtocol.versionID, addr, conf);
Token<TestDelegationTokenIdentifier> token;
token = p.getDelegationToken(new Text(RENEWER));
currentUgi = UserGroupInformation.createUserForTesting(MINI_USER,
GROUP_NAMES);
SecurityUtil.setTokenService(token, addr);
currentUgi.addToken(token);
return p;
}
});
} catch (InterruptedException e) {
Assert.fail(Arrays.toString(e.getStackTrace()));
}
} finally {
RPC.stopProxy(client);
}
}