public void ProbeKeyActivationResponseTest() { var message = new ProbeKeyActivationResponse(); Assert.AreEqual(message.Kind, MessageKind.ProbeKeyActivationResponse); message.IsExists = true; message.IsExpired = true; message.IsNotAccepted = true; message.IsRevoked = true; var serializer = new ProtocolSerializer(ProtocolVersion.Version10); var data = serializer.Serialize(message); Assert.IsNotNull(data); Assert.AreEqual(serializer.GetMessageInfoOrNull(data).Kind, MessageKind.ProbeKeyActivationResponse); var savedMessage = serializer.DeserializeProbeKeyActivationResponse(data); Assert.IsNotNull(savedMessage); Assert.AreEqual(message.Kind, savedMessage.Kind); Assert.AreEqual(message.IsExists, savedMessage.IsExists); Assert.AreEqual(message.IsExpired, savedMessage.IsExpired); Assert.AreEqual(message.IsNotAccepted, savedMessage.IsNotAccepted); Assert.AreEqual(message.IsRevoked, savedMessage.IsRevoked); }
/// <summary> /// Обработчик запроса на получению информации по регистрации публичных ключей. /// </summary> /// <param name="serializer">Сериализатор протокола.</param> /// <param name="postData">Данные запроса.</param> /// <param name="hostAddress">Адрес клиента.</param> /// <returns>Результат.</returns> private string ProcessProbeKeyActivationRequest(ProtocolSerializer serializer, string postData, string hostAddress) { var request = serializer.DeserializeProbeKeyActivationRequest(postData); _logger.InfoFormat("Получен запрос на проверки регистрации ключа {0} для домена {1} с клиента {2}", request.KeyNumber, request.UserDomainID, hostAddress); var response = new ProbeKeyActivationResponse(); response.IsExists = true; var currentKey = RemontinkaServer.Instance.DataStore.GetPublicKey(request.UserDomainID, request.KeyNumber); if (currentKey != null) { currentKey.IsRevoked = currentKey.IsRevoked; response.UserID = currentKey.UserID; currentKey = RemontinkaServer.Instance.DataStore.GetCurrentPublicKey(currentKey.UserID); if (currentKey != null) { currentKey.IsRevoked = currentKey.IsRevoked; } //if else { response.IsExpired = true; } //else } // else { var keyRequest = RemontinkaServer.Instance.DataStore.GetUserPublicKeyRequest(request.UserDomainID, request.KeyNumber); if (keyRequest != null) { response.IsNotAccepted = true; } //if else { response.IsExists = false; } //else } //if return(serializer.Serialize(response)); }