public string getMockToken() { AuthenticationInstance ai = new AuthenticationInstance(); ai.UserName = "******"; ai.PassWord = "******"; ai.TimeStamp = 1; return(AuthenticationUtil.GenCookieToken(ai)); }
static void Main(string[] args) { AuthenticationInstance ai = new AuthenticationInstance(); ai.UserName = "******"; ai.PassWord = "******"; ai.TimeStamp = 1; string token = AuthenticationUtil.GenCookieToken(ai); AuthenticationUtil.Verify(token); }
static void Main(string[] args) { string json = "{\"UserName\":\"a\",\"PassWord\":\"b@@##$?b\",\"TimeStamp\":1}"; DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(AuthenticationInstance)); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json)); AuthenticationInstance aii = ser.ReadObject(ms) as AuthenticationInstance; string token = AuthenticationUtil.GenCookieToken(aii); //AuthenticationUtil. //string tokdden=@"FoluB\/oYyXPTbFCRTrJMbwBodY4jR1RwVtGSXCtrxa4OjeIsovSI0nihqPXllAUdHTW9dNuOuaIk5Xb93dqDG6Ld6qnuRTeuXp0hpFrbwkwOataMcS2NwE9NCcgQZlH4IjdCjds7euP5kxzWjPVmWiP67YJz4zVQieQ6iJDLEIs="; AuthenticationUtil.Verify(token); }
public string Authenticate(AuthenticationInstance ai) { EventLog log = new EventLog("MyEvent"); // 首先应判断日志来源是否存在,一个日志来源只能同时与一个事件绑定s if (!EventLog.SourceExists("New Application")) { EventLog.CreateEventSource("New Application", "MyEvent"); } log.Source = "New Application"; log.WriteEntry("authenticate:" + ai.UserName, EventLogEntryType.Information); log.WriteEntry("authenticate:" + ai.PassWord, EventLogEntryType.Information); Console.WriteLine(ai.UserName); Console.WriteLine(ai.PassWord); string token = AuthenticationUtil.GenCookieToken(ai); //AuthenticationUtil.Verify(token); return(token); }