protected internal override string DoInvoke(ServiceProxyInvokeEventArgs args) { string baseAddress = args.BaseAddress; string className = args.ClassName; string methodName = args.MethodName; object[] parameters = args.PostParameters; ServiceProxyInvokeEventArgs secureChannelArgs = new ServiceProxyInvokeEventArgs { Cuid = args.Cuid, BaseAddress = baseAddress, ClassName = typeof(SecureChannel).Name, MethodName = "Invoke", PostParameters = new object[] { className, methodName, ApiParameters.ParametersToJsonParamsObjectString(parameters) } }; try { SecureChannelMessage <string> result = Post(secureChannelArgs).FromJson <SecureChannelMessage <string> >(); if (result.Success) { Decrypted decrypted = new Decrypted(result.Data, SessionKey, SessionIV); return(decrypted.Value); } else { string properties = result.PropertiesToString(); throw new ServiceProxyInvocationFailedException("{0}"._Format(result.Message, properties)); } } catch (Exception ex) { args.Exception = ex; args.Message = ex.Message; OnInvocationException(args); } return(string.Empty); }
private static void ValidateEncryptedToken(IHttpContext context, Decrypted input, List <ValidationFailures> failures, List <string> messages) { if (input != null) { try { EncryptedTokenValidationStatus tokenStatus = ApiEncryptionValidation.ValidateEncryptedToken(context, input.Value); switch (tokenStatus) { case EncryptedTokenValidationStatus.Unkown: failures.Add(ServiceProxy.ValidationFailures.UnknownTokenValidationResult); messages.Add("ApiEncryptionValidation.ValidateToken failed"); break; case EncryptedTokenValidationStatus.HashFailed: failures.Add(ServiceProxy.ValidationFailures.TokenHashFailed); messages.Add("ApiEncryptionValidation.ValidateToken failed: TokenHashFailed"); break; case EncryptedTokenValidationStatus.NonceFailed: failures.Add(ServiceProxy.ValidationFailures.TokenNonceFailed); messages.Add("ApiEncryptionValidation.ValidateToken failed: TokenNonceFailed"); break; case EncryptedTokenValidationStatus.Success: break; } } catch (Exception ex) { failures.Add(ServiceProxy.ValidationFailures.TokenValidationError); messages.Add(ex.Message); } } }
private void Decode_Click(object sender, EventArgs e) { Decrypted.Clear(); Decode caesars = new Decode(); Decrypted.Text = caesars.DecodeCaesar(Encrypted.Text); }
private void Reset_Click(object sender, EventArgs e) { Message.Clear(); Key.Clear(); Encrypted.Clear(); Decrypted.Clear(); }
public static void Main(string[] args) { Encrypted encrypted = new Encrypted(); Decrypted decrypted = new Decrypted(); Key key = new Key(); key.AddKey(); while (true) { ShowOptions(); int choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: decrypted.DecryptedText(ChoiceSearch.search); break; case 2: Console.Write("Введите наименование: "); string tittle = Console.ReadLine(); Console.Write("\nВведите пароль: "); string password = Console.ReadLine(); Console.Write("\nВведите наименование: "); string description = Console.ReadLine(); encrypted.EncryptedText(tittle, password, description); break; case 3: decrypted.DecryptedText(ChoiceSearch.all); break; case 4: return; break; default: ShowOptionsError(); break; } } }
internal void Execute(IHttpContext context, Decrypted input) { List <ValidationFailures> failures = new List <ValidationFailures>(); List <string> messages = new List <string>(); ValidateEncryptedToken(context, input, failures, messages); ValidateClassName(failures, messages); ValidateTargetType(failures, messages); ValidateMethodName(failures, messages); ValidateMethodExists(failures, messages); ValidateLocalExcludeMethod(context, failures, messages); ValidateParameterCount(failures, messages); ValidateMethodRoles(context, failures, messages); ValidateClassRoles(context, failures, messages); ValidateApiKeyToken(failures, messages); ValidationFailures = failures.ToArray(); Message = messages.ToArray().ToDelimited(s => s, Delimiter); this.Success = failures.Count == 0; }
internal DomainLicense(byte[] encryptedLicense, LicenseVerifier v) { Decrypted = v.Decrypt(encryptedLicense); Encrypted = encryptedLicense; string[] lines = Decrypted.Split('\n'); foreach (string l in lines) { int colon = l.IndexOf(':'); if (colon < 1) { continue; } string key = l.Substring(0, colon).Trim().ToLowerInvariant(); string value = l.Substring(colon + 1).Trim(); switch (key) { case "domain": Domain = value; break; case "owner": OwnerName = value; break; case "issued": Issued = DateTime.Parse(value); break; case "expires": Expires = DateTime.Parse(value); break; case "features": List <Guid> ids = new List <Guid>(); string[] parts = value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string p in parts) { ids.Add(new Guid(p)); } Features = ids; break; } } }
/// <summary> /// Perform symmetric decryption on the specified cipher /// </summary> /// <param name="cipher"></param> /// <returns></returns> public string Decrypt(string cipher) { Decrypted decryptor = new Decrypted(cipher, PlainSymmetricKey, PlainSymmetricIV); return(decryptor.Value); }
/// <summary> /// Perform symmetric decryption on the specified cipher /// </summary> /// <param name="cipher"></param> /// <param name="decrypted"></param> /// <returns></returns> public string Decrypt(string cipher, out Decrypted decrypted) { decrypted = new Decrypted(cipher, PlainSymmetricKey, PlainSymmetricIV); return(decrypted.Value); }