protected SecurityProtocol(System.ServiceModel.Security.SecurityProtocolFactory factory, EndpointAddress target, Uri via) { this.factory = factory; this.target = target; this.via = via; this.communicationObject = new WrapperSecurityCommunicationObject(this); }
internal bool TryGetSupportingTokens(System.ServiceModel.Security.SecurityProtocolFactory factory, EndpointAddress target, Uri via, Message message, TimeSpan timeout, bool isBlockingCall, out IList <SupportingTokenSpecification> supportingTokens) { if (!factory.ActAsInitiator) { supportingTokens = null; return(true); } if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message"); } TimeoutHelper helper = new TimeoutHelper(timeout); supportingTokens = null; IList <SupportingTokenProviderSpecification> supportingTokenProviders = this.GetSupportingTokenProviders(message.Headers.Action); if ((supportingTokenProviders != null) && (supportingTokenProviders.Count > 0)) { if (!isBlockingCall) { return(false); } supportingTokens = new Collection <SupportingTokenSpecification>(); for (int i = 0; i < supportingTokenProviders.Count; i++) { SecurityToken token; SupportingTokenProviderSpecification specification = supportingTokenProviders[i]; if ((this is TransportSecurityProtocol) && (specification.TokenParameters is KerberosSecurityTokenParameters)) { token = new ProviderBackedSecurityToken(specification.TokenProvider, helper.RemainingTime()); } else { token = specification.TokenProvider.GetToken(helper.RemainingTime()); } supportingTokens.Add(new SupportingTokenSpecification(token, EmptyReadOnlyCollection <IAuthorizationPolicy> .Instance, specification.SecurityTokenAttachmentMode, specification.TokenParameters)); } } this.AddMessageSupportingTokens(message, ref supportingTokens); return(true); }
protected IList <SupportingTokenAuthenticatorSpecification> GetSupportingTokenAuthenticatorsAndSetExpectationFlags(System.ServiceModel.Security.SecurityProtocolFactory factory, Message message, ReceiveSecurityHeader securityHeader) { bool flag; bool flag2; bool flag3; if (factory.ActAsInitiator) { return(null); } if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message"); } IList <SupportingTokenAuthenticatorSpecification> list = factory.GetSupportingTokenAuthenticators(message.Headers.Action, out flag2, out flag, out flag3); securityHeader.ExpectBasicTokens = flag; securityHeader.ExpectEndorsingTokens = flag3; securityHeader.ExpectSignedTokens = flag2; return(list); }
protected SendSecurityHeader CreateSendSecurityHeaderForTransportProtocol(Message message, string actor, System.ServiceModel.Security.SecurityProtocolFactory factory) { return(this.CreateSendSecurityHeader(message, actor, factory, false)); }
private SendSecurityHeader CreateSendSecurityHeader(Message message, string actor, System.ServiceModel.Security.SecurityProtocolFactory factory, bool requireMessageProtection) { MessageDirection direction = factory.ActAsInitiator ? MessageDirection.Input : MessageDirection.Output; SendSecurityHeader securityHeader = factory.StandardsManager.CreateSendSecurityHeader(message, actor, true, false, factory.OutgoingAlgorithmSuite, direction); securityHeader.Layout = factory.SecurityHeaderLayout; securityHeader.RequireMessageProtection = requireMessageProtection; SetSecurityHeaderId(securityHeader, message); if (factory.AddTimestamp) { securityHeader.AddTimestamp(factory.TimestampValidityDuration); } return(securityHeader); }