code: @Override
    public void addTokens(final byte[] tokens) {
  
      try (final DataInputBuffer buf = new DataInputBuffer()) {
  
        buf.reset(tokens, tokens.length);
        final Credentials credentials = new Credentials();
        credentials.readTokenStorageStream(buf);
  
        final UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
        ugi.addCredentials(credentials);
        LOG.log(Level.FINEST, "Added {0} tokens for user {1}", new Object[] {credentials.numberOfTokens(), ugi});
  
      } catch (final IOException ex) {
        LOG.log(Level.SEVERE, "Could not access tokens in user credentials.", ex);
        throw new RuntimeException(ex);
      }
    }
docs: Add serialized token to teh credentials.
  @param tokens ByteBuffer containing token.