Created
September 11, 2016 15:42
-
-
Save andrewstevenson/a20ad70cdaba3fd689fe4ae74f0f27c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override def connect(url: String, info: Properties): Connection = { | |
| val connectionProps = Krb5SqlServer.connectionProperties(url) | |
| val keytabFile = connectionProps(Krb5SqlServer.keytabFile) | |
| val principal = connectionProps(Krb5SqlServer.principalKey) | |
| val config = new Configuration() | |
| config.addResource("/etc/hadoop/conf/hdfs-site.xml") | |
| config.addResource("/etc/hadoop/conf/core-site.xml") | |
| config.addResource("/etc/hadoop/conf/mapred-site.xml") | |
| UserGroupInformation.setConfiguration(config) | |
| UserGroupInformation | |
| .getCurrentUser | |
| .setAuthenticationMethod(AuthenticationMethod.KERBEROS) | |
| UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytabFile) | |
| .doAs(new PrivilegedAction[Connection] { | |
| override def run(): Connection = | |
| sqlServerDriver.connect(url, info) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment