@Override public String toString() { return SystemUtils.getRawAddress(this.getRemoteSocketAddress()) + ":" + this.getRemoteSocketAddress().getPort(); }
case NO_ERROR: done.set(true); log.info("Authentication to " + this.memcachedTCPSession.getRemoteSocketAddress() + " successfully"); break; case AUTH_REQUIRED: log.error( "Authentication failed to " + this.memcachedTCPSession.getRemoteSocketAddress()); log.warn("Reopen connection to " + this.memcachedTCPSession.getRemoteSocketAddress() + ",beacause auth fail"); this.memcachedTCPSession.setAuthFailed(true); default: log.error( "Authentication failed to " + this.memcachedTCPSession.getRemoteSocketAddress() + ",response status=" + responseStatus); command = startAuth();
public void onConnect(MemcachedSession session, MemcachedClient client) { MemcachedTCPSession tcpSession = (MemcachedTCPSession) session; Map<String, AuthInfo> authInfoMap = client.getAuthInfoStringMap(); if (authInfoMap != null) { AuthInfo authInfo = authInfoMap.get(AddrUtil.getServerString(tcpSession.getRemoteSocketAddress())); if (authInfo != null) { XMemcachedClient xMemcachedClient = (XMemcachedClient) client; AuthTask task = new AuthTask(authInfo, xMemcachedClient.getCommandFactory(), tcpSession); task.start(); // First time,try to wait if (authInfo.isFirstTime()) { try { task.join(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } } }
private Command startAuth() throws SaslException { // destroy previous client. destroySaslClient(); this.saslClient = Sasl.createSaslClient(authInfo.getMechanisms(), null, "memcached", memcachedTCPSession.getRemoteSocketAddress().toString(), null, this.authInfo.getCallbackHandler()); byte[] response = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY_BYTES) : EMPTY_BYTES; CountDownLatch latch = new CountDownLatch(1); Command command = this.commandFactory.createAuthStartCommand(saslClient.getMechanismName(), latch, response); if (!this.memcachedTCPSession.isClosed()) this.memcachedTCPSession.write(command); else { log.error("Authentication fail,because the connection has been closed"); throw new RuntimeException("Authentication fai,connection has been close"); } return command; }
@Override public String toString() { return SystemUtils.getRawAddress(this.getRemoteSocketAddress()) + ":" + this.getRemoteSocketAddress().getPort(); }
case NO_ERROR: done.set(true); log.info("Authentication to " + this.memcachedTCPSession.getRemoteSocketAddress() + " successfully"); break; case AUTH_REQUIRED: log.error( "Authentication failed to " + this.memcachedTCPSession.getRemoteSocketAddress()); log.warn("Reopen connection to " + this.memcachedTCPSession.getRemoteSocketAddress() + ",beacause auth fail"); this.memcachedTCPSession.setAuthFailed(true); default: log.error( "Authentication failed to " + this.memcachedTCPSession.getRemoteSocketAddress() + ",response status=" + responseStatus); command = startAuth();
public void onConnect(MemcachedSession session, MemcachedClient client) { MemcachedTCPSession tcpSession = (MemcachedTCPSession) session; Map<String, AuthInfo> authInfoMap = client.getAuthInfoStringMap(); if (authInfoMap != null) { AuthInfo authInfo = authInfoMap.get(AddrUtil.getServerString(tcpSession.getRemoteSocketAddress())); if (authInfo != null) { XMemcachedClient xMemcachedClient = (XMemcachedClient) client; AuthTask task = new AuthTask(authInfo, xMemcachedClient.getCommandFactory(), tcpSession); task.start(); // First time,try to wait if (authInfo.isFirstTime()) { try { task.join(1000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } } }
private Command startAuth() throws SaslException { // destroy previous client. destroySaslClient(); this.saslClient = Sasl.createSaslClient(authInfo.getMechanisms(), null, "memcached", memcachedTCPSession.getRemoteSocketAddress().toString(), null, this.authInfo.getCallbackHandler()); byte[] response = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(EMPTY_BYTES) : EMPTY_BYTES; CountDownLatch latch = new CountDownLatch(1); Command command = this.commandFactory.createAuthStartCommand(saslClient.getMechanismName(), latch, response); if (!this.memcachedTCPSession.isClosed()) this.memcachedTCPSession.write(command); else { log.error("Authentication fail,because the connection has been closed"); throw new RuntimeException("Authentication fai,connection has been close"); } return command; }