本文整理汇总了Java中org.apache.zookeeper.server.ZooKeeperSaslServer类的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperSaslServer类的具体用法?Java ZooKeeperSaslServer怎么用?Java ZooKeeperSaslServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ZooKeeperSaslServer类属于org.apache.zookeeper.server包,在下文中一共展示了ZooKeeperSaslServer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SaslServerCallbackHandler
import org.apache.zookeeper.server.ZooKeeperSaslServer; //导入依赖的package包/类
public SaslServerCallbackHandler(Configuration configuration) throws IOException {
String serverSection = System.getProperty(ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY,
ZooKeeperSaslServer.DEFAULT_LOGIN_CONTEXT_NAME);
AppConfigurationEntry configurationEntries[] = configuration.getAppConfigurationEntry(serverSection);
if (configurationEntries == null) {
String errorMessage = "Could not find a 'Server' entry in this configuration: Server cannot start.";
LOG.error(errorMessage);
throw new IOException(errorMessage);
}
credentials.clear();
for(AppConfigurationEntry entry: configurationEntries) {
Map<String,?> options = entry.getOptions();
// Populate DIGEST-MD5 user -> password map with JAAS configuration entries from the "Server" section.
// Usernames are distinguished from other options by prefixing the username with a "user_" prefix.
for(Map.Entry<String, ?> pair : options.entrySet()) {
String key = pair.getKey();
if (key.startsWith(USER_PREFIX)) {
String userName = key.substring(USER_PREFIX.length());
credentials.put(userName,(String)pair.getValue());
}
}
}
}
示例2: SaslServerCallbackHandler
import org.apache.zookeeper.server.ZooKeeperSaslServer; //导入依赖的package包/类
public SaslServerCallbackHandler(Configuration configuration)
throws IOException {
String serverSection = System.getProperty(
ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY,
ZooKeeperSaslServer.DEFAULT_LOGIN_CONTEXT_NAME);
AppConfigurationEntry configurationEntries[] = configuration.getAppConfigurationEntry(serverSection);
if (configurationEntries == null) {
String errorMessage = "Could not find a '" + serverSection + "' entry in this configuration: Server cannot start.";
LOG.error(errorMessage);
throw new IOException(errorMessage);
}
credentials.clear();
for(AppConfigurationEntry entry: configurationEntries) {
Map<String,?> options = entry.getOptions();
// Populate DIGEST-MD5 user -> password map with JAAS configuration entries from the "Server" section.
// Usernames are distinguished from other options by prefixing the username with a "user_" prefix.
for(Map.Entry<String, ?> pair : options.entrySet()) {
String key = pair.getKey();
if (key.startsWith(USER_PREFIX)) {
String userName = key.substring(USER_PREFIX.length());
credentials.put(userName,(String)pair.getValue());
}
}
}
}
示例3: getLoginContextMessage
import org.apache.zookeeper.server.ZooKeeperSaslServer; //导入依赖的package包/类
private String getLoginContextMessage() {
if (zkConfig instanceof ZKClientConfig) {
return ZKClientConfig.LOGIN_CONTEXT_NAME_KEY + "(=" + zkConfig.getProperty(
ZKClientConfig.LOGIN_CONTEXT_NAME_KEY, ZKClientConfig.LOGIN_CONTEXT_NAME_KEY_DEFAULT) + ")";
} else {
return ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY + "(=" + System.getProperty(
ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY, ZooKeeperSaslServer.DEFAULT_LOGIN_CONTEXT_NAME) + ")";
}
}
示例4: getZKServer
import org.apache.zookeeper.server.ZooKeeperSaslServer; //导入依赖的package包/类
protected static TestingServer getZKServer() throws Exception {
if (!kerberos) {
LOGGER.info("Creating a non-security ZooKeeper Server.");
return new TestingServer();
} else {
LOGGER.info("Creating a security ZooKeeper Server.");
// Not entirely sure exactly what "javax.security.auth.useSubjectCredsOnly=false" does, but it has something to do with
// re-authenticating in cases where it otherwise wouldn't. One of the sections on this page briefly mentions it:
// http://docs.oracle.com/javase/7/docs/technotes/guides/security/jgss/tutorials/Troubleshooting.html
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
// Setup KDC and principal
kdc = getKdc();
ZKKeytabFile = new File(kdcWorkDir, "test.keytab");
kdc.createPrincipal(ZKKeytabFile, ZK_SERVER_PRINCIPAL);
System.setProperty("zookeeper.authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
System.setProperty("zookeeper.kerberos.removeHostFromPrincipal", "true");
System.setProperty("zookeeper.kerberos.removeRealmFromPrincipal", "true");
JaasConfiguration.addEntryForKeytab("Server", ZK_SERVER_PRINCIPAL, ZKKeytabFile.getAbsolutePath());
// Here's where we add the "Client" to the jaas configuration, even though we'd like not to
JaasConfiguration.addEntryForKeytab(HAContext.SENTRY_ZK_JAAS_NAME,
SERVER_KERBEROS_NAME, serverKeytab.getAbsolutePath());
javax.security.auth.login.Configuration.setConfiguration(JaasConfiguration.getInstance());
System.setProperty(ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY, "Server");
return new TestingServer();
}
}
示例5: setZookeeperSaslTestConfigProps
import org.apache.zookeeper.server.ZooKeeperSaslServer; //导入依赖的package包/类
/**
* Sets zookeeper server and client SASL test config properties.
*/
public static void setZookeeperSaslTestConfigProps() {
System.setProperty(ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY, "DrillTestServerForUnitTests");
System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "DrillTestClientForUnitTests");
}
示例6: loginServer
import org.apache.zookeeper.server.ZooKeeperSaslServer; //导入依赖的package包/类
/**
* Log in the current zookeeper server process using the given configuration
* keys for the credential file and login principal.
*
* <p><strong>This is only applicable when running on secure hbase</strong>
* On regular HBase (without security features), this will safely be ignored.
* </p>
*
* @param conf The configuration data to use
* @param keytabFileKey Property key used to configure the path to the credential file
* @param userNameKey Property key used to configure the login principal
* @param hostname Current hostname to use in any credentials
* @throws IOException underlying exception from SecurityUtil.login() call
*/
public static void loginServer(Configuration conf, String keytabFileKey,
String userNameKey, String hostname) throws IOException {
login(conf, keytabFileKey, userNameKey, hostname,
ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY,
JaasConfiguration.SERVER_KEYTAB_KERBEROS_CONFIG_NAME);
}