|
20 | 20 |
|
21 | 21 | import org.apache.hadoop.conf.Configuration; |
22 | 22 | import org.apache.hadoop.security.UserGroupInformation; |
| 23 | +import org.slf4j.Logger; |
| 24 | +import org.slf4j.LoggerFactory; |
23 | 25 |
|
24 | 26 | import java.io.IOException; |
25 | 27 |
|
|
30 | 32 | **/ |
31 | 33 | public class KrbUtils { |
32 | 34 |
|
| 35 | + private static final Logger LOG = LoggerFactory.getLogger(KrbUtils.class); |
| 36 | + |
33 | 37 | public static final String KRB5_CONF_KEY = "java.security.krb5.conf"; |
34 | 38 | public static final String HADOOP_AUTH_KEY = "hadoop.security.authentication"; |
35 | 39 | public static final String KRB_STR = "Kerberos"; |
36 | | - public static final String FALSE_STR = "false"; |
37 | | - public static final String SUBJECT_ONLY_KEY = "javax.security.auth.useSubjectCredsOnly"; |
| 40 | +// public static final String FALSE_STR = "false"; |
| 41 | +// public static final String SUBJECT_ONLY_KEY = "javax.security.auth.useSubjectCredsOnly"; |
38 | 42 |
|
39 | 43 | public static UserGroupInformation getUgi(String principal, String keytabPath, String krb5confPath) throws IOException { |
| 44 | + LOG.info("Kerberos login with principal: {} and keytab: {}", principal, keytabPath); |
40 | 45 | System.setProperty(KRB5_CONF_KEY, krb5confPath); |
| 46 | + // TODO 尚未探索出此选项的意义,以后研究明白方可打开 |
41 | 47 | // System.setProperty(SUBJECT_ONLY_KEY, FALSE_STR); |
42 | 48 | Configuration configuration = new Configuration(); |
43 | 49 | configuration.set(HADOOP_AUTH_KEY , KRB_STR); |
44 | 50 | UserGroupInformation.setConfiguration(configuration); |
45 | 51 | return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabPath); |
46 | 52 | } |
47 | 53 |
|
48 | | - public void checkKrbParams() { |
49 | | - |
50 | | - } |
51 | | - |
52 | 54 | } |
0 commit comments