コード例 #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));
		}
コード例 #2
0
		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);
		}
コード例 #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);
		}
コード例 #4
0
		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);
		}
コード例 #5
0
		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);
		}