/// <summary> /// Begins processing an incoming request. /// </summary> /// <param name="context">The security context for the request</param> /// <param name="request">The request.</param> /// <returns>The result object that is used to call the EndProcessRequest method.</returns> public IAsyncResult BeginProcessRequest( SecureChannelContext context, IServiceRequest request) { m_context = context; m_request = request; try { // find service. m_service = m_endpoint.FindService(m_request.TypeId); if (m_service == null) { throw ServiceResultException.Create(StatusCodes.BadServiceUnsupported, "'{0}' is an unrecognized service type.", m_request.TypeId); } // queue request. m_endpoint.ServerForContext.ScheduleIncomingRequest(this); } catch (Exception e) { m_error = e; m_response = SaveExceptionAsResponse(e); // operation completed. OperationCompleted(); } return(this); }
/// <summary> /// Begins processing a request received via a binary encoded channel. /// </summary> /// <param name="channeId">A unique identifier for the secure channel which is the source of the request.</param> /// <param name="endpointDescription">The description of the endpoint which the secure channel is using.</param> /// <param name="request">The incoming request.</param> /// <param name="callback">The callback.</param> /// <param name="callbackData">The callback data.</param> /// <returns> /// The result which must be passed to the EndProcessRequest method. /// </returns> /// <seealso cref="EndProcessRequest"/> /// <seealso cref="ITransportListener"/> public IAsyncResult BeginProcessRequest( string channeId, EndpointDescription endpointDescription, IServiceRequest request, AsyncCallback callback, object callbackData) { if (channeId == null) { throw new ArgumentNullException(nameof(channeId)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } // create operation. ProcessRequestAsyncResult result = new ProcessRequestAsyncResult(this, callback, callbackData, 0); SecureChannelContext context = new SecureChannelContext( channeId, endpointDescription, RequestEncoding.Binary); // begin invoke service. return(result.BeginProcessRequest(context, request)); }
/// <summary> /// Sets the request context for the thread. /// </summary> /// <param name="encoding">The encoding.</param> protected void SetRequestContext(RequestEncoding encoding) { // fetch the current operation context. OperationContext context = OperationContext.Current; if (context != null) { int firstRequestReceived = Interlocked.CompareExchange(ref m_firstRequestReceived, 1, 0); if (firstRequestReceived == 0 && context.Channel != null && !String.IsNullOrEmpty(context.Channel.SessionId)) { Opc.Ua.Security.Audit.SecureChannelCreated( g_ImplementationString, context.Channel.LocalAddress.Uri.ToString(), context.Channel.SessionId, m_endpointDescription, context.Host.Credentials.ClientCertificate.Certificate, context.Host.Credentials.ServiceCertificate.Certificate, (encoding == RequestEncoding.Binary) ? BinaryEncodingSupport.Required : BinaryEncodingSupport.None); } SecureChannelContext requestContext = new SecureChannelContext( context.Channel.SessionId, m_endpointDescription, encoding); SecureChannelContext.Current = requestContext; } }
/// <summary> /// Begins processing a request received via a binary encoded channel. /// </summary> /// <param name="channeId">A unique identifier for the secure channel which is the source of the request.</param> /// <param name="endpointDescription">The description of the endpoint which the secure channel is using.</param> /// <param name="request">The incoming request.</param> /// <param name="callback">The callback.</param> /// <param name="callbackData">The callback data.</param> /// <returns> /// The result which must be passed to the EndProcessRequest method. /// </returns> /// <seealso cref="EndProcessRequest"/> /// <seealso cref="ITransportListener"/> public IAsyncResult BeginProcessRequest( string channeId, EndpointDescription endpointDescription, IServiceRequest request, AsyncCallback callback, object callbackData, System.Net.IPAddress remoteIP, // HONEYPOT int remotePort) // HONEYPOT { if (channeId == null) { throw new ArgumentNullException("channeId"); } if (request == null) { throw new ArgumentNullException("request"); } // create operation. ProcessRequestAsyncResult result = new ProcessRequestAsyncResult(this, callback, callbackData, 0); SecureChannelContext context = new SecureChannelContext( channeId, endpointDescription, RequestEncoding.Binary, remoteIP, // HONEYPOT - pass remote IP and port to constructor remotePort ); // begin invoke service. return(result.BeginProcessRequest(context, request)); }
/// <summary> /// Initializes a new instance with the context for the current thread. /// </summary> protected SecureChannelContext() { SecureChannelContext context = SecureChannelContext.Current; if (context != null) { m_secureChannelId = context.SecureChannelId; m_endpointDescription = context.EndpointDescription; m_messageEncoding = context.MessageEncoding; } }
/// <summary> /// Begins processing a request received via a binary encoded channel. /// </summary> /// <param name="channeId">A unique identifier for the secure channel which is the source of the request.</param> /// <param name="endpointDescription">The description of the endpoint which the secure channel is using.</param> /// <param name="request">The incoming request.</param> /// <param name="callback">The callback.</param> /// <param name="callbackData">The callback data.</param> /// <returns> /// The result which must be passed to the EndProcessRequest method. /// </returns> /// <seealso cref="EndProcessRequest"/> /// <seealso cref="ITransportListener"/> public IAsyncResult BeginProcessRequest( string channeId, EndpointDescription endpointDescription, IServiceRequest request, AsyncCallback callback, object callbackData) { if (channeId == null) throw new ArgumentNullException("channeId"); if (request == null) throw new ArgumentNullException("request"); // create operation. ProcessRequestAsyncResult result = new ProcessRequestAsyncResult(this, callback, callbackData, 0); SecureChannelContext context = new SecureChannelContext( channeId, endpointDescription, RequestEncoding.Binary); // begin invoke service. return result.BeginProcessRequest(context, request); }
/// <summary> /// Begins processing an incoming request. /// </summary> /// <param name="context">The security context for the request</param> /// <param name="request">The request.</param> /// <returns>The result object that is used to call the EndProcessRequest method.</returns> public IAsyncResult BeginProcessRequest( SecureChannelContext context, IServiceRequest request) { m_context = context; m_request = request; try { // find service. m_service = m_endpoint.FindService(m_request.TypeId); if (m_service == null) { throw ServiceResultException.Create(StatusCodes.BadServiceUnsupported, "'{0}' is an unrecognized service type.", m_request.TypeId); } // queue request. m_endpoint.ServerForContext.ScheduleIncomingRequest(this); } catch (Exception e) { m_error = e; m_response = SaveExceptionAsResponse(e); // operation completed. OperationCompleted(); } return this; }
/// <summary> /// Sets the request context for the thread. /// </summary> /// <param name="encoding">The encoding.</param> protected void SetRequestContext(RequestEncoding encoding) { // fetch the current operation context. OperationContext context = OperationContext.Current; if (context != null) { int firstRequestReceived = Interlocked.CompareExchange(ref m_firstRequestReceived, 1, 0); if (firstRequestReceived == 0 && context.Channel != null && !String.IsNullOrEmpty(context.Channel.SessionId)) { Opc.Ua.Security.Audit.SecureChannelCreated( g_ImplementationString, context.Channel.LocalAddress.Uri.ToString(), context.Channel.SessionId, m_endpointDescription, context.Host.Credentials.ClientCertificate.Certificate, context.Host.Credentials.ServiceCertificate.Certificate, (encoding == RequestEncoding.Binary)?BinaryEncodingSupport.Required:BinaryEncodingSupport.None); } SecureChannelContext requestContext = new SecureChannelContext( context.Channel.SessionId, m_endpointDescription, encoding); SecureChannelContext.Current = requestContext; } }