use of org.apache.ignite.client.ClientAuthenticationException in project ignite by apache.
the class AdditionalSecurityCheckTest method testClientInfoIgniteClientFail.
/**
*/
@Test
public void testClientInfoIgniteClientFail() throws Exception {
Ignite ignite = startGrids(2);
assertEquals(2, ignite.cluster().topologyVersion());
startGrid(2);
assertEquals(3, ignite.cluster().topologyVersion());
fail = true;
try (IgniteClient client = Ignition.startClient(getClientConfiguration())) {
fail();
} catch (ClientAuthenticationException e) {
assertTrue(e.getMessage().contains("Client version is not found"));
}
}
use of org.apache.ignite.client.ClientAuthenticationException in project ignite by apache.
the class TcpClientChannel method handshakeRes.
/**
* Receive and handle handshake response.
*/
private void handshakeRes(ByteBuffer buf, ProtocolVersion proposedVer, String user, String pwd, Map<String, String> userAttrs) throws ClientConnectionException, ClientAuthenticationException, ClientProtocolError {
BinaryInputStream res = BinaryByteBufferInputStream.create(buf);
try (BinaryReaderExImpl reader = ClientUtils.createBinaryReader(null, res)) {
boolean success = res.readBoolean();
if (success) {
byte[] features = EMPTY_BYTES;
if (ProtocolContext.isFeatureSupported(proposedVer, BITMAP_FEATURES))
features = reader.readByteArray();
protocolCtx = new ProtocolContext(proposedVer, ProtocolBitmaskFeature.enumSet(features));
if (protocolCtx.isFeatureSupported(PARTITION_AWARENESS)) {
// Reading server UUID
srvNodeId = reader.readUuid();
}
} else {
ProtocolVersion srvVer = new ProtocolVersion(res.readShort(), res.readShort(), res.readShort());
String err = reader.readString();
int errCode = ClientStatus.FAILED;
if (res.remaining() > 0)
errCode = reader.readInt();
if (errCode == ClientStatus.AUTH_FAILED)
throw new ClientAuthenticationException(err);
else if (proposedVer.equals(srvVer))
throw new ClientProtocolError(err);
else if (!supportedVers.contains(srvVer) || (!ProtocolContext.isFeatureSupported(srvVer, AUTHORIZATION) && !F.isEmpty(user)))
// authentication and authentication is required.
throw new ClientProtocolError(String.format("Protocol version mismatch: client %s / server %s. Server details: %s", proposedVer, srvVer, err));
else {
// Retry with server version.
handshake(srvVer, user, pwd, userAttrs);
}
}
} catch (IOException e) {
throw handleIOError(e);
}
}
Aggregations