Beispiel #1
0
        void CreateProviderOpenGetToken(bool getToken)
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);
            r.TargetAddress          = new EndpointAddress("http://localhost:8080");
            r.SecurityBindingElement = new SymmetricSecurityBindingElement();
            r.Properties [ReqType.IssuerBindingContextProperty] =
                new BindingContext(new CustomBinding(new HttpTransportBindingElement()),
                                   new BindingParameterCollection());
            r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;
            // This is required at GetToken().
            r.SecurityAlgorithmSuite = SecurityAlgorithmSuite.Default;
            ClientCredentials cred = new ClientCredentials();
            ClientCredentialsSecurityTokenManager manager =
                new ClientCredentialsSecurityTokenManager(cred);
            // TLS negotiation token provider is created.
            SecurityTokenProvider p =
                manager.CreateSecurityTokenProvider(r);

            ((ICommunicationObject)p).Open();

            if (!getToken)
            {
                return;
            }

            p.GetToken(TimeSpan.FromSeconds(5));
        }
Beispiel #2
0
        public void CreateProviderNoTargetAddress()
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);

            ClientCredentials cred = new ClientCredentials();
            ClientCredentialsSecurityTokenManager manager =
                new ClientCredentialsSecurityTokenManager(cred);

            manager.CreateSecurityTokenProvider(r);
        }
Beispiel #3
0
        public void CreateProviderNoSecurityBindingElement()
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);
            r.TargetAddress = new EndpointAddress("http://localhost:8080");

            ClientCredentials cred = new ClientCredentials();
            ClientCredentialsSecurityTokenManager manager =
                new ClientCredentialsSecurityTokenManager(cred);

            manager.CreateSecurityTokenProvider(r);
        }
Beispiel #4
0
        public void CreateAuthenticator()
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);

            ClientCredentials cred = new ClientCredentials();
            ClientCredentialsSecurityTokenManager manager =
                new ClientCredentialsSecurityTokenManager(cred);

            SecurityTokenResolver resolver;

//			SecurityTokenAuthenticator authenticator =
            manager.CreateSecurityTokenAuthenticator(r, out resolver);
        }
        public void CreateProviderNoMessageSecurityVersion()
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);
            r.TargetAddress          = new EndpointAddress("http://localhost:8080");
            r.SecurityBindingElement = new SymmetricSecurityBindingElement();
            r.Properties [ReqType.IssuerBindingContextProperty] =
                new BindingContext(new CustomBinding(),
                                   new BindingParameterCollection());

            ClientCredentials cred = new ClientCredentials();
            ClientCredentialsSecurityTokenManager manager =
                new ClientCredentialsSecurityTokenManager(cred);

            manager.CreateSecurityTokenProvider(r);
        }
        void CreateRecipientProviderCore(bool mutual)
        {
            MyParameters tp = new MyParameters();

            tp.RequireClientCertificate = true;
            RecipientServiceModelSecurityTokenRequirement r =
                new RecipientServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);
            r.ListenUri = new Uri("http://localhost:8080");
            r.SecurityBindingElement = new SymmetricSecurityBindingElement();
            r.Properties [ReqType.IssuerBindingContextProperty] =
                new BindingContext(new CustomBinding(),
                                   new BindingParameterCollection());
            r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;

            ClientCredentials cred = new ClientCredentials();
            ClientCredentialsSecurityTokenManager manager =
                new ClientCredentialsSecurityTokenManager(cred);

            manager.CreateSecurityTokenProvider(r);
        }
		public SspiClientSecurityTokenAuthenticator (
			ClientCredentialsSecurityTokenManager manager, 
			SecurityTokenRequirement r)
		{
			this.manager = manager;
		}
 public SspiClientSecurityTokenAuthenticator(
     ClientCredentialsSecurityTokenManager manager,
     SecurityTokenRequirement r)
 {
     this.manager = manager;
 }
		public SpnegoSecurityTokenProvider (ClientCredentialsSecurityTokenManager manager, SecurityTokenRequirement requirement)
		{
			this.manager = manager;
			comm = new SpnegoCommunicationObject (this);
		}
