자바 코드 구현 kerbeos 인증 hive 연결
1491 단어 자바
hive 데이터 베 이 스 는 my sql 과 달리 인증 파일 두 개가 있어 야 로그 인 할 수 있 습 니 다.Hive.keytab 및 krb 5.conf
1.페이지 에서 두 개의 파일 을 전달 합 니 다.여기 서 base 64 로 전달 합 니 다.(두 개의 파일 이 크 지 않 은 것 을 고려 하여 이러한 방식 으로 base 64 가 파일 을 인 코딩 할 때 접두사 가 나타 나 므 로 디 코딩 할 때 절단 에 주의해 야 합 니 다)
2.프론트 엔 드 에서 두 개의 파일 을 전달 하여 사용자 정의 주 소 를 디 코딩 하고 읽 습 니 다.
3.자바 코드 로 연결 가 져 오기
Connection con = null; //
System.setProperty("java.security.krb5.conf", "krb5.conf ");
Configuration configuration = new Configuration();
configuration.set("hadoop.security.authentication" , "Kerberos" );
UserGroupInformation.setConfiguration(configuration);
try {
UserGroupInformation userGroupInformation = UserGroupInformation.loginUserFromKeytabAndReturnUGI(" ", "hive.keytab ");
try {
con = userGroupInformation.doAs((PrivilegedExceptionAction) () -> {
Connection connection = null;
connection = DriverManager.getConnection(dsConfig.getDsUrl());
return connection;
});
return con;
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.