hive 认证,
Pluggable custom authentication: Pluggable custom authentication provides a custom authentication provider for HiveServer2. To enable it, confgure thesettings as follows:
<property>
<name>hive.server2.authentication</name>
<value>CUSTOM</value>
</property>
<property>
<name>hive.server2.custom.authentication.class</name>
<value>pluggable-auth-class-name</value>
<description> Custom authentication class name, such as
com.packtpub.hive.essentials.hiveudf.customAuthenticator
</description>
</property>
The following is a sample of a customized class that implements the org.apache.hive.service.auth.PasswdAuthenticationProvider interface.The overridde Authenticate method has the core logic of how to authenticate a username and password. Make sure to copy the compiled JAR fle to $HIVE_HOME/lib/ so that the preceding settings can work.
customAuthenticator.java
package com.packtpub.hive.essentials.hiveudf;
import java.util.Hashtable;
import javax.security.sasl.AuthenticationException;
import org.apache.hive.service.auth.PasswdAuthenticationProvider;
/*
* The customized class for HiveServer2 authentication
*/
public class customAuthenticator implements PasswdAuthenticationProvider {
Hashtable<String, String> authHashTable = null;
public customAuthenticator () {
authHashTable = new Hashtable<String, String>();
authHashTable.put("user1", "passwd1");
authHashTable.put("user2", "passwd2");
}
@Override
public void Authenticate(String user, String password) throws AuthenticationException {
String storedPasswd = authHashTable.get(user);
if (storedPasswd != null && storedPasswd.equals(password))
return;
throw new AuthenticationException("customAuthenticatorException: Invalid user");
}
}
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。