public string Sign(ClientCredentialWrapper credential, bool sendCertificate)
        {
            // Base64Url encoded header and claims
            string token = Encode(credential, sendCertificate);

            // Length check before sign
            if (MaxTokenLength < token.Length)
            {
                throw new MsalException(MsalError.EncodedTokenTooLong);
            }

            return(string.Concat(token, ".", UrlEncodeSegment(credential.Sign(_cryptographyManager, token))));
        }
            public JWTHeaderWithCertificate(ClientCredentialWrapper credential, bool sendCertificate)
                : base(credential)
            {
                X509CertificateThumbprint      = Credential.Thumbprint;
                X509CertificatePublicCertValue = null;

                if (!sendCertificate)
                {
                    return;
                }

#if DESKTOP
                X509CertificatePublicCertValue = Convert.ToBase64String(credential.Certificate.GetRawCertData());
#else
                X509CertificatePublicCertValue = Convert.ToBase64String(credential.Certificate.RawData);
#endif
            }
        private static string EncodeHeaderToJson(ClientCredentialWrapper credential, bool sendCertificate)
        {
            JWTHeaderWithCertificate header = new JWTHeaderWithCertificate(credential, sendCertificate);

            return(JsonHelper.SerializeToJson(header));
        }
 public JWTHeader(ClientCredentialWrapper credential)
 {
     Credential = credential;
 }