public void TestDLLVersion()
        {
            var version = typeof(EnvironmentUtil).Assembly.GetName().Version.ToString();

            Assert.True(version.StartsWith(EnvironmentUtil.GetDllVersion()));
            Assert.False(EnvironmentUtil.GetDllVersion().EndsWith(".0"));
        }
        private void ManagerAuthenticator(ClientConnection connection)
        {
            Logger.Finest("Authenticating against the owner node");
            var ss = _client.GetSerializationService();

            string uuid      = null;
            string ownerUuid = null;

            if (_principal != null)
            {
                uuid      = _principal.GetUuid();
                ownerUuid = _principal.GetOwnerUuid();
            }
            ClientMessage request;

            if (_credentials is UsernamePasswordCredentials)
            {
                var usernamePasswordCr = (UsernamePasswordCredentials)_credentials;
                request = ClientAuthenticationCodec.EncodeRequest(usernamePasswordCr.GetUsername(),
                                                                  usernamePasswordCr.GetPassword(), uuid, ownerUuid, true,
                                                                  ClientTypes.Csharp, _client.GetSerializationService().GetVersion(), EnvironmentUtil.GetDllVersion());
            }
            else
            {
                var data = ss.ToData(_credentials);
                request = ClientAuthenticationCustomCodec.EncodeRequest(data, uuid, ownerUuid, false,
                                                                        ClientTypes.Csharp, _client.GetSerializationService().GetVersion(), EnvironmentUtil.GetDllVersion());
            }

            IClientMessage response;

            try
            {
                var invocationService = (ClientInvocationService)_client.GetInvocationService();
                response = ThreadUtil.GetResult(invocationService.InvokeOnConnection(request, connection));
            }
            catch (Exception e)
            {
                throw ExceptionUtil.Rethrow(e);
            }
            var result = ClientAuthenticationCodec.DecodeResponse(response);

            if (result.address == null)
            {
                throw new HazelcastException("Could not resolve address for owner node.");
            }

            var member = new Member(result.address, result.ownerUuid);

            _principal = new ClientPrincipal(result.uuid, result.ownerUuid);

            connection.Member = member;
            connection.SetOwner();
        }
示例#3
0
        private void ClusterAuthenticator(ClientConnection connection)
        {
            var ss             = _client.GetSerializationService();
            var clusterService = (ClientClusterService)_client.GetClientClusterService();
            var principal      = clusterService.GetPrincipal();

            var           uuid      = principal.GetUuid();
            var           ownerUuid = principal.GetOwnerUuid();
            ClientMessage request;

            var usernamePasswordCr = _credentials as UsernamePasswordCredentials;

            if (usernamePasswordCr != null)
            {
                request = ClientAuthenticationCodec.EncodeRequest(usernamePasswordCr.GetUsername(),
                                                                  usernamePasswordCr.GetPassword(), uuid, ownerUuid, false,
                                                                  ClientTypes.Csharp, _client.GetSerializationService().GetVersion(), EnvironmentUtil.GetDllVersion());
            }
            else
            {
                var data = ss.ToData(_credentials);
                request = ClientAuthenticationCustomCodec.EncodeRequest(data, uuid, ownerUuid, false,
                                                                        ClientTypes.Csharp, _client.GetSerializationService().GetVersion(), EnvironmentUtil.GetDllVersion());
            }

            IClientMessage response;

            try
            {
                var future = ((ClientInvocationService)_client.GetInvocationService()).InvokeOnConnection(request,
                                                                                                          connection);
                response = ThreadUtil.GetResult(future);
            }
            catch (Exception e)
            {
                throw ExceptionUtil.Rethrow(e);
            }
            var rp = ClientAuthenticationCodec.DecodeResponse(response);

            if (rp.address == null)
            {
                throw new HazelcastException("Could not resolve address for member.");
            }

            var member = _client.GetClientClusterService().GetMember(rp.address);

            if (member == null)
            {
                throw new HazelcastException("Node with address '" + rp.address + "' was not found in the member list");
            }
            connection.Member = member;
        }