Search in sources :

Example 16 with BinaryPacket

use of com.alibaba.cobar.net.mysql.BinaryPacket 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)

Aggregations

BinaryPacket (com.alibaba.cobar.net.mysql.BinaryPacket)16 UnknownPacketException (com.alibaba.cobar.exception.UnknownPacketException)10 ErrorPacketException (com.alibaba.cobar.exception.ErrorPacketException)7 IOException (java.io.IOException)7 CommandPacket (com.alibaba.cobar.net.mysql.CommandPacket)6 ErrorPacket (com.alibaba.cobar.net.mysql.ErrorPacket)6 ServerConnection (com.alibaba.cobar.server.ServerConnection)6 MySQLChannel (com.alibaba.cobar.mysql.bio.MySQLChannel)3 UnknownCharsetException (com.alibaba.cobar.exception.UnknownCharsetException)2 ByteBuffer (java.nio.ByteBuffer)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 UnknownTxIsolationException (com.alibaba.cobar.exception.UnknownTxIsolationException)1 Channel (com.alibaba.cobar.mysql.bio.Channel)1 FieldPacket (com.alibaba.cobar.net.mysql.FieldPacket)1 HandshakePacket (com.alibaba.cobar.net.mysql.HandshakePacket)1 MySQLPacket (com.alibaba.cobar.net.mysql.MySQLPacket)1 OkPacket (com.alibaba.cobar.net.mysql.OkPacket)1 Reply323Packet (com.alibaba.cobar.net.mysql.Reply323Packet)1 RouteResultsetNode (com.alibaba.cobar.route.RouteResultsetNode)1 LinkedList (java.util.LinkedList)1