コード例 #1
0
        private static string ExtractAlgorithm(string jwt)
        {
            var algorithm = string.Empty;

            if (!string.IsNullOrEmpty(jwt))
            {
                try
                {
                    algorithm = JoseHelper.ExtractJosePartField(jwt, 0, "alg").ToString();
                }
                catch (Exception)
                {
                    // Ignore on purpose
                }
            }
            return(algorithm);
        }
コード例 #2
0
        private static string[] ExtractCertificates(string jwt)
        {
            string[] certificates = new string[0];

            if (!string.IsNullOrEmpty(jwt))
            {
                try
                {
                    var parsedBody         = JoseHelper.ExtractJosePart(jwt, 1);
                    var parsedCertificates = parsedBody["maa-policyCertificates"]["keys"].ToArray();
                    certificates = parsedCertificates.Select(c => c.ToString()).ToArray();
                }
                catch (Exception)
                {
                    // Ignore on purpose
                }
            }

            return(certificates);
        }
コード例 #3
0
        private static (string algorithm, string jku) ExtractHeaders(string jwt)
        {
            var algorithm = "";
            var jku       = "";

            if (!string.IsNullOrEmpty(jwt))
            {
                try
                {
                    var parsedHeader = JoseHelper.ExtractJosePart(jwt, 0);
                    algorithm = parsedHeader["alg"].ToString();
                    jku       = parsedHeader["jku"].ToString();
                }
                catch (Exception)
                {
                    // Ignore on purpose
                }
            }
            return(algorithm, jku);
        }
コード例 #4
0
        private static string ExtractPolicyText(string jwt)
        {
            string parsedPolicy = string.Empty;

            if (!string.IsNullOrEmpty(jwt))
            {
                try
                {
                    parsedPolicy = JoseHelper.ExtractJosePartField(jwt, 1, "AttestationPolicy").ToString();

                    // Policy is optionally double base64 URL encoded.  We will attempt
                    // to base64 URL decode a second time -- if this throws an exception,
                    // that's OK -- we should just use value as it stands now.
                    var doubleDecodedPolicy = Base64Url.DecodeString(parsedPolicy);
                    parsedPolicy = doubleDecodedPolicy;
                }
                catch (Exception)
                {
                    // Ignore on purpose
                }
            }

            return(parsedPolicy);
        }