use of org.apache.zookeeper_voltpatches.data.Id in project voltdb by VoltDB.
the class ZooKeeperMain method parseACLs.
private static List<ACL> parseACLs(String aclString) {
List<ACL> acl;
String[] acls = aclString.split(",");
acl = new ArrayList<ACL>();
for (String a : acls) {
int firstColon = a.indexOf(':');
int lastColon = a.lastIndexOf(':');
if (firstColon == -1 || lastColon == -1 || firstColon == lastColon) {
System.err.println(a + " does not have the form scheme:id:perm");
continue;
}
ACL newAcl = new ACL();
newAcl.setId(new Id(a.substring(0, firstColon), a.substring(firstColon + 1, lastColon)));
newAcl.setPerms(getPermFromString(a.substring(lastColon + 1)));
acl.add(newAcl);
}
return acl;
}
use of org.apache.zookeeper_voltpatches.data.Id in project voltdb by VoltDB.
the class Id method equals.
@Override
public boolean equals(Object peer_) {
if (!(peer_ instanceof Id)) {
return false;
}
if (peer_ == this) {
return true;
}
Id peer = (Id) peer_;
boolean ret = false;
ret = scheme.equals(peer.scheme);
if (!ret)
return ret;
ret = id.equals(peer.id);
if (!ret)
return ret;
return ret;
}
use of org.apache.zookeeper_voltpatches.data.Id in project voltdb by VoltDB.
the class ZooKeeperServer method fixupACL.
/**
* This method checks out the acl making sure it isn't null or empty, it has
* valid schemes and ids, and expanding any relative ids that depend on the
* requestor's authentication information.
*
* @param authInfo
* list of ACL IDs associated with the client connection
* @param acl
* list of ACLs being assigned to the node (create or setACL
* operation)
* @return
*/
private boolean fixupACL(List<Id> authInfo, List<ACL> acl) {
if (skipACL) {
return true;
}
if (acl == null || acl.size() == 0) {
return false;
}
Iterator<ACL> it = acl.iterator();
LinkedList<ACL> toAdd = null;
while (it.hasNext()) {
ACL a = it.next();
Id id = a.getId();
if (id.getScheme().equals("world") && id.getId().equals("anyone")) {
// wide open
} else if (id.getScheme().equals("auth")) {
// This is the "auth" id, so we have to expand it to the
// authenticated ids of the requestor
it.remove();
if (toAdd == null) {
toAdd = new LinkedList<ACL>();
}
boolean authIdValid = false;
for (Id cid : authInfo) {
AuthenticationProvider ap = ProviderRegistry.getProvider(cid.getScheme());
if (ap == null) {
LOG.error("Missing AuthenticationProvider for " + cid.getScheme());
} else if (ap.isAuthenticated()) {
authIdValid = true;
toAdd.add(new ACL(a.getPerms(), cid));
}
}
if (!authIdValid) {
return false;
}
} else {
AuthenticationProvider ap = ProviderRegistry.getProvider(id.getScheme());
if (ap == null) {
return false;
}
if (!ap.isValid(id.getId())) {
return false;
}
}
}
if (toAdd != null) {
for (ACL a : toAdd) {
acl.add(a);
}
}
return acl.size() > 0;
}
use of org.apache.zookeeper_voltpatches.data.Id in project voltdb by VoltDB.
the class IPAuthenticationProvider method handleAuthentication.
public KeeperException.Code handleAuthentication(ServerCnxn cnxn, byte[] authData) {
String id = cnxn.getRemoteAddress().getAddress().getHostAddress();
cnxn.getAuthInfo().add(new Id(getScheme(), id));
return KeeperException.Code.OK;
}
use of org.apache.zookeeper_voltpatches.data.Id in project voltdb by VoltDB.
the class AgreementTaskMessage method initFromBuffer.
@Override
public void initFromBuffer(ByteBuffer buf) {
m_txnId = buf.getLong();
m_initiatorHSId = buf.getLong();
m_lastSafeTxnId = buf.getLong();
long sessionId = buf.getLong();
int cxid = buf.getInt();
int type = buf.getInt();
int requestBytesLength = buf.getInt();
ByteBuffer requestBuffer = null;
if (requestBytesLength > -1) {
int oldlimit = buf.limit();
int oldposition = buf.position();
buf.limit(buf.position() + requestBytesLength);
requestBuffer = buf.slice();
buf.limit(oldlimit);
buf.position(oldposition + requestBytesLength);
}
m_request = new Request(null, sessionId, cxid, type, requestBuffer, ImmutableList.<Id>of());
assert (buf.capacity() == buf.position());
}
Aggregations