// // GET: /Error/ public ActionResult Raven(RavenStatus id) { return(View(id)); }
/// <summary> /// Constructs an exception with the specified message and status. /// </summary> /// <param name="message"></param> /// <param name="status"></param> public RavenResponseException(String message, RavenStatus status) : this(message) { this.status = status; }
/// <summary> /// Constructs a RavenResponse object from data contained in a System.String. /// </summary> /// <param name="data">The System.String which contains the response data.</param> public RavenResponse(String data) { // store the response and initialise a new dictionary for // the data we have received this.data = data; this.parameters = new Dictionary<String, String>(); // split the response into its components String[] parts = data.Split(RESPONSE_SEP); if (parts.Length < 2) throw new RavenResponseException("too few fields"); // try to parse the protocol version and check that it is supported Int32 ver = 0; if (!Int32.TryParse(parts[0], out ver)) throw new RavenResponseException("could not identify protocol version"); if (ver > 3) throw new RavenException("Unsupported protcol version."); this.version = (RavenVersion)ver; // try to parse the status code Int32 statusCode = 0; if (!Int32.TryParse(parts[1], out statusCode)) throw new RavenResponseException("could not identify status code"); this.status = (RavenStatus)statusCode; // add all of the fields to the dictionary for (Int32 i = 0; i < parts.Length; i++) { this.parameters.Add(RESPONSE_FIELDS[i], HttpUtility.UrlDecode(parts[i])); } // try to parse the time when the session was started if (!this.parameters["issue"].FromRavenTime(out this.issued)) throw new RavenException("Unable to parse the time when the Raven response was issued."); // if the status is OK, then there is some additional data we need to process if (this.status == RavenStatus.OK) { // calculate the session lifetime: // the 'life' field contains the lifetime in seconds, // so we can calculate the time when the session expires by // adding those seconds to the time when the session was started Int32 lifetime = 0; if (!Int32.TryParse(this.parameters["life"], out lifetime)) throw new RavenResponseException("seesion lifetime is not specified"); this.expires = this.issued.AddSeconds(lifetime); if (this.parameters["kid"].StartsWith("0")) throw new RavenResponseException("invalid key ID"); // decode the signature this.signature = this.DecodeSignature(this.parameters["sig"]); } }
// // GET: /Error/ public ActionResult Raven(RavenStatus id) { return View(id); }
/// <summary> /// Constructs a RavenResponse object from data contained in a System.String. /// </summary> /// <param name="data">The System.String which contains the response data.</param> public RavenResponse(String data) { // store the response and initialise a new dictionary for // the data we have received this.data = data; this.parameters = new Dictionary <String, String>(); // split the response into its components String[] parts = data.Split(RESPONSE_SEP); if (parts.Length < 2) { throw new RavenResponseException("too few fields"); } // try to parse the protocol version and check that it is supported Int32 ver = 0; if (!Int32.TryParse(parts[0], out ver)) { throw new RavenResponseException("could not identify protocol version"); } if (ver > 3) { throw new RavenException("Unsupported protcol version."); } this.version = (RavenVersion)ver; // try to parse the status code Int32 statusCode = 0; if (!Int32.TryParse(parts[1], out statusCode)) { throw new RavenResponseException("could not identify status code"); } this.status = (RavenStatus)statusCode; // add all of the fields to the dictionary for (Int32 i = 0; i < parts.Length; i++) { this.parameters.Add(RESPONSE_FIELDS[i], HttpUtility.UrlDecode(parts[i])); } // try to parse the time when the session was started if (!this.parameters["issue"].FromRavenTime(out this.issued)) { throw new RavenException("Unable to parse the time when the Raven response was issued."); } // if the status is OK, then there is some additional data we need to process if (this.status == RavenStatus.OK) { // calculate the session lifetime: // the 'life' field contains the lifetime in seconds, // so we can calculate the time when the session expires by // adding those seconds to the time when the session was started Int32 lifetime = 0; if (!Int32.TryParse(this.parameters["life"], out lifetime)) { throw new RavenResponseException("seesion lifetime is not specified"); } this.expires = this.issued.AddSeconds(lifetime); if (this.parameters["kid"].StartsWith("0")) { throw new RavenResponseException("invalid key ID"); } // decode the signature this.signature = this.DecodeSignature(this.parameters["sig"]); } }