TlsException.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Transport Security Layer (TLS)
  2. // Copyright (c) 2003-2004 Carlos Guzman Alvarez
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. using System;
  24. using System.Text;
  25. using System.Runtime.Serialization;
  26. namespace Mono.Security.Protocol.Tls
  27. {
  28. [Serializable]
  29. internal sealed class TlsException : Exception
  30. {
  31. #region Fields
  32. private Alert alert;
  33. #endregion
  34. #region Properties
  35. public Alert Alert
  36. {
  37. get { return this.alert; }
  38. }
  39. #endregion
  40. #region Constructors
  41. internal TlsException(string message) : base(message)
  42. {
  43. }
  44. internal TlsException(SerializationInfo info, StreamingContext context) : base(info, context)
  45. {
  46. }
  47. internal TlsException(string message, Exception ex) : base(message, ex)
  48. {
  49. }
  50. internal TlsException(
  51. AlertLevel level,
  52. AlertDescription description)
  53. : this (level, description, Alert.GetAlertMessage(description))
  54. {
  55. }
  56. internal TlsException(
  57. AlertLevel level,
  58. AlertDescription description,
  59. string message) : base (message)
  60. {
  61. this.alert = new Alert(level, description);
  62. }
  63. internal TlsException(
  64. AlertDescription description)
  65. : this (description, Alert.GetAlertMessage(description))
  66. {
  67. }
  68. internal TlsException(
  69. AlertDescription description,
  70. string message) : base (message)
  71. {
  72. this.alert = new Alert(description);
  73. }
  74. #endregion
  75. }
  76. }