当前位置: 首页>>代码示例>>Java>>正文


Java ZooKeeperSaslClient类代码示例

本文整理汇总了Java中org.apache.zookeeper.client.ZooKeeperSaslClient的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperSaslClient类的具体用法?Java ZooKeeperSaslClient怎么用?Java ZooKeeperSaslClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZooKeeperSaslClient类属于org.apache.zookeeper.client包,在下文中一共展示了ZooKeeperSaslClient类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clientTunneledAuthenticationInProgress

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
public boolean clientTunneledAuthenticationInProgress() {
    // 1. SASL client is disabled.
    if (!ZooKeeperSaslClient.isEnabled()) {
        return false;
    }

    // 2. SASL login failed.
    if (saslLoginFailed == true) {
        return false;
    }

    // 3. SendThread has not created the authenticating object yet,
    // therefore authentication is (at the earliest stage of being) in progress.
    if (zooKeeperSaslClient == null) {
        return true;
    }

    // 4. authenticating object exists, so ask it for its progress.
    return zooKeeperSaslClient.clientTunneledAuthenticationInProgress();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:ClientCnxn.java

示例2: login

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
private synchronized LoginContext login(final String loginContextName) throws LoginException {
    if (loginContextName == null) {
        throw new LoginException("loginContext name (JAAS file section header) was null. " +
                "Please check your java.security.login.auth.config (=" +
                System.getProperty("java.security.login.auth.config") +
                ") and your " + ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY + "(=" + 
                System.getProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "Client") + ")");
    }
    LoginContext loginContext = new LoginContext(loginContextName,callbackHandler);
    loginContext.login();
    LOG.info("successfully logged in.");
    return loginContext;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:14,代码来源:Login.java

示例3: testSaslConfig

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
@Test
public void testSaslConfig() throws Exception {
    ZooKeeper zk = createClient();
    try {
        zk.getChildren("/", false);
        Assert.assertFalse(zk.getSaslClient().
            clientTunneledAuthenticationInProgress());
        Assert.assertEquals(zk.getSaslClient().getSaslState(),
            ZooKeeperSaslClient.SaslState.COMPLETE);
        Assert.assertNotNull(
            javax.security.auth.login.Configuration.getConfiguration().
                getAppConfigurationEntry("MyZookeeperClient"));
        Assert.assertSame(zk.getSaslClient().getLoginContext(),
            "MyZookeeperClient");
    } catch (KeeperException e) {
        Assert.fail("test failed :" + e);
    } finally {
        zk.close();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:SaslAuthDesignatedClientTest.java

示例4: tunnelAuthInProgress

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
public boolean tunnelAuthInProgress() {
    // 1. SASL client is disabled.
    if (!ZooKeeperSaslClient.isEnabled()) {
        return false;
    }

    // 2. SASL login failed.
    if (saslLoginFailed == true) {
        return false;
    }

    // 3. SendThread has not created the authenticating object yet,
    // therefore authentication is (at the earliest stage of being) in progress.
    if (zooKeeperSaslClient == null) {
        return true;
    }

    // 4. authenticating object exists, so ask it for its progress.
    return zooKeeperSaslClient.clientTunneledAuthenticationInProgress();
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:21,代码来源:ClientCnxn.java

示例5: startConnect

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
private void startConnect() throws IOException {
    state = States.CONNECTING;

    InetSocketAddress addr;
    if (rwServerAddress != null) {
        addr = rwServerAddress;
        rwServerAddress = null;
    } else {
        addr = hostProvider.next(1000);
    }

    setName(getName().replaceAll("\\(.*\\)",
            "(" + addr.getHostName() + ":" + addr.getPort() + ")"));
    if (ZooKeeperSaslClient.isEnabled()) {
        try {
            String principalUserName = System.getProperty(
                    ZK_SASL_CLIENT_USERNAME, "zookeeper");
            zooKeeperSaslClient =
                new ZooKeeperSaslClient(
                        principalUserName+"/"+addr.getHostName());
        } catch (LoginException e) {
            // An authentication error occurred when the SASL client tried to initialize:
            // for Kerberos this means that the client failed to authenticate with the KDC.
            // This is different from an authentication error that occurs during communication
            // with the Zookeeper server, which is handled below.
            LOG.warn("SASL configuration failed: " + e + " Will continue connection to Zookeeper server without "
              + "SASL authentication, if Zookeeper server allows it.");
            eventThread.queueEvent(new WatchedEvent(
              Watcher.Event.EventType.None,
              Watcher.Event.KeeperState.AuthFailed, null));
            saslLoginFailed = true;
        }
    }
    logStartConnect(addr);

    clientCnxnSocket.connect(addr);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:38,代码来源:ClientCnxn.java

示例6: tearDown

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:8,代码来源:SaslClientTest.java

示例7: login

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
private synchronized LoginContext login(final String loginContextName) throws LoginException {
    if (loginContextName == null) {
        throw new LoginException("loginContext name (JAAS file section header) was null. " +
                "Please check your java.security.login.auth.config (=" +
                System.getProperty("java.security.login.auth.config") +
                ") and your " + ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY + "(=" + 
                System.getProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "Client") + ")");
    }
    LoginContext loginContext = new LoginContext(loginContextName,callbackHandler);
    loginContext.login();
    LOG.info("{} successfully logged in.", loginContextName);
    return loginContext;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:14,代码来源:Login.java

示例8: startConnect

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
private void startConnect() throws IOException {
    state = States.CONNECTING;

    InetSocketAddress addr;
    if (rwServerAddress != null) {
        addr = rwServerAddress;
        rwServerAddress = null;
    } else {
        addr = hostProvider.next(1000);
    }

    setName(getName().replaceAll("\\(.*\\)",
            "(" + addr.getHostName() + ":" + addr.getPort() + ")"));
    try {
        zooKeeperSaslClient = new ZooKeeperSaslClient("zookeeper/"+addr.getHostName());
    } catch (LoginException e) {
        // An authentication error occurred when the SASL client tried to initialize:
        // for Kerberos this means that the client failed to authenticate with the KDC.
        // This is different from an authentication error that occurs during communication
        // with the Zookeeper server, which is handled below.
        LOG.warn("SASL configuration failed: " + e + " Will continue connection to Zookeeper server without "
          + "SASL authentication, if Zookeeper server allows it.");
        eventThread.queueEvent(new WatchedEvent(
          Watcher.Event.EventType.None,
          Watcher.Event.KeeperState.AuthFailed, null));
        saslLoginFailed = true;
    }
    logStartConnect(addr);

    clientCnxnSocket.connect(addr);
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:32,代码来源:ClientCnxn.java

示例9: startConnect

import org.apache.zookeeper.client.ZooKeeperSaslClient; //导入依赖的package包/类
private void startConnect() throws IOException {
    state = States.CONNECTING;

    InetSocketAddress addr;
    if (rwServerAddress != null) {
        addr = rwServerAddress;
        rwServerAddress = null;
    } else {
        addr = hostProvider.next(1000);
    }

    setName(getName().replaceAll("\\(.*\\)",
            "(" + addr.getHostName() + ":" + addr.getPort() + ")"));
    try {
        zooKeeperSaslClient = new ZooKeeperSaslClient("zookeeper/" + addr.getHostName());
    } catch (LoginException e) {
        // An authentication error occurred when the SASL client tried to initialize:
        // for Kerberos this means that the client failed to authenticate with the KDC.
        // This is different from an authentication error that occurs during communication
        // with the Zookeeper server, which is handled below.
        LOG.warn("SASL configuration failed: " + e + " Will continue connection to Zookeeper server without "
                + "SASL authentication, if Zookeeper server allows it.");
        eventThread.queueEvent(new WatchedEvent(
                Watcher.Event.EventType.None,
                Watcher.Event.KeeperState.AuthFailed, null));
        saslLoginFailed = true;
    }
    logStartConnect(addr);

    clientCnxnSocket.connect(addr);
}
 
开发者ID:blentle,项目名称:zookeeper-src-learning,代码行数:32,代码来源:ClientCnxn.java


注:本文中的org.apache.zookeeper.client.ZooKeeperSaslClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。