/** * Tries to authenticate using a random destination ID. * This should fail. * * @param clientId Client ID. * @param cred Authentication credentials. */ void authenticate(const string& clientId, const string& creds) { ObjectWrapper protoMsg; GridAuthenticationRequestCommand authReq; GridClientMessageAuthenticationResult authResult; authReq.setClientId(clientId); authReq.credentials(creds); authReq.setRequestId(1); authReq.setDestinationId(GridClientUuid::randomUuid()); // Random unexistent ID. GridClientProtobufMarshaller::wrap(authReq, protoMsg); GridClientTcpPacket tcpPacket; GridClientTcpPacket tcpResponse; ProtoRequest req; tcpPacket.setData(protoMsg); tcpPacket.setAdditionalHeaders(authReq); send(tcpPacket, tcpResponse); ObjectWrapper respMsg = tcpResponse.getData(); GridClientProtobufMarshaller::unwrap(respMsg, authResult); sessToken = authResult.sessionToken(); }
void GridClientProtobufMarshaller::wrap(const GridAuthenticationRequestCommand& reqCmd, ObjectWrapper& objWrapper) { ProtoAuthenticationRequest authReq; ::ObjectWrapper* value = authReq.mutable_credentials(); GridClientObjectWrapperConvertor::wrapSimpleType(reqCmd.credentials(), *value); wrapRequest(reqCmd, AUTH_REQUEST, authReq, objWrapper); }