Beispiel #10
0
 public SslSecurityTokenProvider(ClientCredentialsSecurityTokenManager manager, bool mutual)
 {
     this.manager = manager;
     comm         = new SslCommunicationObject(this, mutual);
 }
 public SpnegoSecurityTokenProvider(ClientCredentialsSecurityTokenManager manager, SecurityTokenRequirement requirement)
 {
     this.manager = manager;
     comm         = new SpnegoCommunicationObject(this);
 }
Beispiel #12
0
        // Summary:
        //  If interactive support is requested and an IssuedSecurityTokenParameters is specified this method
        //  will return an instance of an InfoCardTokenProvider.
        //  Otherwise this method defers to the base implementation.
        //
        // Parameters
        //  parameters  - The security token parameters associated with this ChannelFactory.
        //
        // Note
        //  The target and issuer information will not be available in this call
        //
        public static bool TryCreateSecurityTokenProvider(SecurityTokenRequirement tokenRequirement, ClientCredentialsSecurityTokenManager clientCredentialsTokenManager, out SecurityTokenProvider provider)
        {
            if (tokenRequirement == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenRequirement");
            }
            if (clientCredentialsTokenManager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("clientCredentialsTokenManager");
            }

            provider = null;

            if (!clientCredentialsTokenManager.ClientCredentials.SupportInteractive ||
                (null != clientCredentialsTokenManager.ClientCredentials.IssuedToken.LocalIssuerAddress && null != clientCredentialsTokenManager.ClientCredentials.IssuedToken.LocalIssuerBinding) ||
                !clientCredentialsTokenManager.IsIssuedSecurityTokenRequirement(tokenRequirement)
                )
            {
                //IDT.TraceDebug("ICARDTOKPROV: Non Issued SecurityToken requirement submitted to InfoCardClientCredentialsSecurityTokenManager:\n{0}", tokenRequirement);
                //IDT.TraceDebug("ICARDTOKPROV: Defering to the base class to create the token provider");
            }
            else
            {
                ChannelParameterCollection channelParameter;
                InfoCardChannelParameter   infocardChannelParameter = null;
                if (tokenRequirement.TryGetProperty <ChannelParameterCollection>(ServiceModelSecurityTokenRequirement.ChannelParametersCollectionProperty, out channelParameter))
                {
                    foreach (object obj in channelParameter)
                    {
                        if (obj is InfoCardChannelParameter)
                        {
                            infocardChannelParameter = (InfoCardChannelParameter)obj;
                            break;
                        }
                    }
                }

                if (null == infocardChannelParameter || !infocardChannelParameter.RequiresInfoCard)
                {
                    return(false);
                }

                EndpointAddress target = tokenRequirement.GetProperty <EndpointAddress>(ServiceModelSecurityTokenRequirement.TargetAddressProperty);
                IssuedSecurityTokenParameters issuedTokenParameters = tokenRequirement.GetProperty <IssuedSecurityTokenParameters>(ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty);

                Uri privacyNoticeLink;
                if (!tokenRequirement.TryGetProperty <Uri>(ServiceModelSecurityTokenRequirement.PrivacyNoticeUriProperty, out privacyNoticeLink))
                {
                    privacyNoticeLink = null;
                }

                int privacyNoticeVersion;
                if (!tokenRequirement.TryGetProperty <int>(ServiceModelSecurityTokenRequirement.PrivacyNoticeVersionProperty, out privacyNoticeVersion))
                {
                    privacyNoticeVersion = 0;
                }
                //
                // This analysis of this chain indicates that interactive support will be required
                // The InternalClientCredentials class handles that.
                //
                provider = CreateTokenProviderForNextLeg(tokenRequirement, target, issuedTokenParameters.IssuerAddress, infocardChannelParameter.RelyingPartyIssuer, clientCredentialsTokenManager, infocardChannelParameter);
            }

            return(provider != null);
        }
