public void SetSessionTokenAuthenticator(UniqueId sessionId, SecurityTokenAuthenticator sessionTokenAuthenticator, SecurityTokenResolver sessionTokenResolver)
        {
            this.CommunicationObject.ThrowIfDisposedOrImmutable();
            this.sessionId            = sessionId;
            this.sessionTokenResolver = sessionTokenResolver;
            Collection <SecurityTokenResolver> tmp = new Collection <SecurityTokenResolver>();

            tmp.Add(this.sessionTokenResolver);
            this.sessionTokenResolverList  = new ReadOnlyCollection <SecurityTokenResolver>(tmp);
            this.sessionTokenAuthenticator = sessionTokenAuthenticator;
            SupportingTokenAuthenticatorSpecification spec = new SupportingTokenAuthenticatorSpecification(this.sessionTokenAuthenticator, this.sessionTokenResolver, SecurityTokenAttachmentMode.Endorsing, this.Factory.SecurityTokenParameters);

            this.sessionTokenAuthenticatorSpecificationList = new Collection <SupportingTokenAuthenticatorSpecification>();
            this.sessionTokenAuthenticatorSpecificationList.Add(spec);
        }
Example #2
0
 private void AddSupportingTokenAuthenticators(SupportingTokenParameters supportingTokenParameters, bool isOptional, IList <SupportingTokenAuthenticatorSpecification> authenticatorSpecList)
 {
     for (int i = 0; i < supportingTokenParameters.Endorsing.Count; ++i)
     {
         SecurityTokenRequirement requirement = this.CreateRecipientSecurityTokenRequirement(supportingTokenParameters.Endorsing[i], SecurityTokenAttachmentMode.Endorsing);
         try
         {
             CoreWCF.IdentityModel.Selectors.SecurityTokenResolver      resolver;
             CoreWCF.IdentityModel.Selectors.SecurityTokenAuthenticator authenticator = this.SecurityTokenManager.CreateSecurityTokenAuthenticator(requirement, out resolver);
             SupportingTokenAuthenticatorSpecification authenticatorSpec = new SupportingTokenAuthenticatorSpecification(authenticator, resolver, SecurityTokenAttachmentMode.Endorsing, supportingTokenParameters.Endorsing[i], isOptional);
             authenticatorSpecList.Add(authenticatorSpec);
         }
         catch (Exception e)
         {
             if (!isOptional || Fx.IsFatal(e))
             {
                 throw;
             }
         }
     }
     for (int i = 0; i < supportingTokenParameters.SignedEndorsing.Count; ++i)
     {
         SecurityTokenRequirement requirement = this.CreateRecipientSecurityTokenRequirement(supportingTokenParameters.SignedEndorsing[i], SecurityTokenAttachmentMode.SignedEndorsing);
         try
         {
             CoreWCF.IdentityModel.Selectors.SecurityTokenResolver      resolver;
             CoreWCF.IdentityModel.Selectors.SecurityTokenAuthenticator authenticator = this.SecurityTokenManager.CreateSecurityTokenAuthenticator(requirement, out resolver);
             SupportingTokenAuthenticatorSpecification authenticatorSpec = new SupportingTokenAuthenticatorSpecification(authenticator, resolver, SecurityTokenAttachmentMode.SignedEndorsing, supportingTokenParameters.SignedEndorsing[i], isOptional);
             authenticatorSpecList.Add(authenticatorSpec);
         }
         catch (Exception e)
         {
             if (!isOptional || Fx.IsFatal(e))
             {
                 throw;
             }
         }
     }
     for (int i = 0; i < supportingTokenParameters.SignedEncrypted.Count; ++i)
     {
         SecurityTokenRequirement requirement = this.CreateRecipientSecurityTokenRequirement(supportingTokenParameters.SignedEncrypted[i], SecurityTokenAttachmentMode.SignedEncrypted);
         try
         {
             CoreWCF.IdentityModel.Selectors.SecurityTokenResolver      resolver;
             CoreWCF.IdentityModel.Selectors.SecurityTokenAuthenticator authenticator = this.SecurityTokenManager.CreateSecurityTokenAuthenticator(requirement, out resolver);
             SupportingTokenAuthenticatorSpecification authenticatorSpec = new SupportingTokenAuthenticatorSpecification(authenticator, resolver, SecurityTokenAttachmentMode.SignedEncrypted, supportingTokenParameters.SignedEncrypted[i], isOptional);
             authenticatorSpecList.Add(authenticatorSpec);
         }
         catch (Exception e)
         {
             if (!isOptional || Fx.IsFatal(e))
             {
                 throw;
             }
         }
     }
     for (int i = 0; i < supportingTokenParameters.Signed.Count; ++i)
     {
         SecurityTokenRequirement requirement = this.CreateRecipientSecurityTokenRequirement(supportingTokenParameters.Signed[i], SecurityTokenAttachmentMode.Signed);
         try
         {
             CoreWCF.IdentityModel.Selectors.SecurityTokenResolver      resolver;
             CoreWCF.IdentityModel.Selectors.SecurityTokenAuthenticator authenticator = this.SecurityTokenManager.CreateSecurityTokenAuthenticator(requirement, out resolver);
             SupportingTokenAuthenticatorSpecification authenticatorSpec = new SupportingTokenAuthenticatorSpecification(authenticator, resolver, SecurityTokenAttachmentMode.Signed, supportingTokenParameters.Signed[i], isOptional);
             authenticatorSpecList.Add(authenticatorSpec);
         }
         catch (Exception e)
         {
             if (!isOptional || Fx.IsFatal(e))
             {
                 throw;
             }
         }
     }
 }