aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline/Services')
-rw-r--r--BackEnd/Timeline/Services/Token/JwtUserTokenBadFormatException.cs16
-rw-r--r--BackEnd/Timeline/Services/Token/Resource.Designer.cs162
-rw-r--r--BackEnd/Timeline/Services/Token/Resource.resx153
-rw-r--r--BackEnd/Timeline/Services/Token/UserTokenException.cs27
-rw-r--r--BackEnd/Timeline/Services/User/PasswordBadFormatException.cs26
-rw-r--r--BackEnd/Timeline/Services/User/PasswordService.cs24
-rw-r--r--BackEnd/Timeline/Services/User/Resource.Designer.cs63
-rw-r--r--BackEnd/Timeline/Services/User/Resource.resx21
8 files changed, 428 insertions, 64 deletions
diff --git a/BackEnd/Timeline/Services/Token/JwtUserTokenBadFormatException.cs b/BackEnd/Timeline/Services/Token/JwtUserTokenBadFormatException.cs
index 4d7300a1..7d272170 100644
--- a/BackEnd/Timeline/Services/Token/JwtUserTokenBadFormatException.cs
+++ b/BackEnd/Timeline/Services/Token/JwtUserTokenBadFormatException.cs
@@ -1,6 +1,5 @@
using System;
using System.Globalization;
-using static Timeline.Resources.Services.Exception;
namespace Timeline.Services.Token
{
@@ -34,16 +33,15 @@ namespace Timeline.Services.Token
{
var reason = type switch
{
- ErrorKind.NoIdClaim => JwtUserTokenBadFormatExceptionIdMissing,
- ErrorKind.IdClaimBadFormat => JwtUserTokenBadFormatExceptionIdBadFormat,
- ErrorKind.NoVersionClaim => JwtUserTokenBadFormatExceptionVersionMissing,
- ErrorKind.VersionClaimBadFormat => JwtUserTokenBadFormatExceptionVersionBadFormat,
- ErrorKind.Other => JwtUserTokenBadFormatExceptionOthers,
- _ => JwtUserTokenBadFormatExceptionUnknown
+ ErrorKind.NoIdClaim => Resource.ExceptionJwtUserTokenBadFormatReasonIdMissing,
+ ErrorKind.IdClaimBadFormat => Resource.ExceptionJwtUserTokenBadFormatReasonIdBadFormat,
+ ErrorKind.NoVersionClaim => Resource.ExceptionJwtUserTokenBadFormatReasonVersionMissing,
+ ErrorKind.VersionClaimBadFormat => Resource.ExceptionJwtUserTokenBadFormatReasonVersionBadFormat,
+ ErrorKind.Other => Resource.ExceptionJwtUserTokenBadFormatReasonOthers,
+ _ => Resource.ExceptionJwtUserTokenBadFormatReasonUnknown
};
- return string.Format(CultureInfo.CurrentCulture,
- Resources.Services.Exception.JwtUserTokenBadFormatException, reason);
+ return string.Format(CultureInfo.CurrentCulture, Resource.ExceptionJwtUserTokenBadFormat, reason);
}
}
}
diff --git a/BackEnd/Timeline/Services/Token/Resource.Designer.cs b/BackEnd/Timeline/Services/Token/Resource.Designer.cs
new file mode 100644
index 00000000..4321c665
--- /dev/null
+++ b/BackEnd/Timeline/Services/Token/Resource.Designer.cs
@@ -0,0 +1,162 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Timeline.Services.Token {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Services.Token.Resource", typeof(Resource).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The token didn&apos;t pass verification because {0}..
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormat {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormat", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to id claim is not a number.
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormatReasonIdBadFormat {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormatReasonIdBadFormat", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to id claim does not exist.
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormatReasonIdMissing {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormatReasonIdMissing", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to other error, see inner exception for information.
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormatReasonOthers {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormatReasonOthers", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to unknown error.
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormatReasonUnknown {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormatReasonUnknown", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to version claim is not a number..
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormatReasonVersionBadFormat {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormatReasonVersionBadFormat", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to version claim does not exist..
+ /// </summary>
+ internal static string ExceptionJwtUserTokenBadFormatReasonVersionMissing {
+ get {
+ return ResourceManager.GetString("ExceptionJwtUserTokenBadFormatReasonVersionMissing", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The token is of bad format, which means it may not be created by the server..
+ /// </summary>
+ internal static string ExceptionUserTokenBadFormat {
+ get {
+ return ResourceManager.GetString("ExceptionUserTokenBadFormat", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The token is expired because its expiration time has passed..
+ /// </summary>
+ internal static string ExceptionUserTokenTimeExpired {
+ get {
+ return ResourceManager.GetString("ExceptionUserTokenTimeExpired", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The owner user of the token does not exist..
+ /// </summary>
+ internal static string ExceptionUserTokenUserNotExist {
+ get {
+ return ResourceManager.GetString("ExceptionUserTokenUserNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The token is of bad version..
+ /// </summary>
+ internal static string ExceptionUserTokenVersionExpired {
+ get {
+ return ResourceManager.GetString("ExceptionUserTokenVersionExpired", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Services/Token/Resource.resx b/BackEnd/Timeline/Services/Token/Resource.resx
new file mode 100644
index 00000000..c42da2ca
--- /dev/null
+++ b/BackEnd/Timeline/Services/Token/Resource.resx
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="ExceptionJwtUserTokenBadFormat" xml:space="preserve">
+ <value>The token didn't pass verification because {0}.</value>
+ </data>
+ <data name="ExceptionJwtUserTokenBadFormatReasonIdBadFormat" xml:space="preserve">
+ <value>id claim is not a number</value>
+ </data>
+ <data name="ExceptionJwtUserTokenBadFormatReasonIdMissing" xml:space="preserve">
+ <value>id claim does not exist</value>
+ </data>
+ <data name="ExceptionJwtUserTokenBadFormatReasonOthers" xml:space="preserve">
+ <value>other error, see inner exception for information</value>
+ </data>
+ <data name="ExceptionJwtUserTokenBadFormatReasonUnknown" xml:space="preserve">
+ <value>unknown error</value>
+ </data>
+ <data name="ExceptionJwtUserTokenBadFormatReasonVersionBadFormat" xml:space="preserve">
+ <value>version claim is not a number.</value>
+ </data>
+ <data name="ExceptionJwtUserTokenBadFormatReasonVersionMissing" xml:space="preserve">
+ <value>version claim does not exist.</value>
+ </data>
+ <data name="ExceptionUserTokenBadFormat" xml:space="preserve">
+ <value>The token is of bad format, which means it may not be created by the server.</value>
+ </data>
+ <data name="ExceptionUserTokenTimeExpired" xml:space="preserve">
+ <value>The token is expired because its expiration time has passed.</value>
+ </data>
+ <data name="ExceptionUserTokenUserNotExist" xml:space="preserve">
+ <value>The owner user of the token does not exist.</value>
+ </data>
+ <data name="ExceptionUserTokenVersionExpired" xml:space="preserve">
+ <value>The token is of bad version.</value>
+ </data>
+</root> \ No newline at end of file
diff --git a/BackEnd/Timeline/Services/Token/UserTokenException.cs b/BackEnd/Timeline/Services/Token/UserTokenException.cs
index d666ba10..a781eb05 100644
--- a/BackEnd/Timeline/Services/Token/UserTokenException.cs
+++ b/BackEnd/Timeline/Services/Token/UserTokenException.cs
@@ -2,7 +2,6 @@
namespace Timeline.Services.Token
{
-
[Serializable]
public class UserTokenException : Exception
{
@@ -22,11 +21,11 @@ namespace Timeline.Services.Token
[Serializable]
public class UserTokenTimeExpiredException : UserTokenException
{
- public UserTokenTimeExpiredException() : base(Resources.Services.Exception.UserTokenTimeExpireException) { }
+ public UserTokenTimeExpiredException() : base(Resource.ExceptionUserTokenTimeExpired) { }
public UserTokenTimeExpiredException(string message) : base(message) { }
public UserTokenTimeExpiredException(string message, Exception inner) : base(message, inner) { }
- public UserTokenTimeExpiredException(string token, DateTime expireTime, DateTime verifyTime) : base(token, Resources.Services.Exception.UserTokenTimeExpireException) { ExpireTime = expireTime; VerifyTime = verifyTime; }
- public UserTokenTimeExpiredException(string token, DateTime expireTime, DateTime verifyTime, Exception inner) : base(token, Resources.Services.Exception.UserTokenTimeExpireException, inner) { ExpireTime = expireTime; VerifyTime = verifyTime; }
+ public UserTokenTimeExpiredException(string token, DateTime expireTime, DateTime verifyTime) : base(token, Resource.ExceptionUserTokenTimeExpired) { ExpireTime = expireTime; VerifyTime = verifyTime; }
+ public UserTokenTimeExpiredException(string token, DateTime expireTime, DateTime verifyTime, Exception inner) : base(token, Resource.ExceptionUserTokenTimeExpired, inner) { ExpireTime = expireTime; VerifyTime = verifyTime; }
protected UserTokenTimeExpiredException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
@@ -39,11 +38,11 @@ namespace Timeline.Services.Token
[Serializable]
public class UserTokenVersionExpiredException : UserTokenException
{
- public UserTokenVersionExpiredException() : base(Resources.Services.Exception.UserTokenBadVersionException) { }
+ public UserTokenVersionExpiredException() : base(Resource.ExceptionUserTokenVersionExpired) { }
public UserTokenVersionExpiredException(string message) : base(message) { }
public UserTokenVersionExpiredException(string message, Exception inner) : base(message, inner) { }
- public UserTokenVersionExpiredException(string token, long tokenVersion, long requiredVersion) : base(token, Resources.Services.Exception.UserTokenBadVersionException) { TokenVersion = tokenVersion; RequiredVersion = requiredVersion; }
- public UserTokenVersionExpiredException(string token, long tokenVersion, long requiredVersion, Exception inner) : base(token, Resources.Services.Exception.UserTokenBadVersionException, inner) { TokenVersion = tokenVersion; RequiredVersion = requiredVersion; }
+ public UserTokenVersionExpiredException(string token, long tokenVersion, long requiredVersion) : base(token, Resource.ExceptionUserTokenVersionExpired) { TokenVersion = tokenVersion; RequiredVersion = requiredVersion; }
+ public UserTokenVersionExpiredException(string token, long tokenVersion, long requiredVersion, Exception inner) : base(token, Resource.ExceptionUserTokenVersionExpired, inner) { TokenVersion = tokenVersion; RequiredVersion = requiredVersion; }
protected UserTokenVersionExpiredException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
@@ -57,11 +56,9 @@ namespace Timeline.Services.Token
[Serializable]
public class UserTokenUserNotExistException : UserTokenException
{
- const string message = "The owner of the token does not exist.";
-
- public UserTokenUserNotExistException() : base(message) { }
- public UserTokenUserNotExistException(string token) : base(token, message) { }
- public UserTokenUserNotExistException(string token, Exception inner) : base(token, message, inner) { }
+ public UserTokenUserNotExistException() : base(Resource.ExceptionUserTokenUserNotExist) { }
+ public UserTokenUserNotExistException(string token) : base(token, Resource.ExceptionUserTokenUserNotExist) { }
+ public UserTokenUserNotExistException(string token, Exception inner) : base(token, Resource.ExceptionUserTokenUserNotExist, inner) { }
protected UserTokenUserNotExistException(
System.Runtime.Serialization.SerializationInfo info,
@@ -71,10 +68,10 @@ namespace Timeline.Services.Token
[Serializable]
public class UserTokenBadFormatException : UserTokenException
{
- public UserTokenBadFormatException() : base(Resources.Services.Exception.UserTokenBadFormatException) { }
- public UserTokenBadFormatException(string token) : base(token, Resources.Services.Exception.UserTokenBadFormatException) { }
+ public UserTokenBadFormatException() : base(Resource.ExceptionUserTokenBadFormat) { }
+ public UserTokenBadFormatException(string token) : base(token, Resource.ExceptionUserTokenBadFormat) { }
public UserTokenBadFormatException(string token, string message) : base(token, message) { }
- public UserTokenBadFormatException(string token, Exception inner) : base(token, Resources.Services.Exception.UserTokenBadFormatException, inner) { }
+ public UserTokenBadFormatException(string token, Exception inner) : base(token, Resource.ExceptionUserTokenBadFormat, inner) { }
public UserTokenBadFormatException(string token, string message, Exception inner) : base(token, message, inner) { }
protected UserTokenBadFormatException(
System.Runtime.Serialization.SerializationInfo info,
diff --git a/BackEnd/Timeline/Services/User/PasswordBadFormatException.cs b/BackEnd/Timeline/Services/User/PasswordBadFormatException.cs
deleted file mode 100644
index b9d76017..00000000
--- a/BackEnd/Timeline/Services/User/PasswordBadFormatException.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-
-namespace Timeline.Services.User
-{
- [Serializable]
- public class PasswordBadFormatException : Exception
- {
- public PasswordBadFormatException() : base(Resources.Services.Exception.PasswordBadFormatException) { }
- public PasswordBadFormatException(string message) : base(message) { }
- public PasswordBadFormatException(string message, Exception inner) : base(message, inner) { }
-
- public PasswordBadFormatException(string password, string validationMessage) : this()
- {
- Password = password;
- ValidationMessage = validationMessage;
- }
-
- protected PasswordBadFormatException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
-
- public string Password { get; set; } = "";
-
- public string ValidationMessage { get; set; } = "";
- }
-}
diff --git a/BackEnd/Timeline/Services/User/PasswordService.cs b/BackEnd/Timeline/Services/User/PasswordService.cs
index 580471e1..1c14875f 100644
--- a/BackEnd/Timeline/Services/User/PasswordService.cs
+++ b/BackEnd/Timeline/Services/User/PasswordService.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using System;
+using System.Globalization;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
@@ -12,18 +13,13 @@ namespace Timeline.Services.User
[Serializable]
public class HashedPasswordBadFromatException : Exception
{
- private static string MakeMessage(string reason)
- {
- return Resources.Services.Exception.HashedPasswordBadFromatException + " Reason: " + reason;
- }
-
- public HashedPasswordBadFromatException() : base(Resources.Services.Exception.HashedPasswordBadFromatException) { }
+ public HashedPasswordBadFromatException() : base(Resource.ExceptionHashedPasswordBadFormat) { }
public HashedPasswordBadFromatException(string message) : base(message) { }
public HashedPasswordBadFromatException(string message, Exception inner) : base(message, inner) { }
- public HashedPasswordBadFromatException(string hashedPassword, string reason) : base(MakeMessage(reason)) { HashedPassword = hashedPassword; }
- public HashedPasswordBadFromatException(string hashedPassword, string reason, Exception inner) : base(MakeMessage(reason), inner) { HashedPassword = hashedPassword; }
+ public HashedPasswordBadFromatException(string hashedPassword, string reason, Exception? inner = null)
+ : base(string.Format(CultureInfo.InvariantCulture, Resource.ExceptionHashedPasswordBadFormat, reason), inner) { HashedPassword = hashedPassword; }
protected HashedPasswordBadFromatException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
@@ -150,19 +146,19 @@ namespace Timeline.Services.User
}
catch (FormatException e)
{
- throw new HashedPasswordBadFromatException(hashedPassword, Resources.Services.Exception.HashedPasswordBadFromatExceptionNotBase64, e);
+ throw new HashedPasswordBadFromatException(hashedPassword, Resource.ExceptionHashedPasswordBadFormatReasonNotBase64, e);
}
// read the format marker from the hashed password
if (decodedHashedPassword.Length == 0)
{
- throw new HashedPasswordBadFromatException(hashedPassword, Resources.Services.Exception.HashedPasswordBadFromatExceptionNotLength0);
+ throw new HashedPasswordBadFromatException(hashedPassword, Resource.ExceptionHashedPasswordBadFormatReasonLength0);
}
return (decodedHashedPassword[0]) switch
{
0x01 => VerifyHashedPasswordV3(decodedHashedPassword, providedPassword, hashedPassword),
- _ => throw new HashedPasswordBadFromatException(hashedPassword, Resources.Services.Exception.HashedPasswordBadFromatExceptionNotUnknownMarker),
+ _ => throw new HashedPasswordBadFromatException(hashedPassword, Resource.ExceptionHashedPasswordBadFormatReasonUnknownMarker),
};
}
@@ -178,7 +174,7 @@ namespace Timeline.Services.User
// Read the salt: must be >= 128 bits
if (saltLength < 128 / 8)
{
- throw new HashedPasswordBadFromatException(hashedPasswordString, Resources.Services.Exception.HashedPasswordBadFromatExceptionNotSaltTooShort);
+ throw new HashedPasswordBadFromatException(hashedPasswordString, Resource.ExceptionHashedPasswordBadFormatReasonSaltTooShort);
}
byte[] salt = new byte[saltLength];
Buffer.BlockCopy(hashedPassword, 13, salt, 0, salt.Length);
@@ -187,7 +183,7 @@ namespace Timeline.Services.User
int subkeyLength = hashedPassword.Length - 13 - salt.Length;
if (subkeyLength < 128 / 8)
{
- throw new HashedPasswordBadFromatException(hashedPasswordString, Resources.Services.Exception.HashedPasswordBadFromatExceptionNotSubkeyTooShort);
+ throw new HashedPasswordBadFromatException(hashedPasswordString, Resource.ExceptionHashedPasswordBadFormatReasonSubkeyTooShort);
}
byte[] expectedSubkey = new byte[subkeyLength];
Buffer.BlockCopy(hashedPassword, 13 + salt.Length, expectedSubkey, 0, expectedSubkey.Length);
@@ -201,7 +197,7 @@ namespace Timeline.Services.User
// This should never occur except in the case of a malformed payload, where
// we might go off the end of the array. Regardless, a malformed payload
// implies verification failed.
- throw new HashedPasswordBadFromatException(hashedPasswordString, Resources.Services.Exception.HashedPasswordBadFromatExceptionNotOthers, e);
+ throw new HashedPasswordBadFromatException(hashedPasswordString, Resource.ExceptionHashedPasswordBadFormatReasonOthers, e);
}
}
diff --git a/BackEnd/Timeline/Services/User/Resource.Designer.cs b/BackEnd/Timeline/Services/User/Resource.Designer.cs
index d64a7aab..4f75b055 100644
--- a/BackEnd/Timeline/Services/User/Resource.Designer.cs
+++ b/BackEnd/Timeline/Services/User/Resource.Designer.cs
@@ -70,6 +70,69 @@ namespace Timeline.Services.User {
}
/// <summary>
+ /// Looks up a localized string similar to The hashes password is of bad format. It might not be created by server. Reason: {0}.
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormat {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormat", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Decoded hashed password is of length 0..
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormatReasonLength0 {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormatReasonLength0", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Not of valid base64 format. See inner exception..
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormatReasonNotBase64 {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormatReasonNotBase64", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to See inner exception..
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormatReasonOthers {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormatReasonOthers", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Salt length &lt; 128 bits..
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormatReasonSaltTooShort {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormatReasonSaltTooShort", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Subkey length &lt; 128 bits..
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormatReasonSubkeyTooShort {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormatReasonSubkeyTooShort", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Unknown format marker..
+ /// </summary>
+ internal static string ExceptionHashedPasswordBadFormatReasonUnknownMarker {
+ get {
+ return ResourceManager.GetString("ExceptionHashedPasswordBadFormatReasonUnknownMarker", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Nickname is of bad format. {0}.
/// </summary>
internal static string ExceptionNicknameBadFormat {
diff --git a/BackEnd/Timeline/Services/User/Resource.resx b/BackEnd/Timeline/Services/User/Resource.resx
index 732cfefd..28e75b19 100644
--- a/BackEnd/Timeline/Services/User/Resource.resx
+++ b/BackEnd/Timeline/Services/User/Resource.resx
@@ -120,6 +120,27 @@
<data name="ExceptionBadPassword" xml:space="preserve">
<value>Password is wrong.</value>
</data>
+ <data name="ExceptionHashedPasswordBadFormat" xml:space="preserve">
+ <value>The hashes password is of bad format. It might not be created by server. Reason: {0}</value>
+ </data>
+ <data name="ExceptionHashedPasswordBadFormatReasonLength0" xml:space="preserve">
+ <value>Decoded hashed password is of length 0.</value>
+ </data>
+ <data name="ExceptionHashedPasswordBadFormatReasonNotBase64" xml:space="preserve">
+ <value>Not of valid base64 format. See inner exception.</value>
+ </data>
+ <data name="ExceptionHashedPasswordBadFormatReasonOthers" xml:space="preserve">
+ <value>See inner exception.</value>
+ </data>
+ <data name="ExceptionHashedPasswordBadFormatReasonSaltTooShort" xml:space="preserve">
+ <value>Salt length &lt; 128 bits.</value>
+ </data>
+ <data name="ExceptionHashedPasswordBadFormatReasonSubkeyTooShort" xml:space="preserve">
+ <value>Subkey length &lt; 128 bits.</value>
+ </data>
+ <data name="ExceptionHashedPasswordBadFormatReasonUnknownMarker" xml:space="preserve">
+ <value>Unknown format marker.</value>
+ </data>
<data name="ExceptionNicknameBadFormat" xml:space="preserve">
<value>Nickname is of bad format. {0}</value>
</data>