本文整理汇总了Java中org.trustedanalytics.hadoop.kerberos.KrbLoginManager类的典型用法代码示例。如果您正苦于以下问题:Java KrbLoginManager类的具体用法?Java KrbLoginManager怎么用?Java KrbLoginManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KrbLoginManager类属于org.trustedanalytics.hadoop.kerberos包,在下文中一共展示了KrbLoginManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
public Connection create() throws IOException {
if (kerberosProperties.isEnabled()) {
logger.info("Creating hbase connection with kerberos auth");
try {
KrbLoginManager loginManager = KrbLoginManagerFactory.getInstance()
.getKrbLoginManagerInstance(kerberosProperties.getKdc(), kerberosProperties.getRealm());
Subject subject = loginManager.loginWithCredentials(kerberosProperties.getUser(),
kerberosProperties.getPassword().toCharArray());
loginManager.loginInHadoop(subject, hbaseConfiguration);
return ConnectionFactory.createConnection(hbaseConfiguration, getUserFromSubject(subject));
} catch (LoginException e) {
logger.error("Create hbase connection failed. Unable to authorize with kerberos credentials: "
+ "user - {}, realm - {}, kdc - {}", kerberosProperties.getUser(), kerberosProperties.getRealm(), kerberosProperties.getKdc());
throw new IOException(e);
}
} else {
return ConnectionFactory.createConnection(hbaseConfiguration, getNoKrbUserFromSubject(hbaseConfiguration, kerberosProperties.getUser()));
}
}
示例2: getSecuredHBaseClient
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
private Admin getSecuredHBaseClient() throws InterruptedException, URISyntaxException,
LoginException, IOException {
LOGGER.info("Trying kerberos authentication");
KrbLoginManager loginManager =
KrbLoginManagerFactory.getInstance().getKrbLoginManagerInstance(
kerberosProperties.getKdc(), kerberosProperties.getRealm());
Subject subject =
loginManager.loginWithCredentials(configuration.getUser(), configuration.getPassword()
.toCharArray());
loginManager.loginInHadoop(subject, hbaseConf);
Configuration conf = HBaseConfiguration.create(hbaseConf);
User user =
UserProvider.instantiate(conf).create(UserGroupInformation.getUGIFromSubject(subject));
Connection connection = ConnectionFactory.createConnection(conf, user);
return connection.getAdmin();
}
示例3: create
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
public Connection create() throws IOException, LoginException {
Configuration hbaseConfiguration = Configurations.newInstanceFromEnv().getServiceConfig(ServiceType.HBASE_TYPE).asHadoopConfiguration();
try {
KerberosProperties kerberosProperties = serviceConfigProvider.getKerberosCredentials();
if (isKerberosEnabled(hbaseConfiguration)) {
KrbLoginManager loginManager = KrbLoginManagerFactory.getInstance()
.getKrbLoginManagerInstance(kerberosProperties.getKdc(), kerberosProperties.getRealm());
Subject subject = loginManager.loginWithCredentials(kerberosProperties.getUser(),
kerberosProperties.getPassword().toCharArray());
loginManager.loginInHadoop(subject, hbaseConfiguration);
return ConnectionFactory.createConnection(hbaseConfiguration, getUserFromSubject(hbaseConfiguration, subject));
} else {
return ConnectionFactory.createConnection(hbaseConfiguration, getNoKrbUserFromSubject(hbaseConfiguration, kerberosProperties.getUser()));
}
} catch (VcapEnvironmentException e) {
throw new IOException(e);
}
}
示例4: getZKClient
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "destroy")
@Profile(Profiles.CLOUD)
@Qualifier(Qualifiers.BROKER_INSTANCE)
public ZookeeperClient getZKClient() throws IOException, LoginException {
if (kerberosProperties.isKerberosEnabled()) {
LOGGER.info("Found kerberos configuration - trying to authenticate");
KrbLoginManager loginManager =
KrbLoginManagerFactory.getInstance().getKrbLoginManagerInstance(
kerberosProperties.getKdc(), kerberosProperties.getRealm());
loginManager.loginWithCredentials(config.getUser(), config.getPassword().toCharArray());
} else {
LOGGER.warn("kerberos configuration empty or invalid - will not try to authenticate.");
}
return new ZookeeperClientBuilder(config.getZkClusterHosts(), config.getUser(),
config.getBrokerRootNode(), config.getBrokerRootNode()).build();
}
示例5: logInToKerberos
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
public Configuration logInToKerberos(Configuration hadoopConf)
throws LoginException, IOException {
KrbLoginManager krbLoginManager =
KrbLoginManagerFactory.getInstance().getKrbLoginManagerInstance(kdc, realm);
krbLoginManager.loginInHadoop(krbLoginManager.loginWithCredentials(user, password), hadoopConf);
return hadoopConf;
}
示例6: getUserSecureFileSystem
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
private FileSystem getUserSecureFileSystem()
throws InterruptedException, URISyntaxException, LoginException, IOException {
LOGGER.info("Trying kerberos authentication");
KrbLoginManager loginManager = KrbLoginManagerFactory.getInstance()
.getKrbLoginManagerInstance(kerberosProperties.getKdc(), kerberosProperties.getRealm());
Configuration hadoopConf = getHadoopConfiguration();
loginManager.loginInHadoop(
loginManager.loginWithCredentials(configuration.getUser(), configuration.getPassword().toCharArray()),
hadoopConf);
return getFileSystemForUser(hadoopConf, configuration.getUser());
}
示例7: getAdminSecureFileSystem
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
private FileSystem getAdminSecureFileSystem()
throws InterruptedException, URISyntaxException, LoginException, IOException, KrbException {
byte[] keytabFile = Base64.decodeBase64(configuration.getHdfsSuperuserKeytab());
try (FileOutputStream fileOutputStream = new FileOutputStream(KEYTAB_FILE_PATH)) {
fileOutputStream.write(keytabFile);
}
KrbLoginManager loginManager = KrbLoginManagerFactory.getInstance()
.getKrbLoginManagerInstance(kerberosProperties.getKdc(), kerberosProperties.getRealm());
Configuration hadoopConf = getHadoopConfiguration();
loginManager.loginInHadoop(loginManager.loginWithKeyTab(configuration.getHdfsSuperuser(), KEYTAB_FILE_PATH),
hadoopConf);
return getFileSystemForUser(hadoopConf, configuration.getHdfsSuperuser());
}
示例8: with
import org.trustedanalytics.hadoop.kerberos.KrbLoginManager; //导入依赖的package包/类
Builder with(KrbLoginManager loginManager) {
this.loginManager = loginManager;
return this;
}