/// <summary> /// Parses the response from the server into a CAS Assertion and includes /// this in a CASPrincipal. /// </summary> /// <param name="response"> /// the response from the server, in any format. /// </param> /// <param name="ticket">The ticket used to generate the validation response</param> /// <returns> /// a Principal backed by a CAS Assertion, if one could be created from the /// response. /// </returns> /// <exception cref="TicketValidationException"> /// Thrown if creation of the Assertion fails. /// </exception> protected override ICasPrincipal ParseResponseFromServer(string response, string ticket) { if (response == null) { throw new ArgumentNullException("response"); } // parse Assertion element out of SAML response from CAS CasSaml11Response casSaml11Response = new CasSaml11Response(response, CasAuthentication.TicketTimeTolerance); if (casSaml11Response.HasCasSamlAssertion) { protoLogger.Debug("Valid Assertion found: " + casSaml11Response.CasPrincipal.Assertion); return(casSaml11Response.CasPrincipal); } else { throw new TicketValidationException("CAS Server response could not be parsed."); } }
/// <summary> /// Parses the response from the server into a CAS Assertion and includes this in /// a CASPrincipal. /// </summary> /// <param name="response">the response from the server, in any format.</param> /// <returns> /// a Principal backed by a CAS Assertion, if one could be created from the response. /// </returns> /// <exception cref="TicketValidationException"> /// Thrown if creation of the Assertion fails. /// </exception> protected override ICasPrincipal ParseResponseFromServer(string response) { if (response == null) { throw new TicketValidationException("CAS Server could not validate ticket."); } // parse Assertion element out of SAML response from CAS CasSaml11Response casSaml11Response = new CasSaml11Response(response, this.TicketTimeTolerance); if (casSaml11Response.HasCasSamlAssertion) { if (log.IsDebugEnabled) { log.Debug(string.Format("{0}:Valid Assertion found", CommonUtils.MethodName)); log.Debug(string.Format("{0}:CasAssertion:{1}", CommonUtils.MethodName, DebugUtils.IPrincipalToString(casSaml11Response.CasPrincipal, DebugUtils.CR, " ", 2, ">", true))); } return casSaml11Response.CasPrincipal; } else { throw new TicketValidationException("CAS Server response could not be parsed."); } }
/// <summary> /// Parses the response from the server into a CAS Assertion and includes /// this in a CASPrincipal. /// </summary> /// <param name="response"> /// the response from the server, in any format. /// </param> /// <param name="ticket">The ticket used to generate the validation response</param> /// <returns> /// a Principal backed by a CAS Assertion, if one could be created from the /// response. /// </returns> /// <exception cref="TicketValidationException"> /// Thrown if creation of the Assertion fails. /// </exception> protected override ICasPrincipal ParseResponseFromServer(string response, string ticket) { if (response == null) { throw new ArgumentNullException("response"); } // parse Assertion element out of SAML response from CAS CasSaml11Response casSaml11Response = new CasSaml11Response(response, CasAuthentication.TicketTimeTolerance); if (casSaml11Response.HasCasSamlAssertion) { protoLogger.Debug("Valid Assertion found: " + casSaml11Response.CasPrincipal.Assertion); return casSaml11Response.CasPrincipal; } else { throw new TicketValidationException("CAS Server response could not be parsed."); } }