예제 #1
0
 private Template <string, string> AuthorizationHeaderParser(HttpContext context, string authorizationHeader)
 {
     if (AuthenticationUtility.IsAuthenticationSchemeValid(authorizationHeader, Options.AuthenticationScheme) && authorizationHeader.Length > Options.AuthenticationScheme.Length)
     {
         var credentials = authorizationHeader.Remove(0, Options.AuthenticationScheme.Length + 1).Split(':');
         if (credentials.Length == 2)
         {
             var publicKey = credentials[0];
             var signature = credentials[1];
             if (!publicKey.IsNullOrWhiteSpace() && !signature.IsNullOrWhiteSpace())
             {
                 return(TupleUtility.CreateTwo(publicKey, signature));
             }
         }
     }
     return(null);
 }
 private Dictionary <string, string> AuthorizationHeaderParser(HttpContext context, string authorizationHeader)
 {
     if (AuthenticationUtility.IsAuthenticationSchemeValid(authorizationHeader, AuthenticationScheme))
     {
         string   digestCredentials = authorizationHeader.Remove(0, AuthenticationScheme.Length + 1);
         string[] credentials       = digestCredentials.Split(AuthenticationUtility.DigestAuthenticationCredentialSeparator);
         if (IsDigestCredentialsValid(credentials))
         {
             Dictionary <string, string> result = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
             for (int i = 0; i < credentials.Length; i++)
             {
                 string[] credentialPair = StringUtility.Split(credentials[i], "=");
                 result.Add(credentialPair[0].Trim(), Converter.Parse(credentialPair[1], QuotedStringParser));
             }
             return(IsDigestCredentialsValid(result) ? result : null);
         }
     }
     return(null);
 }
예제 #3
0
 private Template <string, string> AuthorizationHeaderParser(HttpContext context, string authorizationHeader)
 {
     if (AuthenticationUtility.IsAuthenticationSchemeValid(authorizationHeader, AuthenticationScheme))
     {
         string base64Credentials = authorizationHeader.Remove(0, AuthenticationScheme.Length + 1);
         if (StringUtility.IsBase64(base64Credentials))
         {
             string[] credentials = StringConverter.FromBytes(Convert.FromBase64String(base64Credentials), options =>
             {
                 options.Encoding = EncodingUtility.AsciiEncoding;
                 options.Preamble = PreambleSequence.Remove;
             }).Split(AuthenticationUtility.BasicAuthenticationCredentialSeparator);
             if (credentials.Length == 2 &&
                 !string.IsNullOrEmpty(credentials[0]) &&
                 !string.IsNullOrEmpty(credentials[1]))
             {
                 return(TupleUtility.CreateTwo(credentials[0], credentials[1]));
             }
         }
     }
     return(null);
 }