1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.security;
21
22 import org.apache.hadoop.hbase.classification.InterfaceAudience;
23 import org.apache.hadoop.security.UserGroupInformation;
24
25 import java.io.DataInput;
26 import java.io.DataOutput;
27 import java.io.IOException;
28
29
30 @InterfaceAudience.Private
31 public enum AuthMethod {
32 SIMPLE((byte) 80, "", UserGroupInformation.AuthenticationMethod.SIMPLE),
33 KERBEROS((byte) 81, "GSSAPI", UserGroupInformation.AuthenticationMethod.KERBEROS),
34 DIGEST((byte) 82, "DIGEST-MD5", UserGroupInformation.AuthenticationMethod.TOKEN);
35
36
37 public final byte code;
38 public final String mechanismName;
39 public final UserGroupInformation.AuthenticationMethod authenticationMethod;
40
41 AuthMethod(byte code, String mechanismName,
42 UserGroupInformation.AuthenticationMethod authMethod) {
43 this.code = code;
44 this.mechanismName = mechanismName;
45 this.authenticationMethod = authMethod;
46 }
47
48 private static final int FIRST_CODE = values()[0].code;
49
50
51 public static AuthMethod valueOf(byte code) {
52 final int i = (code & 0xff) - FIRST_CODE;
53 return i < 0 || i >= values().length ? null : values()[i];
54 }
55
56
57 public String getMechanismName() {
58 return mechanismName;
59 }
60
61
62 public static AuthMethod read(DataInput in) throws IOException {
63 return valueOf(in.readByte());
64 }
65
66
67 public void write(DataOutput out) throws IOException {
68 out.write(code);
69 }
70 }