Example #1
0
 public override SecurityTokenSerializer CreateSecurityTokenSerializer(SecurityTokenVersion version)
 {
     if (delegateManager != null)
     {
         return(delegateManager.CreateSecurityTokenSerializer(version));
     }
     else
     {
         MessageSecurityTokenVersion wsVersion = version as MessageSecurityTokenVersion;
         if (wsVersion != null)
         {
             return(new WSSecurityTokenSerializer(wsVersion.SecurityVersion, wsVersion.TrustVersion, wsVersion.SecureConversationVersion, wsVersion.EmitBspRequiredAttributes, null, null, null));
         }
         else
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.SecurityTokenManagerCannotCreateSerializerForVersion, version)));
         }
     }
 }
Example #2
0
        internal static SecurityStandardsManager CreateSecurityStandardsManager(MessageSecurityVersion securityVersion, SecurityTokenManager tokenManager)
        {
            SecurityTokenSerializer tokenSerializer = tokenManager.CreateSecurityTokenSerializer(securityVersion.SecurityTokenVersion);

            return(new SecurityStandardsManager(securityVersion, tokenSerializer));
        }
        void CallBegin(bool completedSynchronously)
        {
            IAsyncResult result    = null;
            Exception    exception = null;

            try
            {
                CardSpacePolicyElement[] chain;
                SecurityTokenManager     tokenManager = credentials.CreateSecurityTokenManager();
                requiresInfoCard = InfoCardHelper.IsInfocardRequired(binding, credentials, tokenManager, proxy.RemoteAddress, out chain, out relyingPartyIssuer);
                MessageSecurityVersion    bindingSecurityVersion = InfoCardHelper.GetBindingSecurityVersionOrDefault(binding);
                WSSecurityTokenSerializer tokenSerializer        = WSSecurityTokenSerializer.DefaultInstance;
                result = credentials.GetInfoCardTokenCallback.BeginInvoke(requiresInfoCard, chain, tokenManager.CreateSecurityTokenSerializer(bindingSecurityVersion.SecurityTokenVersion), callback, this);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                exception = e;
            }
            if (exception == null)
            {
                if (!result.CompletedSynchronously)
                {
                    return;
                }

                this.CallEnd(result, out exception);
            }
            if (exception != null)
            {
                return;
            }


            this.CallComplete(completedSynchronously, null);
        }
