use of org.apache.ignite.plugin.security.SecurityCredentials in project ignite by apache.
the class ZookeeperDiscoveryImpl method authenticateNode.
/**
* @param node Node.
* @return Validation result.
*/
private ZkNodeValidateResult authenticateNode(ZookeeperClusterNode node) {
DiscoverySpiNodeAuthenticator nodeAuth = spi.getAuthenticator();
if (nodeAuth == null)
return new ZkNodeValidateResult((byte[]) null);
SecurityCredentials cred;
try {
cred = unmarshalCredentials(node);
} catch (Exception e) {
U.error(log, "Failed to unmarshal node credentials: " + e, e);
return new ZkNodeValidateResult("Failed to unmarshal node credentials");
}
SecurityContext subj = nodeAuth.authenticateNode(node, cred);
if (subj == null) {
U.warn(log, "Authentication failed [nodeId=" + node.id() + ", addrs=" + U.addressesAsString(node) + ']');
// Note: exception message test is checked in tests.
return new ZkNodeValidateResult("Authentication failed");
}
if (!(subj instanceof Serializable)) {
U.warn(log, "Authentication subject is not Serializable [nodeId=" + node.id() + ", addrs=" + U.addressesAsString(node) + ']');
return new ZkNodeValidateResult("Authentication subject is not serializable");
}
byte[] secSubjZipBytes;
try {
secSubjZipBytes = marshalZip(subj);
node.setAttributes(withSecurityContext(subj, node.getAttributes(), marsh));
} catch (Exception e) {
U.error(log, "Failed to marshal node security subject: " + e, e);
return new ZkNodeValidateResult("Failed to marshal node security subject");
}
return new ZkNodeValidateResult(secSubjZipBytes);
}
Aggregations