public void BadFormatSamlResponseException_StringCtor() { var msg = "Message!"; var subject = new BadFormatSamlResponseException(msg); subject.Message.Should().Be(msg); }
public CommandResult Run(HttpRequestData request, IOptions options) { if(request == null) { throw new ArgumentNullException(nameof(request)); } if(options == null) { throw new ArgumentNullException(nameof(options)); } var binding = Saml2Binding.Get(request); if (binding != null) { UnbindResult unbindResult = null; try { unbindResult = binding.Unbind(request, options); var samlResponse = new Saml2Response(unbindResult.Data, request.StoredRequestState?.MessageId); var result = ProcessResponse(options, samlResponse, request.StoredRequestState); if(unbindResult.RelayState != null) { result.ClearCookieName = "Kentor." + unbindResult.RelayState; } return result; } catch (FormatException ex) { throw new BadFormatSamlResponseException( "The SAML Response did not contain valid BASE64 encoded data.", ex); } catch (XmlException ex) { var newEx = new BadFormatSamlResponseException( "The SAML response contains incorrect XML", ex); // Add the payload to the exception if (unbindResult != null) { newEx.Data["Saml2Response"] = unbindResult.Data.OuterXml; } throw newEx; } catch (Exception ex) { if (unbindResult != null) { // Add the payload to the existing exception ex.Data["Saml2Response"] = unbindResult.Data.OuterXml; } throw; } } throw new NoSamlResponseFoundException(); }
public CommandResult Run(HttpRequestData request, IOptions options) { if(request == null) { throw new ArgumentNullException(nameof(request)); } if(options == null) { throw new ArgumentNullException(nameof(options)); } var binding = Saml2Binding.Get(request); if (binding != null) { UnbindResult unbindResult = null; try { unbindResult = binding.Unbind(request); var samlResponse = Saml2Response.Read(unbindResult.Data, unbindResult.RelayState); return ProcessResponse(options, samlResponse); } catch (FormatException ex) { throw new BadFormatSamlResponseException( "The SAML Response did not contain valid BASE64 encoded data.", ex); } catch (XmlException ex) { var newEx = new BadFormatSamlResponseException( "The SAML response contains incorrect XML", ex); // Add the payload to the exception newEx.Data["Saml2Response"] = unbindResult.Data; throw newEx; } catch (Exception ex) { // Add the payload to the existing exception ex.Data["Saml2Response"] = unbindResult.Data; throw; } } throw new NoSamlResponseFoundException(); }