List of usage examples for org.apache.hadoop.security.token TokenIdentifier getUser
public abstract UserGroupInformation getUser();
From source file:org.apache.storm.common.AbstractHadoopAutoCreds.java
License:Apache License
private void addTokensToUGI(Subject subject) { if (subject != null) { Set<Credentials> privateCredentials = subject.getPrivateCredentials(Credentials.class); if (privateCredentials != null) { for (Credentials cred : privateCredentials) { Collection<Token<? extends TokenIdentifier>> allTokens = cred.getAllTokens(); if (allTokens != null) { for (Token<? extends TokenIdentifier> token : allTokens) { try { if (token == null) { LOG.debug("Ignoring null token"); continue; }//w w w. jav a2 s. co m LOG.debug("Current user: {}", UserGroupInformation.getCurrentUser()); LOG.debug("Token from Credentials : {}", token); TokenIdentifier tokenId = token.decodeIdentifier(); if (tokenId != null) { LOG.debug("Token identifier : {}", tokenId); LOG.debug("Username in token identifier : {}", tokenId.getUser()); } UserGroupInformation.getCurrentUser().addToken(token); LOG.info("Added delegation tokens to UGI."); } catch (IOException e) { LOG.error("Exception while trying to add tokens to ugi", e); } } } } } } }