public WrappedKeySecurityToken(string id, byte[] keyToWrap, string wrappingAlgorithm, System.IdentityModel.Tokens.SecurityToken wrappingToken, System.IdentityModel.Tokens.SecurityKeyIdentifier wrappingTokenReference)
 {
 }
        private System.IdentityModel.Tokens.SecurityToken ReadTokenCore(string token, bool isActorToken)
        {
            Utility.VerifyNonNullOrEmptyStringArgument("token", token);
            if (base.Configuration == null)
            {
                throw new System.InvalidOperationException("No configuration");
            }
            if (base.Configuration.IssuerTokenResolver == null)
            {
                throw new System.InvalidOperationException("No configured IssuerTokenResolver");
            }
            if (!this.CanReadToken(token))
            {
                throw new System.IdentityModel.Tokens.SecurityTokenException("Unsupported security token.");
            }
            string[] array = token.Split(new char[]
            {
                '.'
            });
            string text  = array[0];
            string text2 = array[1];
            string text3 = array[2];

            System.Collections.Generic.Dictionary <string, string> dictionary = new System.Collections.Generic.Dictionary <string, string>(System.StringComparer.Ordinal);
            dictionary.DecodeFromJson(Base64UrlEncoder.Decode(text));
            System.Collections.Generic.Dictionary <string, string> dictionary2 = new System.Collections.Generic.Dictionary <string, string>(System.StringComparer.Ordinal);
            dictionary2.DecodeFromJson(Base64UrlEncoder.Decode(text2));
            string text4;

            dictionary.TryGetValue("alg", out text4);
            System.IdentityModel.Tokens.SecurityToken issuerToken = null;
            if (!System.StringComparer.Ordinal.Equals(text4, "none"))
            {
                if (string.IsNullOrEmpty(text3))
                {
                    throw new System.IdentityModel.Tokens.SecurityTokenException("Missing signature.");
                }
                System.IdentityModel.Tokens.SecurityKeyIdentifier signingKeyIdentifier = this.GetSigningKeyIdentifier(dictionary, dictionary2);
                System.IdentityModel.Tokens.SecurityToken         securityToken;
                base.Configuration.IssuerTokenResolver.TryResolveToken(signingKeyIdentifier, out securityToken);
                if (securityToken == null)
                {
                    throw new System.IdentityModel.Tokens.SecurityTokenException("Invalid JWT token. Could not resolve issuer token.");
                }
                issuerToken = this.VerifySignature(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}.{1}", new object[]
                {
                    text,
                    text2
                }), text3, text4, securityToken);
            }
            JsonWebSecurityToken actorToken = null;

            if (!isActorToken)
            {
                actorToken = this.ReadActor(dictionary2);
            }
            string text5;

            dictionary2.TryGetValue("iss", out text5);
            if (string.IsNullOrEmpty(text5))
            {
                throw new System.IdentityModel.Tokens.SecurityTokenValidationException("The token being parsed does not have an issuer.");
            }
            string text6;

            dictionary2.TryGetValue("aud", out text6);
            if (string.IsNullOrEmpty(text6))
            {
                throw new System.IdentityModel.Tokens.SecurityTokenValidationException("The token being parsed does not have an audience.");
            }
            string text7;

            dictionary2.TryGetValue("nbf", out text7);
            if (string.IsNullOrEmpty(text7))
            {
                throw new System.IdentityModel.Tokens.SecurityTokenValidationException("The token being parsed does not have an 'not before' claim.");
            }
            System.DateTime dateTimeFromSeconds = this.GetDateTimeFromSeconds(text7);
            text7 = "";
            dictionary2.TryGetValue("exp", out text7);
            if (string.IsNullOrEmpty(text7))
            {
                throw new System.IdentityModel.Tokens.SecurityTokenValidationException("The token being parsed does not have an 'expires at' claim.");
            }
            System.DateTime      dateTimeFromSeconds2 = this.GetDateTimeFromSeconds(text7);
            JsonWebSecurityToken jsonWebSecurityToken = new JsonWebSecurityToken(text5, text6, dateTimeFromSeconds, dateTimeFromSeconds2, this.CreateClaims(dictionary2), issuerToken, actorToken);

            jsonWebSecurityToken.CaptureSourceData(token);
            return(jsonWebSecurityToken);
        }
Beispiel #3
0
 protected override bool TryResolveTokenCore(System.IdentityModel.Tokens.SecurityKeyIdentifier keyIdentifier, out System.IdentityModel.Tokens.SecurityToken token)
 {
     return(base.TryResolveTokenCore(keyIdentifier, out token));
 }
        protected override bool TryResolveTokenCore(System.IdentityModel.Tokens.SecurityKeyIdentifier keyIdentifier, out System.IdentityModel.Tokens.SecurityToken token)
        {
            token = default(System.IdentityModel.Tokens.SecurityToken);

            return(default(bool));
        }
 protected override bool CanWriteKeyIdentifierCore(System.IdentityModel.Tokens.SecurityKeyIdentifier keyIdentifier)
 {
     return(default(bool));
 }
 protected override void WriteKeyIdentifierCore(System.Xml.XmlWriter writer, System.IdentityModel.Tokens.SecurityKeyIdentifier keyIdentifier)
 {
 }
 protected override bool TryResolveTokenCore(System.IdentityModel.Tokens.SecurityKeyIdentifier keyIdentifier, out System.IdentityModel.Tokens.SecurityToken token)
 {
     throw new NotImplementedException();
 }