Java 类org.apache.zookeeper.client.ZooKeeperSaslClient 实例源码

项目:fuck_zookeeper    文件:ClientCnxn.java   
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();
}
项目:fuck_zookeeper    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:https-github.com-apache-zookeeper    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:ZooKeeper    文件:ClientCnxn.java   
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();
}
项目:ZooKeeper    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:StreamProcessingInfrastructure    文件:ClientCnxn.java   
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();
}
项目:StreamProcessingInfrastructure    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:bigstreams    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:zookeeper    文件:ClientCnxn.java   
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();
}
项目:zookeeper    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:SecureKeeper    文件:ClientCnxn.java   
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();
}
项目:SecureKeeper    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:SecureKeeper    文件:ClientCnxn.java   
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();
}
项目:SecureKeeper    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:StreamBench    文件:ClientCnxn.java   
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();
}
项目:StreamBench    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:LoadBalanced_zk    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:LoadBalanced_zk    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:zookeeper-pkg    文件:SaslAuthDesignatedClientTest.java   
@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();
    }
}
项目:fuck_zookeeper    文件:ClientCnxn.java   
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);
}
项目:fuck_zookeeper    文件:Login.java   
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;
}
项目:fuck_zookeeper    文件:SaslClientTest.java   
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
项目:ZooKeeper    文件:ClientCnxn.java   
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);
}
项目:ZooKeeper    文件:Login.java   
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;
}
项目:ZooKeeper    文件:SaslClientTest.java   
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
项目:StreamProcessingInfrastructure    文件:ClientCnxn.java   
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);
}
项目:StreamProcessingInfrastructure    文件:Login.java   
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;
}
项目:StreamProcessingInfrastructure    文件:SaslClientTest.java   
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
项目:bigstreams    文件:ClientCnxn.java   
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);
}
项目:bigstreams    文件:Login.java   
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;
}
项目:zookeeper-src-learning    文件:ClientCnxn.java   
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);
}
项目:zookeeper-src-learning    文件:Login.java   
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;
}
项目:zookeeper    文件:ClientCnxn.java   
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);
}
项目:zookeeper    文件:Login.java   
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;
}
项目:zookeeper    文件:SaslClientTest.java   
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
项目:SecureKeeper    文件:Login.java   
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;
}
项目:SecureKeeper    文件:SaslClientTest.java   
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
项目:SecureKeeper    文件:Login.java   
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;
}
项目:SecureKeeper    文件:SaslClientTest.java   
@After
public void tearDown() {
    // Restore the System property if it was set previously
    if (existingPropertyValue != null) {
        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
    }
}
项目:StreamBench    文件:ClientCnxn.java   
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);
}