@Override public void readFields(DataInput in) throws IOException { super.readFields(in); identifier = new AuthenticationTokenIdentifier(); identifier.readFields(in); }
private AuthenticationTokenIdentifier getIdentifier(String id, AuthenticationTokenSecretManager secretManager) throws InvalidToken { byte[] tokenId = decodeIdentifier(id); AuthenticationTokenIdentifier tokenIdentifier = secretManager.createIdentifier(); try { tokenIdentifier.readFields(new DataInputStream(new ByteArrayInputStream(tokenId))); } catch (IOException e) { throw (InvalidToken) new InvalidToken("Can't de-serialize tokenIdentifier").initCause(e); } return tokenIdentifier; }
/** * 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; } }