Beispiel #13
0
 static SecurityTokenProvider CreateTokenProviderForNextLeg(SecurityTokenRequirement tokenRequirement, EndpointAddress target, EndpointAddress issuerAddress, Uri relyingPartyIssuer, ClientCredentialsSecurityTokenManager clientCredentialsTokenManager, InfoCardChannelParameter infocardChannelParameter)
 {
     if (((null == relyingPartyIssuer && null == issuerAddress) || issuerAddress.Uri == relyingPartyIssuer))
     {
         return(new InternalInfoCardTokenProvider(infocardChannelParameter));
     }
     else
     {
         // create a federation token provider and add an internal client credentials shim that contains the chain
         IssuedSecurityTokenProvider federationTokenProvider = (IssuedSecurityTokenProvider)clientCredentialsTokenManager.CreateSecurityTokenProvider(tokenRequirement, true);
         federationTokenProvider.IssuerChannelBehaviors.Remove <SecurityCredentialsManager>();
         federationTokenProvider.IssuerChannelBehaviors.Add(new InternalClientCredentials(clientCredentialsTokenManager.ClientCredentials, target, relyingPartyIssuer, infocardChannelParameter));
         return(federationTokenProvider);
     }
 }
        private static SecurityTokenProvider CreateTokenProviderForNextLeg(SecurityTokenRequirement tokenRequirement, EndpointAddress target, EndpointAddress issuerAddress, Uri relyingPartyIssuer, ClientCredentialsSecurityTokenManager clientCredentialsTokenManager, InfoCardChannelParameter infocardChannelParameter)
        {
            if (((null == relyingPartyIssuer) && (null == issuerAddress)) || (issuerAddress.Uri == relyingPartyIssuer))
            {
                return(new InternalInfoCardTokenProvider(infocardChannelParameter));
            }
            IssuedSecurityTokenProvider provider = (IssuedSecurityTokenProvider)clientCredentialsTokenManager.CreateSecurityTokenProvider(tokenRequirement, true);

            provider.IssuerChannelBehaviors.Remove <SecurityCredentialsManager>();
            provider.IssuerChannelBehaviors.Add(new InternalClientCredentials(clientCredentialsTokenManager.ClientCredentials, target, relyingPartyIssuer, infocardChannelParameter));
            return(provider);
        }
 public static bool TryCreateSecurityTokenProvider(SecurityTokenRequirement tokenRequirement, ClientCredentialsSecurityTokenManager clientCredentialsTokenManager, out SecurityTokenProvider provider)
 {
     if (tokenRequirement == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("tokenRequirement");
     }
     if (clientCredentialsTokenManager == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("clientCredentialsTokenManager");
     }
     provider = null;
     if ((clientCredentialsTokenManager.ClientCredentials.SupportInteractive && ((null == clientCredentialsTokenManager.ClientCredentials.IssuedToken.LocalIssuerAddress) || (clientCredentialsTokenManager.ClientCredentials.IssuedToken.LocalIssuerBinding == null))) && clientCredentialsTokenManager.IsIssuedSecurityTokenRequirement(tokenRequirement))
     {
         ChannelParameterCollection parameters;
         Uri uri;
         int num;
         InfoCardChannelParameter infocardChannelParameter = null;
         if (tokenRequirement.TryGetProperty <ChannelParameterCollection>(ServiceModelSecurityTokenRequirement.ChannelParametersCollectionProperty, out parameters))
         {
             foreach (object obj2 in parameters)
             {
                 if (obj2 is InfoCardChannelParameter)
                 {
                     infocardChannelParameter = (InfoCardChannelParameter)obj2;
                     break;
                 }
             }
         }
         if ((infocardChannelParameter == null) || !infocardChannelParameter.RequiresInfoCard)
         {
             return(false);
         }
         EndpointAddress property = tokenRequirement.GetProperty <EndpointAddress>(ServiceModelSecurityTokenRequirement.TargetAddressProperty);
         IssuedSecurityTokenParameters parameters2 = tokenRequirement.GetProperty <IssuedSecurityTokenParameters>(ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty);
         if (!tokenRequirement.TryGetProperty <Uri>(ServiceModelSecurityTokenRequirement.PrivacyNoticeUriProperty, out uri))
         {
             uri = null;
         }
         if (!tokenRequirement.TryGetProperty <int>(ServiceModelSecurityTokenRequirement.PrivacyNoticeVersionProperty, out num))
         {
             num = 0;
         }
         provider = CreateTokenProviderForNextLeg(tokenRequirement, property, parameters2.IssuerAddress, infocardChannelParameter.RelyingPartyIssuer, clientCredentialsTokenManager, infocardChannelParameter);
     }
     return(provider != null);
 }