public static string encryptedCookie = "QWE";
public static bool IsCorrectlyEncrypted = true;
public static string Username = "CevaUsername";
public static bool IsExpired = true;
public static void Main()
var loginController = new LoginController();
public class LoginController
private readonly Logger logger;
private readonly Decryptor decryptor;
this.logger = new Logger();
this.decryptor = new Decryptor();
var cookie = encryptedCookie;
this.logger.Log(string.Format("Trying to log in user with cookie {0}", cookie));
this.logger.Log("Cookie not found");
var decryptedCookie = this.decryptor.Decrypt(cookie);
if (decryptedCookie == null)
this.logger.Log("Invalid cookie");
if (decryptedCookie.IsExpired)
this.logger.Log("Expired cookie");
this.logger.Log(string.Format("Successfully logged in user {0}", decryptedCookie.Username));
public void Log(string message)
Console.WriteLine(message);
public Cookie Decrypt(string input)
return IsCorrectlyEncrypted ? new Cookie(Username, IsExpired) : null;
public Cookie(string username, bool isExpired)
this.Username = username;
this.IsExpired = isExpired;
public string Username { get; private set; }
public bool IsExpired { get; private set; }