Commit 6c034d2a authored by 杨林's avatar 杨林

kerberos认证类

parent 523cdfcb
package tools.auth
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.security.UserGroupInformation
import tools.properties.PropertiesTools
/**
* Created with IntelliJ IDEA.
* Class: KerberosAuth
* Description: kerberos认证
* User: lin
* Date: 2021-07-19
* Time: 16:17
*/
object KerberosAuth {
private[this] val properties = PropertiesTools.getProperties
def auth(): Unit = {
System.setProperty("java.security.krb5.conf", properties.getProperty("kerberos.config.path"))
System.setProperty("javax.security.auth.useSubjectCredsOnly", properties.getProperty("kerberos.javax.auth.useSubjectCredsOnly"))
System.setProperty("sun.security.krb5.debug", "false")
val conf: Configuration = new Configuration()
conf.set("hadoop.security.authentication", properties.getProperty("hadoop.security.auth"))
UserGroupInformation.setConfiguration(conf)
UserGroupInformation.loginUserFromKeytab(properties.getProperty("kerberos.hive.user"), properties.getProperty("kerberos.hive.path"))
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment