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.security.UserGroupInformation;
23
24 import java.io.DataInput;
25 import java.io.DataOutput;
26 import java.io.IOException;
27
28
29 public enum AuthMethod {
30 SIMPLE((byte) 80, "", UserGroupInformation.AuthenticationMethod.SIMPLE),
31 KERBEROS((byte) 81, "GSSAPI", UserGroupInformation.AuthenticationMethod.KERBEROS),
32 DIGEST((byte) 82, "DIGEST-MD5", UserGroupInformation.AuthenticationMethod.TOKEN);
33
34
35 public final byte code;
36 public final String mechanismName;
37 public final UserGroupInformation.AuthenticationMethod authenticationMethod;
38
39 AuthMethod(byte code, String mechanismName,
40 UserGroupInformation.AuthenticationMethod authMethod) {
41 this.code = code;
42 this.mechanismName = mechanismName;
43 this.authenticationMethod = authMethod;
44 }
45
46 private static final int FIRST_CODE = values()[0].code;
47
48
49 public static AuthMethod valueOf(byte code) {
50 final int i = (code & 0xff) - FIRST_CODE;
51 return i < 0 || i >= values().length ? null : values()[i];
52 }
53
54
55 public String getMechanismName() {
56 return mechanismName;
57 }
58
59
60 public static AuthMethod read(DataInput in) throws IOException {
61 return valueOf(in.readByte());
62 }
63
64
65 public void write(DataOutput out) throws IOException {
66 out.write(code);
67 }
68 }