Example #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));
        }
Example #2
0
        public void InitializeSecurityTokenParameters()
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);

            Assert.AreEqual(ServiceModelSecurityTokenTypes.Spnego, r.TokenType, "#1");
            Assert.AreEqual(false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2");
        }
Example #3
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);
        }
        public void InitializeSecurityTokenParameters()
        {
            MyParameters tp = new MyParameters();
            InitiatorServiceModelSecurityTokenRequirement r =
                new InitiatorServiceModelSecurityTokenRequirement();

            tp.InitRequirement(r);

            Assert.AreEqual(ServiceModelSecurityTokenTypes.AnonymousSslnego, r.TokenType, "#1");
            Assert.AreEqual(false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2");
            SslSecurityTokenParameters dummy;

            Assert.IsTrue(r.TryGetProperty <SslSecurityTokenParameters> (ReqType.IssuedSecurityTokenParametersProperty, out dummy), "#3");
        }
Example #5
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);
        }
Example #6
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 void InitializeSecurityTokenParameters ()
		{
			MyParameters tp = new MyParameters ();
			InitiatorServiceModelSecurityTokenRequirement r =
				new InitiatorServiceModelSecurityTokenRequirement ();
			tp.InitRequirement (r);

			Assert.AreEqual (ServiceModelSecurityTokenTypes.Spnego, r.TokenType, "#1");
			Assert.AreEqual (false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2");
		}
		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));
		}
		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 CreateProvider ()
		{
			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 ());
			r.MessageSecurityVersion = MessageSecurityVersion.Default.SecurityTokenVersion;

			ClientCredentials cred = new ClientCredentials ();
			ClientCredentialsSecurityTokenManager manager =
				new ClientCredentialsSecurityTokenManager (cred);
			//SecurityTokenProvider p =
				manager.CreateSecurityTokenProvider (r);
		}
		public void CreateProviderNoIssuerBindingContext ()
		{
			MyParameters tp = new MyParameters ();
			InitiatorServiceModelSecurityTokenRequirement r =
				new InitiatorServiceModelSecurityTokenRequirement ();
			tp.InitRequirement (r);
			r.TargetAddress = new EndpointAddress ("http://localhost:8080");
			r.SecurityBindingElement = new SymmetricSecurityBindingElement ();

			ClientCredentials cred = new ClientCredentials ();
			ClientCredentialsSecurityTokenManager manager =
				new ClientCredentialsSecurityTokenManager (cred);
			//SecurityTokenProvider p =
				manager.CreateSecurityTokenProvider (r);
		}
		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);
		}
		public void InitializeSecurityTokenParameters ()
		{
			MyParameters tp = new MyParameters ();
			InitiatorServiceModelSecurityTokenRequirement r =
				new InitiatorServiceModelSecurityTokenRequirement ();
			tp.InitRequirement (r);

			Assert.AreEqual (ServiceModelSecurityTokenTypes.AnonymousSslnego, r.TokenType, "#1");
			Assert.AreEqual (false, r.Properties [ReqType.SupportSecurityContextCancellationProperty], "#2");
			SslSecurityTokenParameters dummy;
			Assert.IsTrue (r.TryGetProperty<SslSecurityTokenParameters> (ReqType.IssuedSecurityTokenParametersProperty, out dummy), "#3");
		}
		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);
		}