summary refs log tree commit diff
path: root/crypto/src/tls/TlsFatalAlert.cs
blob: 511fa9fb1dcfa00cdd9bd58f9a07d4f8c4e43824 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Runtime.Serialization;

namespace Org.BouncyCastle.Tls
{
    [Serializable]
    public class TlsFatalAlert
        : TlsException
    {
        private static string GetMessage(short alertDescription, string detailMessage)
        {
            string msg = Tls.AlertDescription.GetText(alertDescription);
            if (null != detailMessage)
            {
                msg += "; " + detailMessage;
            }
            return msg;
        }

        protected readonly short m_alertDescription;

        public TlsFatalAlert(short alertDescription)
            : this(alertDescription, (string)null)
        {
        }

        public TlsFatalAlert(short alertDescription, string detailMessage)
            : this(alertDescription, detailMessage, null)
        {
        }

        public TlsFatalAlert(short alertDescription, Exception alertCause)
            : this(alertDescription, null, alertCause)
        {
        }

        public TlsFatalAlert(short alertDescription, string detailMessage, Exception alertCause)
            : base(GetMessage(alertDescription, detailMessage), alertCause)
        {
            this.m_alertDescription = alertDescription;
        }

        protected TlsFatalAlert(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

        public virtual short AlertDescription
        {
            get { return m_alertDescription; }
        }
    }
}