Search in sources :

Example 21 with SecurityCredentials

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);
}
Also used : SecurityCredentials(org.apache.ignite.plugin.security.SecurityCredentials) Serializable(java.io.Serializable) SecurityUtils.withSecurityContext(org.apache.ignite.internal.processors.security.SecurityUtils.withSecurityContext) SecurityContext(org.apache.ignite.internal.processors.security.SecurityContext) DiscoverySpiNodeAuthenticator(org.apache.ignite.spi.discovery.DiscoverySpiNodeAuthenticator) IgniteClientDisconnectedException(org.apache.ignite.IgniteClientDisconnectedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) DataFormatException(java.util.zip.DataFormatException) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) KeeperException(org.apache.zookeeper.KeeperException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

SecurityCredentials (org.apache.ignite.plugin.security.SecurityCredentials)21 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 SecurityCredentialsBasicProvider (org.apache.ignite.plugin.security.SecurityCredentialsBasicProvider)5 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 SecurityContext (org.apache.ignite.internal.processors.security.SecurityContext)4 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 UUID (java.util.UUID)3 IgniteClientDisconnectedException (org.apache.ignite.IgniteClientDisconnectedException)3 IgniteException (org.apache.ignite.IgniteException)3 IgniteInterruptedException (org.apache.ignite.IgniteInterruptedException)3 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)3 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)3 IgniteKernal (org.apache.ignite.internal.IgniteKernal)3 GridClient (org.apache.ignite.internal.client.GridClient)3 GridClientConfiguration (org.apache.ignite.internal.client.GridClientConfiguration)3 AuthenticationContext (org.apache.ignite.plugin.security.AuthenticationContext)3 Map (java.util.Map)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2