forked from winauth/winauth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthenticatorException.cs
More file actions
175 lines (155 loc) · 5.18 KB
/
Copy pathAuthenticatorException.cs
File metadata and controls
175 lines (155 loc) · 5.18 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* Copyright (C) 2010 Colin Mackie.
* This software is distributed under the terms of the GNU General Public License.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace WinAuth
{
/// <summary>
/// Base Authenticator exception class
/// </summary>
public class AuthenticatorException : ApplicationException
{
public AuthenticatorException()
: base()
{
}
public AuthenticatorException(string msg)
: base(msg)
{
}
public AuthenticatorException(string msg, Exception ex)
: base(msg, ex)
{
}
}
/// <summary>
/// Exception for reading invalid config data
/// </summary>
public class InvalidConfigDataException : AuthenticatorException
{
public InvalidConfigDataException() : base() { }
}
/// <summary>
/// Exception for invalid HMAC algorithm configuration
/// </summary>
public class InvalidHMACAlgorithmException : AuthenticatorException
{
public InvalidHMACAlgorithmException() : base() { }
}
/// <summary>
/// Exception for invalid user decryption
/// </summary>
public class InvalidUserDecryptionException : AuthenticatorException
{
public InvalidUserDecryptionException() : base() { }
}
/// <summary>
/// Exception for invalid machine decryption
/// </summary>
public class InvalidMachineDecryptionException : AuthenticatorException
{
public InvalidMachineDecryptionException() : base() { }
}
/// <summary>
/// Exception for error or unexpected return from server for enroll
/// </summary>
public class InvalidEnrollResponseException : AuthenticatorException
{
public InvalidEnrollResponseException(string msg = null, Exception ex = null) : base(msg, ex) { }
}
/// <summary>
/// Exception for error or unexpected return from server for trades
/// </summary>
public class InvalidTradesResponseException : AuthenticatorException
{
public InvalidTradesResponseException(string msg = null, Exception ex = null) : base(msg, ex) { }
}
/// <summary>
/// Exception for error or unexpected return from server for sync
/// </summary>
public class InvalidSyncResponseException : AuthenticatorException
{
public InvalidSyncResponseException(string msg) : base(msg) { }
}
/// <summary>
/// Config has been encrypted and we need a key
/// </summary>
public class EncryptedSecretDataException : AuthenticatorException
{
public EncryptedSecretDataException() : base() { }
}
/// <summary>
/// Config decryption bad password
/// </summary>
public class BadPasswordException : AuthenticatorException
{
public BadPasswordException(string msg = null, Exception ex = null) : base(msg, ex) { }
}
public class BadYubiKeyException : BadPasswordException
{
public BadYubiKeyException(string msg = null, Exception ex = null) : base(msg, ex) { }
}
public class InvalidRestoreResponseException : AuthenticatorException
{
public InvalidRestoreResponseException(string msg) : base(msg) { }
}
public class InvalidRestoreCodeException : InvalidRestoreResponseException
{
public InvalidRestoreCodeException(string msg) : base(msg) { }
}
/// <summary>
/// Invalid encryption detected
/// </summary>
public class InvalidEncryptionException : AuthenticatorException
{
public InvalidEncryptionException(string plain, string password, string encrypted, string decrypted) : base()
{
Plain = plain;
Password = password;
Encrypted = encrypted;
Decrypted = decrypted;
}
public string Plain { get; set; }
public string Password { get; set; }
public string Encrypted { get; set; }
public string Decrypted { get; set; }
}
/// <summary>
/// Error on setting secret data (invalid decoding) caused by corruption or wrong password
/// </summary>
public class InvalidSecretDataException : AuthenticatorException
{
public InvalidSecretDataException(Exception inner, string password, string encType, List<string> decrypted)
: base("Error decoding Secret Data", inner)
{
Password = password;
EncType = encType;
Decrypted = decrypted;
}
public string Password { get; set; }
public string EncType { get; set; }
public List<string> Decrypted { get; set; }
}
}