コード例 #1
0
        public static async Task <bool> ParseAuthenticationData(HttpRequestMessage req, Stream certBlob)
        {
            dynamic body = await req.Content.ReadAsStringAsync();

            try {
                CertData e = JsonConvert.DeserializeObject <CertData>(body as string);
                return(Authenticate(e, certBlob));
            } catch (Exception) {
                return(false);
            }
        }
コード例 #2
0
 public static bool Authenticate(CertData cert, Stream certBlob)
 {
     try {
         if (certBlob.CanRead)
         {
             using (StreamReader streamReader = new StreamReader(certBlob)) {
                 string fileContent = streamReader.ReadToEnd();
                 fileContent = fileContent.Trim().ReplaceAllCharacters('\n').ReplaceAllCharacters('\r').ToLowerInvariant();
                 cert.Cert   = cert.Cert.Trim().ReplaceAllCharacters('\n').ReplaceAllCharacters('\r').ToLowerInvariant();
                 if (fileContent == cert.Cert)
                 {
                     return(true);
                 }
             }
         }
     } catch (System.IO.IOException) {
         return(false);
     }
     return(false);
 }