private void SendPacket(string Name, ExpectedResponses.type type) { if (type == ExpectedResponses.type.FullPacketResponse) { ExpectedResponse.ExpectedPacket = BuildExpectedResponse(OutGoingPacket); ExpectedResponse.ResponseExpected = true; ExpectedResponse.Name = Name; ExpectedResponse.ResponseType = type; try { SP.Write(OutGoingPacket, 0, OutGoingPacket.Length); } catch (Exception ex) { MessageBox.Show("While trying to send out serial port data, CommProtocol had this error: " + ex.Message, "CommProtocol Error"); } ResponseTimer.Start(); } else if (type == ExpectedResponses.type.DataResponse) { ExpectedResponse.ExpectedPacket = "UNDEFINED";//a data packet is expected, we can't define it here ExpectedResponse.ResponseExpected = true; ExpectedResponse.Name = Name; ExpectedResponse.ResponseType = type; try { SP.Write(OutGoingPacket, 0, OutGoingPacket.Length); } catch (Exception ex) { MessageBox.Show("While trying to send out serial port data, CommProtocol had this error: " + ex.Message, "CommProtocol Error"); } ResponseTimer.Start(); } else if (type == ExpectedResponses.type.none) { try { SP.Write(OutGoingPacket, 0, OutGoingPacket.Length);//no response is expected, just write the packet } catch (Exception ex) { MessageBox.Show("While trying to send out serial port data, CommProtocol had this error: " + ex.Message, "CommProtocol Error"); } } }
public ResponseTimeoutEventArgs(ExpectedResponses ExpectedResponse, string BufferContents) { this.BufferContents = BufferContents; this.ExpectedResponse = ExpectedResponse; }
private string AuthnRequestForIdp(IdentityProvider identityProvider, Saml20AuthnRequest request, IOwinContext context, Saml2Configuration config) { var logger = SAML2.Logging.LoggerProvider.LoggerFor(typeof(SamlMessage)); context.Set(IdpTempSessionKey, identityProvider.Id); // Determine which endpoint to use from the configuration file or the endpoint metadata. var destination = IdpSelectionUtil.DetermineEndpointConfiguration(BindingType.Redirect, identityProvider.Endpoints.DefaultSignOnEndpoint, identityProvider.Metadata.SSOEndpoints); request.Destination = destination.Url; if (identityProvider.ForceAuth) { request.ForceAuthn = true; } // Check isPassive status if (context.Get <bool>(IdpIsPassive)) { request.IsPassive = true; } if (identityProvider.IsPassive) { request.IsPassive = true; } // Check if request should forceAuthn if (context.Get <bool>(IdpForceAuthn)) { request.ForceAuthn = true; } // Check if protocol binding should be forced if (identityProvider.Endpoints.DefaultSignOnEndpoint != null) { if (!string.IsNullOrEmpty(identityProvider.Endpoints.DefaultSignOnEndpoint.ForceProtocolBinding)) { request.ProtocolBinding = identityProvider.Endpoints.DefaultSignOnEndpoint.ForceProtocolBinding; } } // Save request message id to session ExpectedResponses.Add(request.Id); switch (destination.Binding) { case BindingType.Redirect: logger.DebugFormat(TraceMessages.AuthnRequestPrepared, identityProvider.Id, Saml20Constants.ProtocolBindings.HttpRedirect); var redirectBuilder = new HttpRedirectBindingBuilder { SigningKey = config.ServiceProvider.SigningCertificate.PrivateKey, Request = request.GetXml().OuterXml }; logger.DebugFormat(TraceMessages.AuthnRequestSent, redirectBuilder.Request); var redirectLocation = request.Destination + "?" + redirectBuilder.ToQuery(); return(redirectLocation); case BindingType.Post: throw new NotImplementedException(); //logger.DebugFormat(TraceMessages.AuthnRequestPrepared, identityProvider.Id, Saml20Constants.ProtocolBindings.HttpPost); //var postBuilder = new HttpPostBindingBuilder(destination); //// Honor the ForceProtocolBinding and only set this if it's not already set //if (string.IsNullOrEmpty(request.ProtocolBinding)) { // request.ProtocolBinding = Saml20Constants.ProtocolBindings.HttpPost; //} //var requestXml = request.GetXml(); //XmlSignatureUtils.SignDocument(requestXml, request.Id, config.ServiceProvider.SigningCertificate); //postBuilder.Request = requestXml.OuterXml; //logger.DebugFormat(TraceMessages.AuthnRequestSent, postBuilder.Request); //context.Response.Write(postBuilder.GetPage()); //break; case BindingType.Artifact: throw new NotImplementedException(); //logger.DebugFormat(TraceMessages.AuthnRequestPrepared, identityProvider.Id, Saml20Constants.ProtocolBindings.HttpArtifact); //var artifactBuilder = new HttpArtifactBindingBuilder(context, config); //// Honor the ForceProtocolBinding and only set this if it's not already set //if (string.IsNullOrEmpty(request.ProtocolBinding)) { // request.ProtocolBinding = Saml20Constants.ProtocolBindings.HttpArtifact; //} //logger.DebugFormat(TraceMessages.AuthnRequestSent, request.GetXml().OuterXml); //artifactBuilder.RedirectFromLogin(destination, request); //break; default: logger.Error(SAML2.ErrorMessages.EndpointBindingInvalid); throw new Saml20Exception(SAML2.ErrorMessages.EndpointBindingInvalid); } throw new NotImplementedException(); }