/** * Try to locate the required token for the server. * * @param authType of the SASL client * @return Token for server, or null if no token available * @throws IOException - token selector cannot be instantiated */ private Token<?> getServerToken(SaslAuth authType) throws IOException { TokenInfo tokenInfo = SecurityUtil.getTokenInfo(protocol, conf); LOG.debug("Get token info proto:" + protocol + " info:" + tokenInfo); if (tokenInfo == null) { // protocol has no support for tokens return null; } TokenSelector<?> tokenSelector = null; try { tokenSelector = tokenInfo.value().newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new IOException(e.toString(), e); } return tokenSelector.selectToken( SecurityUtil.buildTokenService(serverAddr), ugi.getTokens()); }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol .equals(ContainerManagementProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return NMTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol.equals(ApplicationMasterProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return AMRMTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol .equals(ApplicationClientProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return RMDelegationTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol .equals(ApplicationHistoryProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return TimelineDelegationTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol .equals(LocalizationProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { LOG.debug("Using localizerTokenSecurityInfo"); return LocalizerTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return ClientToAMTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol.equals(MRClientProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return ClientToAMTokenSelector.class; } }; }
@Override public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) { if (!protocol .equals(HSClientProtocolPB.class)) { return null; } return new TokenInfo() { @Override public Class<? extends Annotation> annotationType() { return null; } @Override public Class<? extends TokenSelector<? extends TokenIdentifier>> value() { return ClientHSTokenSelector.class; } }; }