use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class SaslAuthenticationHandler method channelRead.
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
if (msg instanceof ByteBuf) {
ByteBuf response = (ByteBuf) msg;
roundtripsToGo--;
if (successful(response) || status(response) == STATUS_AUTH_CONTINUE) {
byte opcode = opcode(response);
try {
if (MemcacheProtocol.Opcode.SASL_AUTH.opcode() == opcode) {
handleAuthResponse(ctx, (ByteBuf) msg);
} else if (MemcacheProtocol.Opcode.SASL_STEP.opcode() == opcode) {
completeAuth(ctx, (ByteBuf) msg);
}
} catch (Exception ex) {
failConnect(ctx, "Unexpected error during SASL auth", response, ex, status(response));
}
} else if (STATUS_AUTH_ERROR == status(response)) {
maybeFailConnect(ctx, "Authentication Failure - Potential causes: invalid credentials or if " + "LDAP is enabled ensure PLAIN SASL mechanism is exclusively used on the PasswordAuthenticator (insecure) or " + "TLS is used (recommended)", response, null, status(response));
} else {
failConnect(ctx, "Unexpected Status 0x" + Integer.toHexString(status(response)) + " during SASL auth", response, null, status(response));
}
} else {
failConnect(ctx, "Unexpected response type on channel read, this is a bug - please report. " + msg, null, null, (short) 0);
}
ReferenceCountUtil.release(msg);
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class CompressionTest method doesNotCompressIfDisabledPrepend.
@Test
void doesNotCompressIfDisabledPrepend() {
PrependRequest request = new PrependRequest(timeout, coreContext, cid, retryStrategy, key, longContent, cas, durability, null);
ByteBuf encoded = request.encode(allocator, 0, ctx(false));
assertEquals(0, datatype(encoded));
assertEquals(Unpooled.wrappedBuffer(longContent), body(encoded).get());
ReferenceCountUtil.release(encoded);
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class CompressionTest method doesNotCompressIfTooShortInsert.
@Test
void doesNotCompressIfTooShortInsert() {
InsertRequest request = new InsertRequest(key, shortContent, expiry, flags, timeout, coreContext, cid, retryStrategy, durability, null);
ByteBuf encoded = request.encode(allocator, 0, ctx(true));
assertEquals(0, datatype(encoded));
assertEquals(Unpooled.wrappedBuffer(shortContent), body(encoded).get());
ReferenceCountUtil.release(encoded);
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class DecompressionTest method decompressesGetAndTouch.
@Test
void decompressesGetAndTouch() {
ByteBuf response = decodeHexDump(readResource("compressed_get_and_touch_response.txt", DecompressionTest.class));
long encodedExpiry = 1;
GetAndTouchRequest request = new GetAndTouchRequest("mydoc", Duration.ofSeconds(1), mock(CoreContext.class), CollectionIdentifier.fromDefault("bucket"), BestEffortRetryStrategy.INSTANCE, encodedExpiry, null);
GetAndTouchResponse decoded = request.decode(response, null);
assertEquals(readResource("dummy.json", DecompressionTest.class), new String(decoded.content(), UTF_8));
}
use of com.couchbase.client.core.deps.io.netty.buffer.ByteBuf in project couchbase-jvm-clients by couchbase.
the class DecompressionTest method decompressesReplicaGet.
@Test
void decompressesReplicaGet() {
ByteBuf response = decodeHexDump(readResource("compressed_replica_get_response.txt", DecompressionTest.class));
ReplicaGetRequest request = new ReplicaGetRequest("mydoc", Duration.ofSeconds(1), mock(CoreContext.class), CollectionIdentifier.fromDefault("bucket"), BestEffortRetryStrategy.INSTANCE, (short) 1, null);
GetResponse decoded = request.decode(response, null);
assertEquals(readResource("dummy.json", DecompressionTest.class), new String(decoded.content(), UTF_8));
}
Aggregations