aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/Token
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-25 21:37:52 +0800
committercrupest <crupest@outlook.com>2021-04-25 21:37:52 +0800
commitdc4f255e0fab5f6b39b7add197830591b89103c0 (patch)
treee919eaa01fda4efe318e48829360eeef7bf6491a /BackEnd/Timeline/Services/Token
parent657fb589137099794e58fbd35beb7d942b376965 (diff)
downloadtimeline-dc4f255e0fab5f6b39b7add197830591b89103c0.tar.gz
timeline-dc4f255e0fab5f6b39b7add197830591b89103c0.tar.bz2
timeline-dc4f255e0fab5f6b39b7add197830591b89103c0.zip
...
Diffstat (limited to 'BackEnd/Timeline/Services/Token')
-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
4 files changed, 334 insertions, 24 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,