use of org.apache.zookeeper_voltpatches.proto.AuthPacket in project voltdb by VoltDB.
the class AuthPacket method equals.
@Override
public boolean equals(Object peer_) {
if (!(peer_ instanceof AuthPacket)) {
return false;
}
if (peer_ == this) {
return true;
}
AuthPacket peer = (AuthPacket) peer_;
boolean ret = false;
ret = (type == peer.type);
if (!ret)
return ret;
ret = scheme.equals(peer.scheme);
if (!ret)
return ret;
ret = org.apache.jute_voltpatches.Utils.bufEquals(auth, peer.auth);
if (!ret)
return ret;
return ret;
}
use of org.apache.zookeeper_voltpatches.proto.AuthPacket in project voltdb by VoltDB.
the class AuthPacket method compareTo.
public int compareTo(Object peer_) throws ClassCastException {
if (!(peer_ instanceof AuthPacket)) {
throw new ClassCastException("Comparing different types of records.");
}
AuthPacket peer = (AuthPacket) peer_;
int ret = 0;
ret = (type == peer.type) ? 0 : ((type < peer.type) ? -1 : 1);
if (ret != 0)
return ret;
ret = scheme.compareTo(peer.scheme);
if (ret != 0)
return ret;
{
byte[] my = auth;
byte[] ur = peer.auth;
ret = org.apache.jute_voltpatches.Utils.compareBytes(my, 0, my.length, ur, 0, ur.length);
}
if (ret != 0)
return ret;
return ret;
}
use of org.apache.zookeeper_voltpatches.proto.AuthPacket in project voltdb by VoltDB.
the class ClientCnxn method addAuthInfo.
public void addAuthInfo(String scheme, byte[] auth) {
if (!zooKeeper.state.isAlive()) {
return;
}
authInfo.add(new AuthData(scheme, auth));
queuePacket(new RequestHeader(-4, OpCode.auth), null, new AuthPacket(0, scheme, auth), null, null, null, null, null, null);
}
use of org.apache.zookeeper_voltpatches.proto.AuthPacket in project voltdb by VoltDB.
the class NIOServerCnxn method readRequest.
private void readRequest() throws IOException {
// We have the request, now process and setup for next
InputStream bais = new ByteBufferInputStream(incomingBuffer);
BinaryInputArchive bia = BinaryInputArchive.getArchive(bais);
RequestHeader h = new RequestHeader();
h.deserialize(bia, "header");
// Through the magic of byte buffers, txn will not be
// pointing
// to the start of the txn
incomingBuffer = incomingBuffer.slice();
if (h.getType() == OpCode.auth) {
AuthPacket authPacket = new AuthPacket();
ZooKeeperServer.byteBuffer2Record(incomingBuffer, authPacket);
String scheme = authPacket.getScheme();
AuthenticationProvider ap = ProviderRegistry.getProvider(scheme);
if (ap == null || (ap.handleAuthentication(this, authPacket.getAuth()) != KeeperException.Code.OK)) {
if (ap == null) {
LOG.warn("No authentication provider for scheme: " + scheme + " has " + ProviderRegistry.listProviders());
} else {
LOG.warn("Authentication failed for scheme: " + scheme);
}
// send a response...
ReplyHeader rh = new ReplyHeader(h.getXid(), 0, KeeperException.Code.AUTHFAILED.intValue());
sendResponse(rh, null, null);
// ... and close connection
sendCloseSession();
disableRecv();
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Authentication succeeded for scheme: " + scheme);
}
ReplyHeader rh = new ReplyHeader(h.getXid(), 0, KeeperException.Code.OK.intValue());
sendResponse(rh, null, null);
}
return;
} else {
Request si = new Request(this, sessionId, h.getXid(), h.getType(), incomingBuffer, authInfo);
si.setOwner(ServerCnxn.me);
zk.submitRequest(si);
}
if (h.getXid() >= 0) {
synchronized (this) {
outstandingRequests++;
}
synchronized (this.factory) {
// check throttling
if (zk.getInProcess() > factory.outstandingLimit) {
if (LOG.isDebugEnabled()) {
LOG.debug("Throttling recv " + zk.getInProcess());
}
disableRecv();
// following lines should not be needed since we are
// already reading
// } else {
// enableRecv();
}
}
}
}
Aggregations