/// <summary> /// Initializes a new instance of the <see cref="OpenIdChannel"/> class. /// </summary> /// <param name="messageTypeProvider">A class prepared to analyze incoming messages and indicate what concrete /// message types can deserialize from it.</param> /// <param name="bindingElements">The binding elements to use in sending and receiving messages.</param> protected OpenIdChannel(IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements) : base(messageTypeProvider, bindingElements) { Requires.NotNull(messageTypeProvider, "messageTypeProvider"); // Customize the binding element order, since we play some tricks for higher // security and backward compatibility with older OpenID versions. var outgoingBindingElements = new List<IChannelBindingElement>(bindingElements); var incomingBindingElements = new List<IChannelBindingElement>(bindingElements); incomingBindingElements.Reverse(); // Customize the order of the incoming elements by moving the return_to elements in front. var backwardCompatibility = incomingBindingElements.OfType<BackwardCompatibilityBindingElement>().SingleOrDefault(); var returnToSign = incomingBindingElements.OfType<ReturnToSignatureBindingElement>().SingleOrDefault(); if (backwardCompatibility != null) { incomingBindingElements.MoveTo(0, backwardCompatibility); } if (returnToSign != null) { // Yes, this is intentionally, shifting the backward compatibility // binding element to second position. incomingBindingElements.MoveTo(0, returnToSign); } this.CustomizeBindingElementOrder(outgoingBindingElements, incomingBindingElements); // Change out the standard web request handler to reflect the standard // OpenID pattern that outgoing web requests are to unknown and untrusted // servers on the Internet. this.WebRequestHandler = new UntrustedWebRequestHandler(); }
/// <summary> /// Initializes a new instance of the <see cref="StandardMessageFactoryChannel" /> class. /// </summary> /// <param name="messageTypes">The message types that might be encountered.</param> /// <param name="versions">All the possible message versions that might be encountered.</param> /// <param name="hostFactories">The host factories.</param> /// <param name="bindingElements">The binding elements to use in sending and receiving messages. /// The order they are provided is used for outgoing messgaes, and reversed for incoming messages.</param> protected StandardMessageFactoryChannel(ICollection<Type> messageTypes, ICollection<Version> versions, IHostFactories hostFactories, IChannelBindingElement[] bindingElements = null) : base(new StandardMessageFactory(), bindingElements ?? new IChannelBindingElement[0], hostFactories) { Requires.NotNull(messageTypes, "messageTypes"); Requires.NotNull(versions, "versions"); this.messageTypes = messageTypes; this.versions = versions; this.StandardMessageFactory.AddMessageTypes(GetMessageDescriptions(this.messageTypes, this.versions, this.MessageDescriptions)); }
protected OAuthChannel(ITamperProtectionChannelBindingElement signingBindingElement, ITokenManager tokenManager, SecuritySettings securitySettings, IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements) : base(messageTypeProvider, bindingElements) { Requires.NotNull(tokenManager, "tokenManager"); Requires.NotNull(securitySettings, "securitySettings"); Requires.NotNull(signingBindingElement, "signingBindingElement"); Requires.That(signingBindingElement.SignatureCallback == null, "signingBindingElement", OAuthStrings.SigningElementAlreadyAssociatedWithChannel); Requires.NotNull(bindingElements, "bindingElements"); this.TokenManager = tokenManager; signingBindingElement.SignatureCallback = this.SignatureCallback; }
/// <summary> /// Initializes a new instance of the <see cref="OpenIdChannel" /> class. /// </summary> /// <param name="messageTypeProvider">A class prepared to analyze incoming messages and indicate what concrete /// message types can deserialize from it.</param> /// <param name="bindingElements">The binding elements to use in sending and receiving messages.</param> /// <param name="hostFactories">The host factories.</param> protected OpenIdChannel(IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements, IHostFactories hostFactories) : base(messageTypeProvider, bindingElements, hostFactories ?? new DefaultOpenIdHostFactories()) { Requires.NotNull(messageTypeProvider, "messageTypeProvider"); // Customize the binding element order, since we play some tricks for higher // security and backward compatibility with older OpenID versions. var outgoingBindingElements = new List<IChannelBindingElement>(bindingElements); var incomingBindingElements = new List<IChannelBindingElement>(bindingElements); incomingBindingElements.Reverse(); // Customize the order of the incoming elements by moving the return_to elements in front. var backwardCompatibility = incomingBindingElements.OfType<BackwardCompatibilityBindingElement>().SingleOrDefault(); var returnToSign = incomingBindingElements.OfType<ReturnToSignatureBindingElement>().SingleOrDefault(); if (backwardCompatibility != null) { incomingBindingElements.MoveTo(0, backwardCompatibility); } if (returnToSign != null) { // Yes, this is intentionally, shifting the backward compatibility // binding element to second position. incomingBindingElements.MoveTo(0, returnToSign); } this.CustomizeBindingElementOrder(outgoingBindingElements, incomingBindingElements); }
/// <summary> /// Initializes a new instance of the <see cref="OAuth2ChannelBase" /> class. /// </summary> /// <param name="messageTypes">The message types that are received by this channel.</param> /// <param name="channelBindingElements">The binding elements to use in sending and receiving messages. /// The order they are provided is used for outgoing messgaes, and reversed for incoming messages.</param> /// <param name="hostFactories">The host factories.</param> internal OAuth2ChannelBase(Type[] messageTypes, IChannelBindingElement[] channelBindingElements = null, IHostFactories hostFactories = null) : base(Requires.NotNull(messageTypes, "messageTypes"), Versions, hostFactories ?? new OAuth.DefaultOAuthHostFactories(), channelBindingElements ?? new IChannelBindingElement[0]) { }
/// <summary> /// Initializes a new instance of the <see cref="TestBadChannel" /> class. /// </summary> /// <param name="messageFactory">The message factory. Could be <see cref="TestMessageFactory"/></param> /// <param name="bindingElements">The binding elements.</param> /// <param name="hostFactories">The host factories.</param> internal TestBadChannel(IMessageFactory messageFactory, IChannelBindingElement[] bindingElements, IHostFactories hostFactories) : base(messageFactory, bindingElements, hostFactories) { }
internal TestChannel(IMessageFactory messageTypeProvider, IChannelBindingElement[] bindingElements, IHostFactories hostFactories) : base(messageTypeProvider, bindingElements, hostFactories) { }