1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.security.token;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.io.Text;
25 import org.apache.hadoop.security.token.Token;
26 import org.apache.hadoop.security.token.TokenIdentifier;
27 import org.apache.hadoop.security.token.TokenSelector;
28
29 import java.util.Collection;
30
31 @InterfaceAudience.Private
32 public class AuthenticationTokenSelector
33 implements TokenSelector<AuthenticationTokenIdentifier> {
34 private static final Log LOG = LogFactory.getLog(AuthenticationTokenSelector.class);
35
36 public AuthenticationTokenSelector() {
37 }
38
39 @Override
40 public Token<AuthenticationTokenIdentifier> selectToken(Text serviceName,
41 Collection<Token<? extends TokenIdentifier>> tokens) {
42 if (serviceName != null) {
43 for (Token ident : tokens) {
44 if (serviceName.equals(ident.getService()) &&
45 AuthenticationTokenIdentifier.AUTH_TOKEN_TYPE.equals(ident.getKind())) {
46 if (LOG.isDebugEnabled()) {
47 LOG.debug("Returning token "+ident);
48 }
49 return (Token<AuthenticationTokenIdentifier>)ident;
50 }
51 }
52 }
53 LOG.debug("No matching token found");
54 return null;
55 }
56 }