Example #4
0
        static PolicyElement[] GetPolicyChain(EndpointAddress target, Binding outerBinding, IssuedSecurityTokenParameters parameters, Uri firstPrivacyNoticeLink, int firstPrivacyNoticeVersion, SecurityTokenManager clientCredentialsTokenManager)
        {
            EndpointAddress nextTarget = target;
            IssuedSecurityTokenParameters nextParameters = parameters;

            List <PolicyElement> chain = new List <PolicyElement>();

            Uri  privacyNoticeLink    = firstPrivacyNoticeLink;
            int  privacyNoticeVersion = firstPrivacyNoticeVersion;
            bool isManagedIssuer      = false;


            //
            // this is the binding to the final STS in the chain. Start from here and walk the
            // chain backwards to the 1st STS in the chain
            //
            while (null != nextParameters)
            {
                MessageSecurityVersion bindingSecurityVersion = null;
                if (nextParameters.IssuerBinding == null)
                {
                    bindingSecurityVersion = GetBindingSecurityVersionOrDefault(outerBinding);
                }
                else
                {
                    bindingSecurityVersion = GetBindingSecurityVersionOrDefault(nextParameters.IssuerBinding);
                }
                chain.Add(new PolicyElement(nextTarget,
                                            nextParameters.IssuerAddress,
                                            nextParameters.CreateRequestParameters(bindingSecurityVersion, clientCredentialsTokenManager.CreateSecurityTokenSerializer(bindingSecurityVersion.SecurityTokenVersion)),
                                            privacyNoticeLink,
                                            privacyNoticeVersion,
                                            isManagedIssuer,
                                            nextParameters.IssuerBinding));

                isManagedIssuer = IsReferralToManagedIssuer(nextParameters.IssuerBinding);
                GetPrivacyNoticeLinkFromIssuerBinding(nextParameters.IssuerBinding, out privacyNoticeLink, out privacyNoticeVersion);
                nextTarget     = nextParameters.IssuerAddress;
                outerBinding   = nextParameters.IssuerBinding;
                nextParameters = TryGetNextStsIssuedTokenParameters(nextParameters.IssuerBinding);
            }

            //
            // Add the last element for the MCIP case
            //
            if (isManagedIssuer)
            {
                chain.Add(new PolicyElement(nextTarget,
                                            null,
                                            null,
                                            privacyNoticeLink,
                                            privacyNoticeVersion,
                                            isManagedIssuer,
                                            null));
            }
            return(chain.ToArray());
        }
        private static PolicyElement[] GetPolicyChain(EndpointAddress target, Binding outerBinding, IssuedSecurityTokenParameters parameters, Uri firstPrivacyNoticeLink, int firstPrivacyNoticeVersion, SecurityTokenManager clientCredentialsTokenManager)
        {
            EndpointAddress issuerAddress             = target;
            IssuedSecurityTokenParameters parameters2 = parameters;
            List <PolicyElement>          list        = new List <PolicyElement>();
            Uri  privacyNoticeLink    = firstPrivacyNoticeLink;
            int  privacyNoticeVersion = firstPrivacyNoticeVersion;
            bool isManagedIssuer      = false;

            while (parameters2 != null)
            {
                MessageSecurityVersion messageSecurityVersion = null;
                if (parameters2.IssuerBinding == null)
                {
                    messageSecurityVersion = GetBindingSecurityVersionOrDefault(outerBinding);
                }
                else
                {
                    messageSecurityVersion = GetBindingSecurityVersionOrDefault(parameters2.IssuerBinding);
                }
                list.Add(new PolicyElement(issuerAddress, parameters2.IssuerAddress, parameters2.CreateRequestParameters(messageSecurityVersion, clientCredentialsTokenManager.CreateSecurityTokenSerializer(messageSecurityVersion.SecurityTokenVersion)), privacyNoticeLink, privacyNoticeVersion, isManagedIssuer, parameters2.IssuerBinding));
                isManagedIssuer = IsReferralToManagedIssuer(parameters2.IssuerBinding);
                GetPrivacyNoticeLinkFromIssuerBinding(parameters2.IssuerBinding, out privacyNoticeLink, out privacyNoticeVersion);
                issuerAddress = parameters2.IssuerAddress;
                outerBinding  = parameters2.IssuerBinding;
                parameters2   = TryGetNextStsIssuedTokenParameters(parameters2.IssuerBinding);
            }
            if (isManagedIssuer)
            {
                list.Add(new PolicyElement(issuerAddress, null, null, privacyNoticeLink, privacyNoticeVersion, isManagedIssuer, null));
            }
            return(list.ToArray());
        }
        private void CallBegin(bool completedSynchronously)
        {
            IAsyncResult result    = null;
            Exception    exception = null;

            try
            {
                CardSpacePolicyElement[] elementArray;
                SecurityTokenManager     clientCredentialsTokenManager = this.credentials.CreateSecurityTokenManager();
                this.requiresInfoCard = InfoCardHelper.IsInfocardRequired(this.binding, this.credentials, clientCredentialsTokenManager, this.proxy.RemoteAddress, out elementArray, out this.relyingPartyIssuer);
                MessageSecurityVersion    bindingSecurityVersionOrDefault = InfoCardHelper.GetBindingSecurityVersionOrDefault(this.binding);
                WSSecurityTokenSerializer defaultInstance = WSSecurityTokenSerializer.DefaultInstance;
                result = this.credentials.GetInfoCardTokenCallback.BeginInvoke(this.requiresInfoCard, elementArray, clientCredentialsTokenManager.CreateSecurityTokenSerializer(bindingSecurityVersionOrDefault.SecurityTokenVersion), callback, this);
            }
            catch (Exception exception2)
            {
                if (Fx.IsFatal(exception2))
                {
                    throw;
                }
                exception = exception2;
            }
            if (exception == null)
            {
                if (!result.CompletedSynchronously)
                {
                    return;
                }
                this.CallEnd(result, out exception);
            }
            if (exception == null)
            {
                this.CallComplete(completedSynchronously, null);
            }
        }