@Override public AuthenticationTokenIdentifier createIdentifier() { // Return our TokenIdentifier implementation return new AuthenticationTokenIdentifier(); }
@Override public void readFields(DataInput in) throws IOException { super.readFields(in); identifier = new AuthenticationTokenIdentifier(); identifier.readFields(in); }
@Override public DelegationTokenImpl clone() { DelegationTokenImpl copy = (DelegationTokenImpl) super.clone(); copy.setPassword(getPassword()); copy.identifier = new AuthenticationTokenIdentifier(identifier); return copy; }
requireNonNull(cfg); final AuthenticationTokenIdentifier id = new AuthenticationTokenIdentifier(username, cfg);
/** * Unwraps the provided {@link AuthenticationToken} if it is an instance of * {@link DelegationTokenStub}, reconstituting it from the provided {@link JobConf}. * * @param job * The job * @param token * The authentication token */ public static AuthenticationToken unwrapAuthenticationToken(JobConf job, AuthenticationToken token) { requireNonNull(job); requireNonNull(token); if (token instanceof DelegationTokenStub) { DelegationTokenStub delTokenStub = (DelegationTokenStub) token; Token<? extends TokenIdentifier> hadoopToken = job.getCredentials() .getToken(new Text(delTokenStub.getServiceName())); AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier(); try { identifier .readFields(new DataInputStream(new ByteArrayInputStream(hadoopToken.getIdentifier()))); return new DelegationTokenImpl(hadoopToken.getPassword(), identifier); } catch (IOException e) { throw new RuntimeException("Could not construct DelegationToken from JobConf Credentials", e); } } return token; }
/** * Unwraps the provided {@link AuthenticationToken} if it is an instance of * {@link DelegationTokenStub}, reconstituting it from the provided {@link JobConf}. * * @param job * The job * @param token * The authentication token */ public static AuthenticationToken unwrapAuthenticationToken(JobConf job, AuthenticationToken token) { requireNonNull(job); requireNonNull(token); if (token instanceof DelegationTokenStub) { DelegationTokenStub delTokenStub = (DelegationTokenStub) token; Token<? extends TokenIdentifier> hadoopToken = job.getCredentials() .getToken(new Text(delTokenStub.getServiceName())); AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier(); try { identifier .readFields(new DataInputStream(new ByteArrayInputStream(hadoopToken.getIdentifier()))); return new DelegationTokenImpl(hadoopToken.getPassword(), identifier); } catch (IOException e) { throw new RuntimeException("Could not construct DelegationToken from JobConf Credentials", e); } } return token; }
/** * Unwraps the provided {@link AuthenticationToken} if it is an instance of * {@link DelegationTokenStub}, reconstituting it from the provided {@link JobConf}. * * @param job * The job * @param token * The authentication token */ public static AuthenticationToken unwrapAuthenticationToken(JobContext job, AuthenticationToken token) { requireNonNull(job); requireNonNull(token); if (token instanceof DelegationTokenStub) { DelegationTokenStub delTokenStub = (DelegationTokenStub) token; Token<? extends TokenIdentifier> hadoopToken = job.getCredentials() .getToken(new Text(delTokenStub.getServiceName())); AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier(); try { identifier .readFields(new DataInputStream(new ByteArrayInputStream(hadoopToken.getIdentifier()))); return new DelegationTokenImpl(hadoopToken.getPassword(), identifier); } catch (IOException e) { throw new RuntimeException("Could not construct DelegationToken from JobConf Credentials", e); } } return token; } }
/** * Unwraps the provided {@link AuthenticationToken} if it is an instance of * {@link DelegationTokenStub}, reconstituting it from the provided {@link JobConf}. * * @param job * The job * @param token * The authentication token */ public static AuthenticationToken unwrapAuthenticationToken(JobContext job, AuthenticationToken token) { requireNonNull(job); requireNonNull(token); if (token instanceof DelegationTokenStub) { DelegationTokenStub delTokenStub = (DelegationTokenStub) token; Token<? extends TokenIdentifier> hadoopToken = job.getCredentials() .getToken(new Text(delTokenStub.getServiceName())); AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier(); try { identifier .readFields(new DataInputStream(new ByteArrayInputStream(hadoopToken.getIdentifier()))); return new DelegationTokenImpl(hadoopToken.getPassword(), identifier); } catch (IOException e) { throw new RuntimeException("Could not construct DelegationToken from JobConf Credentials", e); } } return token; } }
@Override public DelegationToken getDelegationToken(DelegationTokenConfig cfg) throws AccumuloException, AccumuloSecurityException { final TDelegationTokenConfig tConfig; if (null != cfg) { tConfig = DelegationTokenConfigSerializer.serialize(cfg); } else { tConfig = new TDelegationTokenConfig(); } TDelegationToken thriftToken; try { thriftToken = MasterClient.execute(context, new ClientExecReturn<TDelegationToken,Client>() { @Override public TDelegationToken execute(Client client) throws Exception { return client.getDelegationToken(Tracer.traceInfo(), context.rpcCreds(), tConfig); } }); } catch (TableNotFoundException e) { // should never happen throw new AssertionError( "Received TableNotFoundException on method which should not throw that exception", e); } AuthenticationTokenIdentifier identifier = new AuthenticationTokenIdentifier( thriftToken.getIdentifier()); // Get the password out of the thrift delegation token return new DelegationTokenImpl(thriftToken.getPassword(), identifier); }