Search in sources :

Example 1 with Reply323Packet

use of com.alibaba.cobar.net.mysql.Reply323Packet in project cobar by alibaba.

the class MySQLDetectorAuthenticator method auth323.

/**
 * 发送323响应认证数据包
 */
private void auth323(byte packetId, byte[] seed) {
    Reply323Packet r323 = new Reply323Packet();
    r323.packetId = ++packetId;
    String pass = source.getPassword();
    if (pass != null && pass.length() > 0) {
        r323.seed = SecurityUtil.scramble323(pass, new String(seed)).getBytes();
    }
    r323.write(source);
}
Also used : Reply323Packet(com.alibaba.cobar.net.mysql.Reply323Packet)

Example 2 with Reply323Packet

use of com.alibaba.cobar.net.mysql.Reply323Packet in project cobar by alibaba.

the class MySQLChannel method auth323.

/**
 * 323协议认证
 */
private void auth323(byte packetId, byte[] seed) throws IOException {
    Reply323Packet r323 = new Reply323Packet();
    r323.packetId = ++packetId;
    String passwd = dsc.getPassword();
    if (passwd != null && passwd.length() > 0) {
        r323.seed = SecurityUtil.scramble323(passwd, new String(seed)).getBytes();
    }
    r323.write(out);
    out.flush();
    BinaryPacket bin = receive();
    switch(bin.data[0]) {
        case OkPacket.FIELD_COUNT:
            afterSuccess();
            break;
        case ErrorPacket.FIELD_COUNT:
            ErrorPacket err = new ErrorPacket();
            err.read(bin);
            throw new ErrorPacketException(new String(err.message, charset));
        default:
            throw new UnknownPacketException(bin.toString());
    }
}
Also used : ErrorPacket(com.alibaba.cobar.net.mysql.ErrorPacket) ErrorPacketException(com.alibaba.cobar.exception.ErrorPacketException) UnknownPacketException(com.alibaba.cobar.exception.UnknownPacketException) Reply323Packet(com.alibaba.cobar.net.mysql.Reply323Packet) BinaryPacket(com.alibaba.cobar.net.mysql.BinaryPacket)

Example 3 with Reply323Packet

use of com.alibaba.cobar.net.mysql.Reply323Packet in project cobar by alibaba.

the class MySQLConnectionAuthenticator method auth323.

private void auth323(byte packetId) {
    // 发送323响应认证数据包
    Reply323Packet r323 = new Reply323Packet();
    r323.packetId = ++packetId;
    String pass = source.getPassword();
    if (pass != null && pass.length() > 0) {
        byte[] seed = source.getHandshake().seed;
        r323.seed = SecurityUtil.scramble323(pass, new String(seed)).getBytes();
    }
    r323.write(source);
}
Also used : Reply323Packet(com.alibaba.cobar.net.mysql.Reply323Packet)

Aggregations

Reply323Packet (com.alibaba.cobar.net.mysql.Reply323Packet)3 ErrorPacketException (com.alibaba.cobar.exception.ErrorPacketException)1 UnknownPacketException (com.alibaba.cobar.exception.UnknownPacketException)1 BinaryPacket (com.alibaba.cobar.net.mysql.BinaryPacket)1 ErrorPacket (com.alibaba.cobar.net.mysql.ErrorPacket)1