예제 #1
0
        private static void AddConfirmationData(Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityToken token)
        {
            var confirmationData = new Microsoft.IdentityModel.Tokens.Saml2.Saml2SubjectConfirmationData
            {
                Recipient    = new Uri(assertionConsumerEndpoint),
                NotOnOrAfter = DateTime.UtcNow.AddMinutes(tokenLifetime),
            };

            token.Assertion.Subject.SubjectConfirmations.Add(new Microsoft.IdentityModel.Tokens.Saml2.Saml2SubjectConfirmation(
                                                                 Saml2Constants.ConfirmationMethods.Bearer, confirmationData));
        }
        /// <summary>
        /// Initializes an instance of <see cref="Saml2SubjectConfirmation"/> from a <see cref="Uri"/> indicating the
        /// method of confirmation and <see cref="Saml2SubjectConfirmationData"/>.
        /// </summary>
        /// <param name="method">The <see cref="Uri"/> to use for initialization.</param>
        /// <param name="subjectConfirmationData">The <see cref="Saml2SubjectConfirmationData"/> to use for initialization.</param>
        public Saml2SubjectConfirmation(Uri method, Saml2SubjectConfirmationData subjectConfirmationData)
        {
            if (method == null)
            {
                throw LogArgumentNullException(nameof(method));
            }

            if (!method.IsAbsoluteUri)
            {
                throw LogExceptionMessage(new ArgumentException(FormatInvariant(LogMessages.IDX13300, nameof(method), method), nameof(method)));
            }

            _method = method;
            SubjectConfirmationData = subjectConfirmationData;
        }