コード例 #1
0
        public static string AuthenticateRequest(PlantDexHttpRequest request)
        {
            string cLevel  = request.commandLevel;
            string source  = request.source;
            string command = request.command;
            string digest  = request.digest;
            string rawDigest;

            if (cLevel == "admin")
            {
                rawDigest = cLevel + ":" + source + ":" + command + ":" + GlobalEssentials.ADMIN_AUTH_KEY;
            }
            else if (cLevel == "client")
            {
                rawDigest = cLevel + ":" + source + ":" + command + ":" + GlobalEssentials.CLIENT_AUTH_KEY;
            }
            else
            {
                return("fail");
            }

            if (Hash(rawDigest) == digest)
            {
                return("success");
            }

            return("fail");
        }
コード例 #2
0
        public static void SaveRequest(PlantDexHttpRequest request, string status)
        {
            try
            {
                SqlConnection con = ConnectionManager.GetConnection();
                SqlCommand    com = new SqlCommand("INSERT INTO HttpRequests(RequestSource, RequestCommand, RequestLevel, timestamp, RequestStatus) VALUES(@RequestSource, @RequestCommand, @RequestLevel, GETDATE(), @RequestStatus)", con);
                com.Parameters.AddWithValue("@RequestSource", request.source);
                com.Parameters.AddWithValue("@RequestCommand", request.command);
                com.Parameters.AddWithValue("@RequestLevel", request.commandLevel);
                com.Parameters.AddWithValue("@RequestStatus", status);
                com.ExecuteNonQuery();

                con.Close();
            }
            catch (Exception ex)
            {
            }
        }