修改:工程结构变更为 maven 工程
This commit is contained in:
45
src/main/java/org/redkalex/cache/redis/RedisCacheReqAuth.java
vendored
Normal file
45
src/main/java/org/redkalex/cache/redis/RedisCacheReqAuth.java
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.redkalex.cache.redis;
|
||||
|
||||
import org.redkale.net.client.ClientConnection;
|
||||
import org.redkale.util.ByteArray;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author zhangjx
|
||||
*/
|
||||
public class RedisCacheReqAuth extends RedisCacheRequest {
|
||||
|
||||
private static final byte[] PS = "AUTH".getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
protected String password;
|
||||
|
||||
public RedisCacheReqAuth(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(ClientConnection conn, ByteArray writer) {
|
||||
byte[] pwd = password.getBytes();
|
||||
writer.put((byte) '*');
|
||||
writer.put((byte) '2');
|
||||
writer.put((byte) '\r', (byte) '\n');
|
||||
writer.put((byte) '$');
|
||||
writer.put((byte) '4');
|
||||
writer.put((byte) '\r', (byte) '\n');
|
||||
writer.put(PS);
|
||||
writer.put((byte) '\r', (byte) '\n');
|
||||
|
||||
writer.put((byte) '$');
|
||||
writer.put(String.valueOf(pwd.length).getBytes(StandardCharsets.UTF_8));
|
||||
writer.put((byte) '\r', (byte) '\n');
|
||||
writer.put(pwd);
|
||||
writer.put((byte) '\r', (byte) '\n');
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user