public RstDirectFilter(SecurityStandardsManager standardsManager, AcceleratedTokenAuthenticator authenticator)
 {
     this.standardsManager = standardsManager;
     this.authenticator    = authenticator;
 }
 public AcceleratedTokenAuthenticatorBindingElement(AcceleratedTokenAuthenticator authenticator)
 {
     this.authenticator = authenticator;
 }
        protected SecurityTokenAuthenticator CreateSecureConversationTokenAuthenticator(RecipientServiceModelSecurityTokenRequirement recipientRequirement, bool preserveBootstrapTokens, out SecurityTokenResolver sctResolver)
        {
            SecurityBindingElement securityBindingElement = recipientRequirement.SecurityBindingElement;

            if (securityBindingElement == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.TokenAuthenticatorRequiresSecurityBindingElement, recipientRequirement));
            }
            bool isCookieMode = !recipientRequirement.SupportSecurityContextCancellation;
            LocalServiceSecuritySettings          localServiceSettings = securityBindingElement.LocalServiceSettings;
            IMessageFilterTable <EndpointAddress> endpointFilterTable  = recipientRequirement.GetPropertyOrDefault <IMessageFilterTable <EndpointAddress> >(ServiceModelSecurityTokenRequirement.EndpointFilterTableProperty, null);

            if (!isCookieMode)
            {
                sctResolver = new SecurityContextSecurityTokenResolver(Int32.MaxValue, false);

                // remember this authenticator for future reference
                SecuritySessionSecurityTokenAuthenticator authenticator = new SecuritySessionSecurityTokenAuthenticator();
                authenticator.BootstrapSecurityBindingElement = SecurityUtils.GetIssuerSecurityBindingElement(recipientRequirement);
                authenticator.IssuedSecurityTokenParameters   = recipientRequirement.GetProperty <SecurityTokenParameters>(ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty);
                authenticator.IssuedTokenCache              = (ISecurityContextSecurityTokenCache)sctResolver;
                authenticator.IssuerBindingContext          = recipientRequirement.GetProperty <BindingContext>(ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty);
                authenticator.KeyEntropyMode                = securityBindingElement.KeyEntropyMode;
                authenticator.ListenUri                     = recipientRequirement.ListenUri;
                authenticator.SecurityAlgorithmSuite        = recipientRequirement.SecurityAlgorithmSuite;
                authenticator.SessionTokenLifetime          = TimeSpan.MaxValue;
                authenticator.KeyRenewalInterval            = securityBindingElement.LocalServiceSettings.SessionKeyRenewalInterval;
                authenticator.StandardsManager              = SecurityUtils.CreateSecurityStandardsManager(recipientRequirement, this);
                authenticator.EndpointFilterTable           = endpointFilterTable;
                authenticator.MaximumConcurrentNegotiations = localServiceSettings.MaxStatefulNegotiations;
                authenticator.NegotiationTimeout            = localServiceSettings.NegotiationTimeout;
                authenticator.PreserveBootstrapTokens       = preserveBootstrapTokens;
                return(authenticator);
            }
            else
            {
                sctResolver = new SecurityContextSecurityTokenResolver(localServiceSettings.MaxCachedCookies, true, localServiceSettings.MaxClockSkew);

                AcceleratedTokenAuthenticator authenticator = new AcceleratedTokenAuthenticator();
                authenticator.BootstrapSecurityBindingElement = SecurityUtils.GetIssuerSecurityBindingElement(recipientRequirement);
                authenticator.KeyEntropyMode                = securityBindingElement.KeyEntropyMode;
                authenticator.EncryptStateInServiceToken    = true;
                authenticator.IssuedSecurityTokenParameters = recipientRequirement.GetProperty <SecurityTokenParameters>(ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty);
                authenticator.IssuedTokenCache              = (ISecurityContextSecurityTokenCache)sctResolver;
                authenticator.IssuerBindingContext          = recipientRequirement.GetProperty <BindingContext>(ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty);
                authenticator.ListenUri = recipientRequirement.ListenUri;
                authenticator.SecurityAlgorithmSuite  = recipientRequirement.SecurityAlgorithmSuite;
                authenticator.StandardsManager        = SecurityUtils.CreateSecurityStandardsManager(recipientRequirement, this);
                authenticator.SecurityStateEncoder    = parent.SecureConversationAuthentication.SecurityStateEncoder;
                authenticator.KnownTypes              = parent.SecureConversationAuthentication.SecurityContextClaimTypes;
                authenticator.PreserveBootstrapTokens = preserveBootstrapTokens;

                // local security quotas
                authenticator.MaximumCachedNegotiationState = localServiceSettings.MaxStatefulNegotiations;
                authenticator.NegotiationTimeout            = localServiceSettings.NegotiationTimeout;
                authenticator.ServiceTokenLifetime          = localServiceSettings.IssuedCookieLifetime;
                authenticator.MaximumConcurrentNegotiations = localServiceSettings.MaxStatefulNegotiations;

                // audit settings
                authenticator.AuditLogLocation                = recipientRequirement.AuditLogLocation;
                authenticator.SuppressAuditFailure            = recipientRequirement.SuppressAuditFailure;
                authenticator.MessageAuthenticationAuditLevel = recipientRequirement.MessageAuthenticationAuditLevel;
                authenticator.EndpointFilterTable             = endpointFilterTable;
                return(authenticator);
            }
        }