diff --git a/MSBuild.build.bat b/MSBuild.build.bat new file mode 100644 index 0000000000000000000000000000000000000000..94acfa84edf3ae0312d7c423cb40b951edc23ec0 --- /dev/null +++ b/MSBuild.build.bat @@ -0,0 +1,9 @@ +REM set __msBuildDir=%WINDIR%\Microsoft.NET\Framework\v2.0.50727 +REM set __msBuildDir=%WINDIR%\Microsoft.NET\Framework\v3.5 +set __msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319 + +call "%__msBuildDir%\msbuild.exe" /target:BuildAndTest "MSBuild.build.xml" /p:Configuration=Debug;FavoriteFood=Popeyes /l:FileLogger,Microsoft.Build.Engine;logfile=MSBuild.build_Debug.log +call "%__msBuildDir%\msbuild.exe" /target:BuildAndTest "MSBuild.build.xml" /p:Configuration=Release;FavoriteFood=Popeyes /l:FileLogger,Microsoft.Build.Engine;logfile=MSBuild.build_Release.log + + +set __msBuildDir= \ No newline at end of file diff --git a/MSBuild.build.xml b/MSBuild.build.xml new file mode 100644 index 0000000000000000000000000000000000000000..a864eb0fd6b31b36843e709f494bf550f70aafb4 --- /dev/null +++ b/MSBuild.build.xml @@ -0,0 +1,31 @@ + + + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MSBuild.build_Debug.log b/MSBuild.build_Debug.log new file mode 100644 index 0000000000000000000000000000000000000000..9d48093ff1ad1798e904f84bec1df218c2aafcf4 --- /dev/null +++ b/MSBuild.build_Debug.log @@ -0,0 +1,19 @@ +Build started 04-02-2021 11:49:16. +__________________________________________________ +Project "C:\Users\kristian.sorensen-bo\source\repos\dotnet\MSBuild.build.xml" (BuildAndTest target(s)): + +Target BuildAndTest: + Target Test: + C:\Users\kristian.sorensen-bo\source\repos\dotnet\MSBuild.build.xml(16,3): error MSB4036: The "NUnit3" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\windows\Microsoft.NET\Framework\v2.0.50727" directory. + Done building target "Test" in project "MSBuild.build.xml" -- FAILED. +Done building target "BuildAndTest" in project "MSBuild.build.xml" -- FAILED. + +Done building project "MSBuild.build.xml" -- FAILED. + +Build FAILED. + +C:\Users\kristian.sorensen-bo\source\repos\dotnet\MSBuild.build.xml(16,3): error MSB4036: The "NUnit3" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\windows\Microsoft.NET\Framework\v2.0.50727" directory. + 0 Warning(s) + 1 Error(s) + +Time Elapsed 00:00:00.09 diff --git a/MSBuild.build_Release.log b/MSBuild.build_Release.log new file mode 100644 index 0000000000000000000000000000000000000000..72fda28628d6bb16fbab6af4e15583f09c70f570 --- /dev/null +++ b/MSBuild.build_Release.log @@ -0,0 +1,19 @@ +Build started 04-02-2021 11:49:16. +__________________________________________________ +Project "C:\Users\kristian.sorensen-bo\source\repos\dotnet\MSBuild.build.xml" (BuildAndTest target(s)): + +Target BuildAndTest: + Target Test: + C:\Users\kristian.sorensen-bo\source\repos\dotnet\MSBuild.build.xml(16,3): error MSB4036: The "NUnit3" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\windows\Microsoft.NET\Framework\v2.0.50727" directory. + Done building target "Test" in project "MSBuild.build.xml" -- FAILED. +Done building target "BuildAndTest" in project "MSBuild.build.xml" -- FAILED. + +Done building project "MSBuild.build.xml" -- FAILED. + +Build FAILED. + +C:\Users\kristian.sorensen-bo\source\repos\dotnet\MSBuild.build.xml(16,3): error MSB4036: The "NUnit3" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\windows\Microsoft.NET\Framework\v2.0.50727" directory. + 0 Warning(s) + 1 Error(s) + +Time Elapsed 00:00:00.12 diff --git a/build.xml b/build.xml index ccd01ff486df544276679d1698cf58ef39e1ad8a..803cfe33e35290b493b39a7f77908a08b495afeb 100644 --- a/build.xml +++ b/build.xml @@ -1,438 +1,438 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Temp.NoSign.dir - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Temp.NoSign.dir + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/dk.gov.oiosi.exception/MainException.cs b/src/dk.gov.oiosi.exception/MainException.cs index d02060f5fe4e89e28669d5202393290ee5bdeb5b..d03b62369bb7c2e88e4d1109389644803757aaeb 100644 --- a/src/dk.gov.oiosi.exception/MainException.cs +++ b/src/dk.gov.oiosi.exception/MainException.cs @@ -66,8 +66,7 @@ namespace dk.gov.oiosi.exception /// Construct an exception. It assumes that the error message text is /// stored in the main resource file of this module /// - public MainException() - { + public MainException() { this.logger = LoggerFactory.Create(this.GetType()); this.SetMessage(new Dictionary(), null); } @@ -78,10 +77,10 @@ namespace dk.gov.oiosi.exception /// of this module /// /// the resourceFile - public MainException(ResourceManager resourceManager) + public MainException(ResourceManager resourceManager, string errorCode = "") { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(resourceManager, new Dictionary(), null); + this.SetMessage(resourceManager, new Dictionary(), null, errorCode); } /// @@ -101,10 +100,10 @@ namespace dk.gov.oiosi.exception /// text is stored in the main resource file of this module /// /// the keyword for the message - public MainException(Dictionary keywords) + public MainException(Dictionary keywords, string errorCode = "") { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(keywords, null); + this.SetMessage(keywords, null, errorCode); } /// @@ -126,10 +125,10 @@ namespace dk.gov.oiosi.exception /// /// the resourceFile /// the keyword for the message - public MainException(ResourceManager resourceManager, Dictionary keywords) + public MainException(ResourceManager resourceManager, Dictionary keywords, string errorCode = "") { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(resourceManager, keywords, null); + this.SetMessage(resourceManager, keywords, null, errorCode); } /// @@ -152,11 +151,11 @@ namespace dk.gov.oiosi.exception /// /// the resourceFile /// the innerException to throw - public MainException(ResourceManager resourceManager, Exception innerException) + public MainException(ResourceManager resourceManager, Exception innerException, string errorCode = "") : base(string.Empty, innerException) { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(resourceManager, new Dictionary(), innerException); + this.SetMessage(resourceManager, new Dictionary(), innerException, errorCode); } /// /// Constructs an exception with external error messages and an inner exception. @@ -165,11 +164,11 @@ namespace dk.gov.oiosi.exception /// /// the resourceFile /// the innerException to throw - public MainException(ICollection resourceManager, Exception innerException) + public MainException(ICollection resourceManager, Exception innerException, string errorCode = "") : base(string.Empty, innerException) { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(resourceManager, new Dictionary(), innerException); + this.SetMessage(resourceManager, new Dictionary(), innerException, errorCode); } /// @@ -178,11 +177,12 @@ namespace dk.gov.oiosi.exception /// /// the keyword for the message /// the innerexception to throw - public MainException(Dictionary keywords, Exception innerException) + /// The NemHandel standard error-code syntax (Optional) + public MainException(Dictionary keywords, Exception innerException, string errorCode = "") : base(string.Empty, innerException) { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(keywords, innerException); + this.SetMessage(keywords, innerException, errorCode); } /// @@ -193,11 +193,11 @@ namespace dk.gov.oiosi.exception /// the resourcefile /// the keyword for the message /// the innerexception of the thrown exception - public MainException(ResourceManager resourceManager, Dictionary keywords, Exception innerException) + public MainException(ResourceManager resourceManager, Dictionary keywords, Exception innerException, string errorCode = "") : base(string.Empty, innerException) { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(resourceManager, keywords, innerException); + this.SetMessage(resourceManager, keywords, innerException, errorCode); } /// @@ -208,11 +208,11 @@ namespace dk.gov.oiosi.exception /// the resourcefile /// the keyword for the message /// the innerexception of the thrown exception - public MainException(ICollection resourceManager, Dictionary keywords, Exception innerException) + public MainException(ICollection resourceManager, Dictionary keywords, Exception innerException, string errorCode = "") : base(string.Empty, innerException) { this.logger = LoggerFactory.Create(this.GetType()); - this.SetMessage(resourceManager, keywords, innerException); + this.SetMessage(resourceManager, keywords, innerException, errorCode); } #region Standard Exception implementation @@ -273,11 +273,14 @@ namespace dk.gov.oiosi.exception get { return message; } } - private void SetMessage(Dictionary keywords, Exception originalException) { + private void SetMessage(Dictionary keywords, Exception originalException, string errorCode = "") { Type exceptionType = this.GetType(); try { - message = exceptionMessageStore.GetExceptionMessage(resources, exceptionType, keywords); + message = + !string.IsNullOrEmpty(errorCode) ? + string.Format("{0}: {1}", errorCode, exceptionMessageStore.GetExceptionMessage(resources, exceptionType, keywords)) : + exceptionMessageStore.GetExceptionMessage(resources, exceptionType, keywords); } catch { @@ -296,19 +299,19 @@ namespace dk.gov.oiosi.exception } } - private void SetMessage(ResourceManager resource, Dictionary keywords, Exception originalException) + private void SetMessage(ResourceManager resource, Dictionary keywords, Exception originalException, string errorCode = "") { List collectiveResources = new List(resources); collectiveResources.Add(resource); - this.SetMessage(collectiveResources, keywords, originalException); + this.SetMessage(collectiveResources, keywords, originalException, errorCode); } - private void SetMessage(ICollection resourceManagerCollection, Dictionary keywords, Exception originalException) + private void SetMessage(ICollection resourceManagerCollection, Dictionary keywords, Exception originalException, string errorCode = "") { Type exceptionType = this.GetType(); try { - message = exceptionMessageStore.GetExceptionMessage(resourceManagerCollection, exceptionType, keywords); + message = !string.IsNullOrEmpty(errorCode) ? string.Format("{0}: {1}", errorCode, exceptionMessageStore.GetExceptionMessage(resourceManagerCollection, exceptionType, keywords)): exceptionMessageStore.GetExceptionMessage(resourceManagerCollection, exceptionType, keywords); } catch { diff --git a/src/dk.gov.oiosi.exception/NullArgumentException.cs b/src/dk.gov.oiosi.exception/NullArgumentException.cs index e184b0f8fbf6a1a5c9565415ddd7755de5dd9aad..9aa4a1b4b071562adc2fdddf1de3f00860d029c8 100644 --- a/src/dk.gov.oiosi.exception/NullArgumentException.cs +++ b/src/dk.gov.oiosi.exception/NullArgumentException.cs @@ -46,6 +46,7 @@ namespace dk.gov.oiosi.exception { /// Constructor /// /// Name of the argument that was null - public NullArgumentException(string argument) : base(KeywordFromString.GetKeyword("argument", argument)) { } + /// NemHandel standardised error code + public NullArgumentException(string argument, string errorCode ="") : base(KeywordFromString.GetKeyword("argument", argument), errorCode) { } } } diff --git a/src/dk.gov.oiosi.exception/NullOrEmptyArgumentException.cs b/src/dk.gov.oiosi.exception/NullOrEmptyArgumentException.cs index 6b78297020ebf5b9f60cf764a473e3ccc2f806f8..dadea7b0ad073953cd348b29209edf6f06a31e85 100644 --- a/src/dk.gov.oiosi.exception/NullOrEmptyArgumentException.cs +++ b/src/dk.gov.oiosi.exception/NullOrEmptyArgumentException.cs @@ -46,6 +46,7 @@ namespace dk.gov.oiosi.exception { /// Constructor /// /// Name of the argument that was null or empty - public NullOrEmptyArgumentException(string argument) : base(KeywordFromString.GetKeyword("argument", argument)) { } + /// NemHandel standardised error code + public NullOrEmptyArgumentException(string argument, string errorCode = "") : base(KeywordFromString.GetKeyword("argument", argument), errorCode) { } } } diff --git a/src/dk.gov.oiosi.exception/UnexpectedNumberOfCharactersException.cs b/src/dk.gov.oiosi.exception/UnexpectedNumberOfCharactersException.cs index f3b78e7452760d2cd366e4a6ca5724aa3c47206b..1e82b31d38fe34668bab6d494b24a8d3ac6d7bda 100644 --- a/src/dk.gov.oiosi.exception/UnexpectedNumberOfCharactersException.cs +++ b/src/dk.gov.oiosi.exception/UnexpectedNumberOfCharactersException.cs @@ -49,7 +49,7 @@ namespace dk.gov.oiosi.exception { /// /// The argument that was checked for character count /// The number of characters found - public UnexpectedNumberOfCharactersException(string argument, int characters) : base(GetKeywords(argument, characters)) { } + public UnexpectedNumberOfCharactersException(string argument, int characters, string errorCode = "") : base(GetKeywords(argument, characters), errorCode) { } /// /// Returns the relevant keyword key/values for the exception text diff --git a/src/dk.gov.oiosi/addressing/Identifier.cs b/src/dk.gov.oiosi/addressing/Identifier.cs index 21d0277b72f3a0c720976e5bb53e7ee5be253c6a..f8070010583adc6621d48aa41079fbdf34d3010a 100644 --- a/src/dk.gov.oiosi/addressing/Identifier.cs +++ b/src/dk.gov.oiosi/addressing/Identifier.cs @@ -74,17 +74,17 @@ namespace dk.gov.oiosi.addressing { // value - DK99010080, 5798009811578 if (string.IsNullOrEmpty(this.value)) { - throw new NullOrEmptyArgumentException("Value/key is empty"); + throw new NullOrEmptyArgumentException("E-RSP33001: Value/key is empty"); } else if (this.value.Trim().Contains(" ")) { - throw new IncorrectBusinessIdentifierException(this.value); + throw new IncorrectBusinessIdentifierException("E-RSP33002:" + this.value); } // type - EAN, DK:CPR, if (string.IsNullOrEmpty(this.type)) { - throw new NullOrEmptyArgumentException("identifierType"); + throw new NullOrEmptyArgumentException("E-RSP33003:" + "identifierType"); } // For Type=DK:CVR, strip DK from start (if present) diff --git a/src/dk.gov.oiosi/common/CouldNotLoadTypeException.cs b/src/dk.gov.oiosi/common/CouldNotLoadTypeException.cs index f463e0b4a1e89ca255e10b5511ab6729a9df2632..d4403f351ed25fdc26de8f952b8905b65d403509 100644 --- a/src/dk.gov.oiosi/common/CouldNotLoadTypeException.cs +++ b/src/dk.gov.oiosi/common/CouldNotLoadTypeException.cs @@ -44,7 +44,6 @@ namespace dk.gov.oiosi.common { /// Constructor /// /// The assembly qualified name of the type that could not be loaded - public CouldNotLoadTypeException(string type) : - base(KeywordFromString.GetKeyword("type", type)) { } + public CouldNotLoadTypeException(string type, string errorCode = "") : base(KeywordFromString.GetKeyword("type", type), errorCode) { } } } diff --git a/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs index 94faea5e34899c29d236eacfe18882923f4fd75a..99c7453cc7593aff901ae529d1a9c9875236f8cc 100644 --- a/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.common { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { @@ -70,7 +70,7 @@ namespace dk.gov.oiosi.common { } /// - /// Looks up a localized string similar to Kunne ikke oprette en instans af typen "[implementationnamespaceclass]" i dll'en "[implementationassembly]".. + /// Looks up a localized string similar to E-RSP32105: Kunne ikke oprette en instans af typen "[implementationnamespaceclass]" i dll'en "[implementationassembly]".. /// internal static string dk_gov_oiosi_common_CreateInstanceFailedException { get { diff --git a/src/dk.gov.oiosi/common/ErrorMessages.resx b/src/dk.gov.oiosi/common/ErrorMessages.resx index 1e0a379d6b5d0a4e87bee481f499a123e4aeab50..852a3bb7b6be4e76edd86419150b8ce5b563ac18 100644 --- a/src/dk.gov.oiosi/common/ErrorMessages.resx +++ b/src/dk.gov.oiosi/common/ErrorMessages.resx @@ -112,16 +112,16 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Kunne ikke loade en instans af typen '[type]'. - Kunne ikke oprette en instans af typen "[implementationnamespaceclass]" i dll'en "[implementationassembly]". + E-RSP32105: Kunne ikke oprette en instans af typen "[implementationnamespaceclass]" i dll'en "[implementationassembly]". Ukendt servicenøgle type kode "[endpointkeytypecode]". diff --git a/src/dk.gov.oiosi/common/ExternalCodeFactory.cs b/src/dk.gov.oiosi/common/ExternalCodeFactory.cs index 001bf1b0d355d6c4a966aab0e98ccf51e641c842..a2d91f462cd812476d0dd3feb99dd7810664c24f 100644 --- a/src/dk.gov.oiosi/common/ExternalCodeFactory.cs +++ b/src/dk.gov.oiosi/common/ExternalCodeFactory.cs @@ -17,7 +17,7 @@ namespace dk.gov.oiosi.common /// public T CreateInstance(IExternalCodeFactoryConfiguration configuration) { - if (configuration == null) throw new NullArgumentException("configuration"); + if (configuration == null) throw new NullArgumentException("E-RSP32101: 'configuration' is null"); return this.CreateInstance(configuration.ImplementationNamespaceClass, configuration.ImplementationAssembly); } @@ -30,20 +30,21 @@ namespace dk.gov.oiosi.common /// public T CreateInstance(string implementationNamespaceClass, string implementationAssembly) { - if (implementationNamespaceClass == null) throw new NullArgumentException("implementationNamespaceClass"); - if (implementationAssembly == null) throw new NullArgumentException("implementationAssembly"); + if (implementationNamespaceClass == null) throw new NullArgumentException("E-RSP32102: 'implementationNamespaceClass' is null"); + if (implementationAssembly == null) throw new NullArgumentException("E-RSP32103: 'implementationAssembly' is null"); try { string qualifiedTypename = implementationNamespaceClass + ", " + implementationAssembly; Type instanceType = Type.GetType(qualifiedTypename); if (instanceType == null) - throw new CouldNotLoadTypeException(qualifiedTypename); + throw new CouldNotLoadTypeException(string.Format("E-RSP32104: '{0}' is null", qualifiedTypename)); // 3. Instantiate the type: T instance = (T)instanceType.GetConstructor(new Type[0]).Invoke(null); return instance; } catch (Exception ex) { + //ErrorCode: E-RSP32105 throw new CreateInstanceFailedException(implementationNamespaceClass, implementationAssembly, ex); } } diff --git a/src/dk.gov.oiosi/common/IdentifierUtility.cs b/src/dk.gov.oiosi/common/IdentifierUtility.cs index 1914e5709dba0d489609a9615f069657c61d030f..c6c9a7c1926c18178012d723ba13a254773f82d8 100644 --- a/src/dk.gov.oiosi/common/IdentifierUtility.cs +++ b/src/dk.gov.oiosi/common/IdentifierUtility.cs @@ -131,7 +131,7 @@ namespace dk.gov.oiosi.common } catch (Exception e) { - throw new ArgumentException("EndpointAddress could not be created from " + endpointAddress, e); + throw new ArgumentException("E-RSP32001: EndpointAddress could not be created from " + endpointAddress, e); } } diff --git a/src/dk.gov.oiosi/common/UtilityException.cs b/src/dk.gov.oiosi/common/UtilityException.cs index 13510d140f4e5ae0653ed9fac08743bc89b3457c..38f3c56db1f6a5e990c69ece83e93b26725c10a6 100644 --- a/src/dk.gov.oiosi/common/UtilityException.cs +++ b/src/dk.gov.oiosi/common/UtilityException.cs @@ -52,7 +52,7 @@ namespace dk.gov.oiosi.common { /// Constructor with keywords /// /// keyword for the message - public UtilityException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public UtilityException(System.Collections.Generic.Dictionary keywords, string errorCode= "") : base(resourceManager, keywords, errorCode) { } /// /// Constructor with innerexception diff --git a/src/dk.gov.oiosi/common/cache/QuantityCache.cs b/src/dk.gov.oiosi/common/cache/QuantityCache.cs index a2c27576e8e7e106761dd556a92e8b6678c36046..641c1ba19d01e7fba68b5aadd9cbd4f677853fea 100644 --- a/src/dk.gov.oiosi/common/cache/QuantityCache.cs +++ b/src/dk.gov.oiosi/common/cache/QuantityCache.cs @@ -54,7 +54,7 @@ namespace dk.gov.oiosi.common.cache { /// /// public QuantityCache(int maxSize) { - if (maxSize < 0) throw new ArgumentOutOfRangeException("maxSize"); + if (maxSize < 0) throw new ArgumentOutOfRangeException("E-RSP32201: Argument 'maxSize' is out of range."); this.Setup(maxSize); } @@ -70,17 +70,17 @@ namespace dk.gov.oiosi.common.cache { // parsed okay if (maxSize < 0) { - throw new Exception("MaxSize must not be less then zero."); + throw new Exception("E-RSP32202: Argument 'maxSize' must not be less then zero."); } } else { - throw new Exception("Argument maxSize could not be parsed to an integer."); + throw new Exception("E-RSP32203: Argument 'maxSize' could not be parsed to an integer."); } } else { - throw new Exception("Argument maxSize was not present in the configuration file."); + throw new Exception("E-RSP32204: Argument 'maxSize' is missing in the configuration file."); } if (configuration.ContainsKey("CacheName")) @@ -110,7 +110,7 @@ namespace dk.gov.oiosi.common.cache { { if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException("E-RSP32205: 'key' is null"); } if (_maxSize == 0) @@ -127,7 +127,7 @@ namespace dk.gov.oiosi.common.cache { { // key does already exist // so it is not added again - throw new ArgumentNullException("key"); + throw new ArgumentException("E-RSP32206: 'key' already exists in dictionary"); } else { @@ -150,7 +150,7 @@ namespace dk.gov.oiosi.common.cache { TValue result; if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException("E-RSP32205: 'key' is null"); } if (_maxSize == 0) @@ -183,13 +183,13 @@ namespace dk.gov.oiosi.common.cache { } /// - /// Sets item in cachem by removing the old value and adding the new value + /// Sets item in cache by removing the old value and adding the new value /// /// /// public void Set(TKey key, TValue value) { - if (key == null) throw new ArgumentNullException("key"); + if (key == null) throw new ArgumentNullException("E-RSP32205: 'key' is null"); if (_maxSize == 0) return; lock (_lockObject) { @@ -210,7 +210,7 @@ namespace dk.gov.oiosi.common.cache { bool result = false; if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException("E-RSP32205: 'key' is null"); } else if (_maxSize == 0) { @@ -245,7 +245,7 @@ namespace dk.gov.oiosi.common.cache { { if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException("E-RSP32205: 'key' is null"); } else if (_maxSize == 0) { @@ -284,7 +284,7 @@ namespace dk.gov.oiosi.common.cache { if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException("E-RSP32205: 'key' is null"); } else if (_maxSize == 0) { diff --git a/src/dk.gov.oiosi/common/cache/TimedCache.cs b/src/dk.gov.oiosi/common/cache/TimedCache.cs index 43a1fec841bbb4829fce6c7f17933fff4eef0541..b781b825260235fff0507792a1f61cfcac6fc4f9 100644 --- a/src/dk.gov.oiosi/common/cache/TimedCache.cs +++ b/src/dk.gov.oiosi/common/cache/TimedCache.cs @@ -112,7 +112,7 @@ namespace dk.gov.oiosi.common.cache { else { // could not be parsed, valie is invalid - throw new Exception("Failed to create the TimeCache, because the configuration is invalid. Could not parse the validityInMinutes value '" + configuration[validityTimeInMinutesString] + "' to an int."); + throw new Exception("E-RSP32301: Failed to create the TimeCache, because the configuration is invalid. Could not parse the validityInMinutes value '" + configuration[validityTimeInMinutesString] + "' to an int."); } } else if (configuration.ContainsKey(validityTimeInHoursString)) @@ -134,7 +134,7 @@ namespace dk.gov.oiosi.common.cache { else { // could not be parsed, valie is invalid - throw new Exception("Failed to create the TimeCache, because the configuration is invalid. Could not parse the validityInMinutes value '" + configuration[validityTimeInHoursString] + "' to an int."); + throw new Exception("E-RSP32301: Failed to create the TimeCache, because the configuration is invalid. Could not parse the validityInMinutes value '" + configuration[validityTimeInHoursString] + "' to an int."); } } else @@ -169,7 +169,7 @@ namespace dk.gov.oiosi.common.cache { else { // could not be parsed, valie is invalid - throw new Exception("Failed to create the TimeCache, because the configuration is invalid. Could not parse the frequencyInMinutes value '" + configuration[frequencyInMinutesString] + "' to an int."); + throw new Exception("E-RSP32302: Failed to create the TimeCache, because the configuration is invalid. Could not parse the frequencyInMinutes value '" + configuration[frequencyInMinutesString] + "' to an int."); } } else if (configuration.ContainsKey(frequencyInHoursString)) @@ -183,7 +183,7 @@ namespace dk.gov.oiosi.common.cache { else { // could not be parsed, valie is invalid - throw new Exception("Failed to create the TimeCache, because the configuration is invalid. Could not parse the frequencyInHours value '" + configuration[frequencyInHoursString] + "' to an int."); + throw new Exception("E-RSP32302: Failed to create the TimeCache, because the configuration is invalid. Could not parse the frequencyInHours value '" + configuration[frequencyInHoursString] + "' to an int."); } } else @@ -213,7 +213,7 @@ namespace dk.gov.oiosi.common.cache { // The frequence must be greater then one minutes if (frequencyInMinutes < 1) { - throw new Exception("The frequency cache check '" + frequencyInMinutes + "' must be greater then one minute."); + throw new Exception("E-RSP32303: The frequency cache check '" + frequencyInMinutes + "' must be greater then one minute."); } // start a new scheduled task, starting now @@ -256,7 +256,7 @@ namespace dk.gov.oiosi.common.cache { TValue result; if (key == null) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException("E-RSP32304: 'key' is null"); } else { diff --git a/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs index 499ac0c475f196c4cea909335b95dc266eec6aea..1d4586fba0a8714dc3a94a04e2dfeafa0e5ca502 100644 --- a/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.communication { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { @@ -61,7 +61,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Kunne ikke instantiere et proxy objekt til kommunikation med servicen. + /// Looks up a localized string similar to E-RSP31003: Kunne ikke instantiere et proxy objekt til kommunikation med servicen. /// internal static string dk_gov_oiosi_communication_client_ProxyGenerationException { get { @@ -89,7 +89,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Fandt flere dokumenttyper med rodnavne "[rootname]", rodnamespace "[rootnamespace]" og identifikationsdiskriminatorerne "[identifierdiscriminators]". Dette skyldes sandssynligvis en fejl i konfigurationsfilen.. + /// Looks up a localized string similar to E-RSP31106: Fandt flere dokumenttyper med rodnavne "[rootname]", rodnamespace "[rootnamespace]" og identifikationsdiskriminatorerne "[identifierdiscriminators]". Dette skyldes sandssynligvis en fejl i konfigurationsfilen.. /// internal static string dk_gov_oiosi_communication_configuration_AmbiguousDocumentTypeResultFromParametersException { get { @@ -99,7 +99,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Dokumentet [DocumentName] findes allerede i samlingen af dokumenttype-konfigurationer. Dette skyldes sandssynligvis at en dokumenttype er konfigureret 2 gange i konfigurationen. + /// Looks up a localized string similar to E-RSP31142: Dokumentet [DocumentName] findes allerede i samlingen af dokumenttype-konfigurationer. Dette skyldes sandssynligvis at en dokumenttype er konfigureret 2 gange i konfigurationen. /// internal static string dk_gov_oiosi_communication_configuration_DocumentAllreadyAddedException { get { @@ -108,7 +108,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Kunne ikke mappe værdien "[value]" til en nøgletype. Nøgler-type-angivelse i afsendte dokumenter er mappet til nøgle-type-definitioner i konfigurationen for hver dokumenttype. Der kunne ikke findes et match.. + /// Looks up a localized string similar to E-RSP31131: Kunne ikke mappe værdien "[value]" til en nøgletype. Nøgler-type-angivelse i afsendte dokumenter er mappet til nøgle-type-definitioner i konfigurationen for hver dokumenttype. Der kunne ikke findes et match.. /// internal static string dk_gov_oiosi_communication_configuration_KeyTypeMappingFailedException { get { @@ -126,7 +126,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Kunne ikke finde dokumenttypen med id "[guid]". Dette skyldes sandssynligvis, at dokumenttypen ikke er konfigureret.. + /// Looks up a localized string similar to E-RSP31105: Kunne ikke finde dokumenttypen med id "[guid]". Dette skyldes sandssynligvis, at dokumenttypen ikke er konfigureret.. /// internal static string dk_gov_oiosi_communication_configuration_NoDocumentTypeFoundFromIdException { get { @@ -145,7 +145,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Der opstod en fejl under instantieringen af en kommunikationskanal.. + /// Looks up a localized string similar to E-RSP31004: Der opstod en fejl under instantieringen af en kommunikationskanal.. /// internal static string dk_gov_oiosi_communication_CreatingCommunicationChannelFailedException { get { @@ -154,7 +154,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Kunne ikke finde den aktuelle servicehost.. + /// Looks up a localized string similar to E-RSP31303: Kunne ikke finde den aktuelle servicehost.. /// internal static string dk_gov_oiosi_communication_CurrentServiceHostSearchFailedException { get { @@ -163,7 +163,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to En SOAP fault meddelelse blev returneret af det kaldte endpoint. Beskeden er: '[fault]'. Fejlen skyldes: '[source]'.. + /// Looks up a localized string similar to E-RSP31007: En SOAP fault meddelelse blev returneret af det kaldte endpoint. Beskeden er: '[fault]'. Fejlen skyldes: '[source]'.. /// internal static string dk_gov_oiosi_communication_FaultReturnedException { get { @@ -172,7 +172,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Den angivet TCP port "[tcpportnumber]" er ikke indenfor det gyldige interval 0-65536.. + /// Looks up a localized string similar to E-RSP31021: Den angivet TCP port "[tcpportnumber]" er ikke indenfor det gyldige interval 0-65536.. /// internal static string dk_gov_oiosi_communication_InvalidTcpPortException { get { @@ -181,7 +181,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Den type endpoint applikationen har valgt at lytte på er ikke supporteret. '[type]' endpoints kan ikke bruge som serivce endpoints.. + /// Looks up a localized string similar to E-RSP31308: Den type endpoint applikationen har valgt at lytte på er ikke supporteret. '[type]' endpoints kan ikke bruge som serivce endpoints.. /// internal static string dk_gov_oiosi_communication_listener_EndpointTypeNotSupportedException { get { @@ -200,7 +200,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to There was no unique service endpoint configured. + /// Looks up a localized string similar to E-RSP31307: There was no unique service endpoint configured. /// internal static string dk_gov_oiosi_communication_listener_NoUniqueEndpointException { get { @@ -209,7 +209,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Kunne ikke starte lytningen på følgende adresse(r) "[listeningaddresses]".. + /// Looks up a localized string similar to E-RSP31309: Kunne ikke starte lytningen på følgende adresse(r) "[listeningaddresses]".. /// internal static string dk_gov_oiosi_communication_listener_StartListeningFailedException { get { @@ -218,7 +218,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Kunne ikke stoppe lytningen på følgende adresse(r) "[listeningaddresses]".. + /// Looks up a localized string similar to E-RSP31310: Kunne ikke stoppe lytningen på følgende adresse(r) "[listeningaddresses]".. /// internal static string dk_gov_oiosi_communication_listener_StopListeningFailedException { get { @@ -245,7 +245,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Elementet '[element]' manglede i kommunikationsstakken. Dette skyldes enten at den ikke er korrekt konfigureret configured i app.config, eller sat programmatisk på bindingen.. + /// Looks up a localized string similar to E-RSP31006: Elementet '[element]' manglede i kommunikationsstakken. Dette skyldes enten at den ikke er korrekt konfigureret configured i app.config, eller sat programmatisk på bindingen.. /// internal static string dk_gov_oiosi_communication_MissingStackElementException { get { @@ -254,7 +254,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Der skal angives et endpoint for at kunne generere et 'request'.. + /// Looks up a localized string similar to E-RSP31001: Der skal angives et endpoint for at kunne generere et 'request'.. /// internal static string dk_gov_oiosi_communication_NoEndpointGivenException { get { @@ -263,7 +263,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to The scheme '[scheme]' is not supported by RaspRequest.. + /// Looks up a localized string similar to E-RSP31002: The scheme '[scheme]' is not supported by RaspRequest.. /// internal static string dk_gov_oiosi_communication_NotSupportedSchemeException { get { @@ -290,7 +290,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Nedlukning af kommunikationen fejlede.. + /// Looks up a localized string similar to E-RSP31005: Nedlukning af kommunikationen fejlede.. /// internal static string dk_gov_oiosi_communication_RequestShutdownException { get { @@ -317,7 +317,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to Der findes ingen der lytter til inkomne beskeder.. + /// Looks up a localized string similar to E-RSP31305: Der findes ingen der lytter til inkomne beskeder.. /// internal static string dk_gov_oiosi_communication_WcfListenerSearchFailedException { get { diff --git a/src/dk.gov.oiosi/communication/ErrorMessages.resx b/src/dk.gov.oiosi/communication/ErrorMessages.resx index 9dea80309edc89ae55b6c4b4c7c8b33ca3e84f15..6024b9727b10749c4f6a8f1e73a31ce8692ba74e 100644 --- a/src/dk.gov.oiosi/communication/ErrorMessages.resx +++ b/src/dk.gov.oiosi/communication/ErrorMessages.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Kunne ikke instantiere et proxy objekt til kommunikation med servicen + E-RSP31003: Kunne ikke instantiere et proxy objekt til kommunikation med servicen Fandt flere dokumenttype-konfigurationer for dette dokument. Dette skyldes sandssynligvis en fejl i konfigurationsfilen. @@ -127,49 +127,49 @@ Fandt flere dokumenttyper med id "[guid]". Dette skyldes sandssynligvis en fejl i konfigurationsfilen. - Fandt flere dokumenttyper med rodnavne "[rootname]", rodnamespace "[rootnamespace]" og identifikationsdiskriminatorerne "[identifierdiscriminators]". Dette skyldes sandssynligvis en fejl i konfigurationsfilen. + E-RSP31106: Fandt flere dokumenttyper med rodnavne "[rootname]", rodnamespace "[rootnamespace]" og identifikationsdiskriminatorerne "[identifierdiscriminators]". Dette skyldes sandssynligvis en fejl i konfigurationsfilen. - Dokumentet [DocumentName] findes allerede i samlingen af dokumenttype-konfigurationer. Dette skyldes sandssynligvis at en dokumenttype er konfigureret 2 gange i konfigurationen + E-RSP31142: Dokumentet [DocumentName] findes allerede i samlingen af dokumenttype-konfigurationer. Dette skyldes sandssynligvis at en dokumenttype er konfigureret 2 gange i konfigurationen - Kunne ikke mappe værdien "[value]" til en nøgletype. Nøgler-type-angivelse i afsendte dokumenter er mappet til nøgle-type-definitioner i konfigurationen for hver dokumenttype. Der kunne ikke findes et match. + E-RSP31131: Kunne ikke mappe værdien "[value]" til en nøgletype. Nøgler-type-angivelse i afsendte dokumenter er mappet til nøgle-type-definitioner i konfigurationen for hver dokumenttype. Der kunne ikke findes et match. Kunne ikke finde dokumenttypen. Dette skyldes sandssynligvis, at dokumenttypen ikke er konfigureret. - Kunne ikke finde dokumenttypen med id "[guid]". Dette skyldes sandssynligvis, at dokumenttypen ikke er konfigureret. + E-RSP31105: Kunne ikke finde dokumenttypen med id "[guid]". Dette skyldes sandssynligvis, at dokumenttypen ikke er konfigureret. Kunne ikke finde dokumenttypen med rodnavne "[rootname]", rodnamespace "[rootnamespace]" og identifikationsdiskriminatorerne "[identifierdiscriminators]". Dette skyldes sandssynligvis, at dokumenttypen ikke er konfigureret. - Der opstod en fejl under instantieringen af en kommunikationskanal. + E-RSP31004: Der opstod en fejl under instantieringen af en kommunikationskanal. - Kunne ikke finde den aktuelle servicehost. + E-RSP31303: Kunne ikke finde den aktuelle servicehost. - En SOAP fault meddelelse blev returneret af det kaldte endpoint. Beskeden er: '[fault]'. Fejlen skyldes: '[source]'. + E-RSP31007: En SOAP fault meddelelse blev returneret af det kaldte endpoint. Beskeden er: '[fault]'. Fejlen skyldes: '[source]'. - Den angivet TCP port "[tcpportnumber]" er ikke indenfor det gyldige interval 0-65536. + E-RSP31021: Den angivet TCP port "[tcpportnumber]" er ikke indenfor det gyldige interval 0-65536. - Den type endpoint applikationen har valgt at lytte på er ikke supporteret. '[type]' endpoints kan ikke bruge som serivce endpoints. + E-RSP31308: Den type endpoint applikationen har valgt at lytte på er ikke supporteret. '[type]' endpoints kan ikke bruge som serivce endpoints. No unique endpoint was given for the RASP Listener. Make sure your ListenerIdentity and App.Config only defines one, and only one, endpoint of type [type]. - There was no unique service endpoint configured + E-RSP31307: There was no unique service endpoint configured - Kunne ikke starte lytningen på følgende adresse(r) "[listeningaddresses]". + E-RSP31309: Kunne ikke starte lytningen på følgende adresse(r) "[listeningaddresses]". - Kunne ikke stoppe lytningen på følgende adresse(r) "[listeningaddresses]". + E-RSP31310: Kunne ikke stoppe lytningen på følgende adresse(r) "[listeningaddresses]". Failed to find listener to the service host "[currentservicehostname]". @@ -178,13 +178,13 @@ Der var ikke sat tilstrækkelige credentials. Både et klient- og servercertifikat skal sættes, enten i konfigurationen eller programmatisk. - Elementet '[element]' manglede i kommunikationsstakken. Dette skyldes enten at den ikke er korrekt konfigureret configured i app.config, eller sat programmatisk på bindingen. + E-RSP31006: Elementet '[element]' manglede i kommunikationsstakken. Dette skyldes enten at den ikke er korrekt konfigureret configured i app.config, eller sat programmatisk på bindingen. - Der skal angives et endpoint for at kunne generere et 'request'. + E-RSP31001: Der skal angives et endpoint for at kunne generere et 'request'. - The scheme '[scheme]' is not supported by RaspRequest. + E-RSP31002: The scheme '[scheme]' is not supported by RaspRequest. Der opstod en fejl i kommunikationsstakken. @@ -193,7 +193,7 @@ Klient- og serverkonfiguration matcher ikke. Du bør sikre dig at den kaldte service overholder RASP profilen. - Nedlukning af kommunikationen fejlede. + E-RSP31005: Nedlukning af kommunikationen fejlede. Afsendelse og modtagelse af et svar fejlede. @@ -202,6 +202,6 @@ SOAP action '[expected]' var forventet på svaret men action '[gotten]' blev modtaget - Der findes ingen der lytter til inkomne beskeder. + E-RSP31305: Der findes ingen der lytter til inkomne beskeder. \ No newline at end of file diff --git a/src/dk.gov.oiosi/communication/OiosiCommunicationException.cs b/src/dk.gov.oiosi/communication/OiosiCommunicationException.cs index 6b8cbbce8fab2d53d4a8030458fd9d067da2dc0a..864ccf552a65feb56ee8c982073d1c5f4df8f29e 100644 --- a/src/dk.gov.oiosi/communication/OiosiCommunicationException.cs +++ b/src/dk.gov.oiosi/communication/OiosiCommunicationException.cs @@ -95,7 +95,7 @@ namespace dk.gov.oiosi.communication { /// /// /// - public OiosiCommunicationException(ResourceManager errorMessages, System.Collections.Generic.Dictionary keywords) : base(errorMessages, keywords) { } + public OiosiCommunicationException(ResourceManager errorMessages, System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(errorMessages, keywords, errorCode) { } /// /// Constructor that takes a resource manager and a dictionary of keywords. diff --git a/src/dk.gov.oiosi/communication/Request.cs b/src/dk.gov.oiosi/communication/Request.cs index 94a9fb84710b7d85a1f04a45f117acd808bc44eb..97e540d73ad8b2c77b9c903c82339dbfb9c07c41 100644 --- a/src/dk.gov.oiosi/communication/Request.cs +++ b/src/dk.gov.oiosi/communication/Request.cs @@ -125,6 +125,7 @@ namespace dk.gov.oiosi.communication { if (string.IsNullOrEmpty(endpointConfigurationName)) { + //E-RSP31001 throw new NoEndpointGivenException(); } @@ -138,12 +139,14 @@ namespace dk.gov.oiosi.communication { if (endpointAddress == null) { + //E-RSP31001 throw new NoEndpointGivenException(); } // We only support 'http' and 'mailto' if (endpointAddress.Scheme != "mailto" && endpointAddress.Scheme != "http") { + //E-RSP31002 throw new NotSupportedSchemeException(endpointAddress.Scheme); } } @@ -181,6 +184,7 @@ namespace dk.gov.oiosi.communication default: { + //E-RSP31002 throw new NotSupportedSchemeException(this.requestUri.Scheme); } } @@ -198,6 +202,7 @@ namespace dk.gov.oiosi.communication catch (Exception e) { Debug.Fail("User the 'dk.gov.oiosi.communication.service.IServiceContract' contract instead of 'dk.gov.oiosi.communication.client.IClientProxyContract'."); + //E-RSP31003 throw new ProxyGenerationException(e); } } @@ -343,6 +348,7 @@ namespace dk.gov.oiosi.communication // Test that an inner channel was created if (proxy.InnerChannel == null) { + //E-RSP31004 throw new CreatingCommunicationChannelFailedException(); } } @@ -365,6 +371,7 @@ namespace dk.gov.oiosi.communication } catch (Exception ex) { + //E-RSP31005 throw new RequestShutdownException(ex); } } @@ -408,6 +415,7 @@ namespace dk.gov.oiosi.communication } catch (NullReferenceException e) { + //E-RSP31006 throw new MissingStackElementException("UbiquitousPropertiesBindingElement", e); } } @@ -566,10 +574,12 @@ namespace dk.gov.oiosi.communication // Time for blaming. Who's fault was it? if (e.Code.IsSenderFault) { + //E-RSP31007 return new FaultReturnedException(e, "dig"); } else { + //E-RSP31007 return new FaultReturnedException(e, "serveren"); } } diff --git a/src/dk.gov.oiosi/communication/TcpPort.cs b/src/dk.gov.oiosi/communication/TcpPort.cs index 8d0f37a02751faa8c6a08b1421afd4ed1dd4f06f..fc08d8004ae93bf67a5e4b4d01adca899454568d 100644 --- a/src/dk.gov.oiosi/communication/TcpPort.cs +++ b/src/dk.gov.oiosi/communication/TcpPort.cs @@ -58,8 +58,10 @@ namespace dk.gov.oiosi.communication { private void SetValue(int number) { if (number < 0) + //E-RSP31021 throw new InvalidTcpPortException(number); if (number > 65536) + //E-RSP31021 throw new InvalidTcpPortException(number); _number = number; } diff --git a/src/dk.gov.oiosi/communication/configuration/AmbiguousDocumentTypeResultException.cs b/src/dk.gov.oiosi/communication/configuration/AmbiguousDocumentTypeResultException.cs index 282f49a3b81556b2734ba3d08eeb3feeb78333f9..57a4977581c28aa2bc84432e897cf36c49c1ef41 100644 --- a/src/dk.gov.oiosi/communication/configuration/AmbiguousDocumentTypeResultException.cs +++ b/src/dk.gov.oiosi/communication/configuration/AmbiguousDocumentTypeResultException.cs @@ -54,6 +54,6 @@ namespace dk.gov.oiosi.communication.configuration { /// /// /// - public AmbiguousDocumentTypeResultException(ResourceManager errorMessages, Dictionary keywords) : base(errorMessages, keywords) { } + public AmbiguousDocumentTypeResultException(ResourceManager errorMessages, Dictionary keywords, string errorCode = "") : base(errorMessages, keywords, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/communication/configuration/DocumentTypeCollectionConfig.cs b/src/dk.gov.oiosi/communication/configuration/DocumentTypeCollectionConfig.cs index efa80a4c6c2316e77d044737efc6a3c55aba8196..2d643513f74042a6c67190cc91ccccf42804d5a9 100644 --- a/src/dk.gov.oiosi/communication/configuration/DocumentTypeCollectionConfig.cs +++ b/src/dk.gov.oiosi/communication/configuration/DocumentTypeCollectionConfig.cs @@ -64,7 +64,7 @@ namespace dk.gov.oiosi.communication.configuration public void AddDocumentType(DocumentTypeConfig documentType) { if (documentType == null) - throw new NullArgumentException("documentType"); + throw new NullArgumentException("E-RSP31101: 'documentType' is null"); if (ContainsDocumentTypeByValue(documentType)) throw new DocumentAllreadyAddedException(documentType.FriendlyName); _documentTypes.Add(documentType); @@ -77,7 +77,7 @@ namespace dk.gov.oiosi.communication.configuration public void RemoveDocumentType(DocumentTypeConfig documentType) { if (documentType == null) - throw new NullArgumentException("documentType"); + throw new NullArgumentException("E-RSP31101: 'documentType' is null"); _documentTypes.Remove(documentType); } @@ -143,9 +143,9 @@ namespace dk.gov.oiosi.communication.configuration /// public DocumentTypeConfig GetDocumentType(string rootName, string rootNamespace, XpathDiscriminatorConfigCollection identifierDiscriminators) { - if (rootName == null) throw new ArgumentNullException("rootName"); - if (rootNamespace == null) throw new ArgumentNullException("rootNamespace"); - if (identifierDiscriminators == null) throw new ArgumentNullException("identifierDiscriminators"); + if (rootName == null) throw new ArgumentNullException("E-RSP31102: 'rootName' is null"); + if (rootNamespace == null) throw new ArgumentNullException("E-RSP31103: 'rootNamespace' is null"); + if (identifierDiscriminators == null) throw new ArgumentNullException("E-RSP31104: 'identifierDiscriminators' is null"); DocumentTypeConfig documentType = null; if (!TryGetDocumentType(rootName, rootNamespace, identifierDiscriminators, out documentType)) @@ -164,7 +164,11 @@ namespace dk.gov.oiosi.communication.configuration { DocumentTypeConfig documentType = null; if (!TryGetDocumentType(guid, out documentType)) + { + //E-RSP31105 throw new NoDocumentTypeFoundFromIdException(guid); + } + return documentType; } @@ -189,9 +193,9 @@ namespace dk.gov.oiosi.communication.configuration /// public bool TryGetDocumentType(string rootName, string rootNamespace, XpathDiscriminatorConfigCollection identifierDiscriminators, out DocumentTypeConfig documentType) { - if (rootName == null) throw new ArgumentNullException("rootName"); - if (rootNamespace == null) throw new ArgumentNullException("rootNamespace"); - if (identifierDiscriminators == null) throw new ArgumentNullException("identifierDiscriminators"); + if (rootName == null) throw new ArgumentNullException("E-RSP31102: 'rootName' is null"); + if (rootNamespace == null) throw new ArgumentNullException("E-RSP31103: 'rootNamespace' is null"); + if (identifierDiscriminators == null) throw new ArgumentNullException("E-RSP31104: 'identifierDiscriminators' is null"); documentType = null; Predicate match = delegate(DocumentTypeConfig current) @@ -201,8 +205,15 @@ namespace dk.gov.oiosi.communication.configuration return identifierDiscriminators.Equals(current.IdentifierDiscriminators); }; List documentTypes = _documentTypes.FindAll(match); - if (documentTypes.Count < 1) return false; - if (documentTypes.Count > 1) throw new AmbiguousDocumentTypeResultFromParametersException(rootName, rootNamespace, identifierDiscriminators); + if (documentTypes.Count < 1) + { + return false; + } + if (documentTypes.Count > 1) + { + //E-RSP31106 + throw new AmbiguousDocumentTypeResultFromParametersException(rootName, rootNamespace, identifierDiscriminators); + } documentType = documentTypes[0]; return true; } @@ -221,8 +232,16 @@ namespace dk.gov.oiosi.communication.configuration return id == current.Id; }; List documentTypes = _documentTypes.FindAll(match); - if (documentTypes.Count < 1) return false; - if (documentTypes.Count > 1) throw new AmbiguousDocumentTypeResultFromIdException(id); + if (documentTypes.Count < 1) + { + return false; + } + + if (documentTypes.Count > 1) + { + //E-RSP31107 + throw new AmbiguousDocumentTypeResultFromIdException(id); + } documentType = documentTypes[0]; return true; } diff --git a/src/dk.gov.oiosi/communication/configuration/DocumentTypeConfig.cs b/src/dk.gov.oiosi/communication/configuration/DocumentTypeConfig.cs index 5abe9494ab37936fd2dfa631a6ea97e5f16502f4..3db29ab7d4f40c4d8d87fb29ffaf7c4524337ebc 100644 --- a/src/dk.gov.oiosi/communication/configuration/DocumentTypeConfig.cs +++ b/src/dk.gov.oiosi/communication/configuration/DocumentTypeConfig.cs @@ -82,9 +82,9 @@ namespace dk.gov.oiosi.communication.configuration XpathDiscriminatorConfigCollection identifierDiscriminators ) { - if (rootName == null) throw new NullArgumentException("rootName"); - if (rootNamespace == null) throw new NullArgumentException("rootNamespace"); - if (identifierDiscriminators == null) throw new NullArgumentException("identifierDiscriminators"); + if (rootName == null) throw new NullArgumentException("E-RSP31111: 'rootName' is null"); + if (rootNamespace == null) throw new NullArgumentException("E-RSP31112: 'rootNamespace' is null"); + if (identifierDiscriminators == null) throw new NullArgumentException("E-RSP31113: 'identifierDiscriminators' is null"); this._id = Guid.NewGuid(); _rootName = rootName; _rootNamespace = rootNamespace; @@ -104,9 +104,9 @@ namespace dk.gov.oiosi.communication.configuration XpathDiscriminatorConfigCollection identifierDiscriminators ) { - if (rootName == null) throw new NullArgumentException("rootName"); - if (rootNamespace == null) throw new NullArgumentException("rootNamespace"); - if (identifierDiscriminators == null) throw new NullArgumentException("identifierDiscriminators"); + if (rootName == null) throw new NullArgumentException("E-RSP31111: 'rootName' is null"); + if (rootNamespace == null) throw new NullArgumentException("E-RSP31112: 'rootNamespace' is null"); + if (identifierDiscriminators == null) throw new NullArgumentException("E-RSP31113: 'identifierDiscriminators' is null"); this._id = id; _rootName = rootName; _rootNamespace = rootNamespace; @@ -146,13 +146,13 @@ namespace dk.gov.oiosi.communication.configuration ) : this(id, rootName, rootNamespace, identifierDiscriminators) { - if (friendlyName == null) throw new NullArgumentException("friendlyName"); - if (schemaPath == null) throw new NullArgumentException("schemaPath"); - if (stylesheetPath == null) throw new NullArgumentException("stylesheetPath"); - if (serviceContractTModel == null) throw new NullArgumentException("serviceContractTModel"); - if (xsltTransformStylesheetPath == null) throw new NullArgumentException("xsltTransformStylesheetPath"); - if (endpointType == null) throw new NullArgumentException("endpointType"); - if (schematronValidationConfigCollection == null) throw new NullArgumentException("schematronValidationConfigs"); + if (friendlyName == null) throw new NullArgumentException("E-RSP31114: 'friendlyName' is null"); + if (schemaPath == null) throw new NullArgumentException("E-RSP31115: 'schemaPath' is null"); + if (stylesheetPath == null) throw new NullArgumentException("E-RSP31116: 'stylesheetPath' is null"); + if (serviceContractTModel == null) throw new NullArgumentException("E-RSP31117: 'serviceContractTModel' is null"); + if (xsltTransformStylesheetPath == null) throw new NullArgumentException("E-RSP31118: 'xsltTransformStylesheetPath' is null"); + if (endpointType == null) throw new NullArgumentException("E-RSP31119: 'endpointType' is null"); + if (schematronValidationConfigCollection == null) throw new NullArgumentException("E-RSP31120: 'schematronValidationConfigs' is null"); _friendlyName = friendlyName; _schemaPath = schemaPath; @@ -438,7 +438,7 @@ namespace dk.gov.oiosi.communication.configuration get { return this._schematronValidationConfigCollection.ToArray(); } set { - if (value == null) throw new NullArgumentException("value"); + if (value == null) throw new NullArgumentException("E-RSP31121: 'value' is null"); _schematronValidationConfigCollection = new List(value); } } @@ -462,7 +462,7 @@ namespace dk.gov.oiosi.communication.configuration get { return _profileIdXPath; } set { - if (value == null) throw new NullArgumentException("ProfileIdXPath value"); + if (value == null) throw new NullArgumentException("E-RSP31122: 'ProfileIdXPath' cannot not be set to null"); _profileIdXPath = value; } } @@ -476,7 +476,7 @@ namespace dk.gov.oiosi.communication.configuration get { return _documentIdXPath; } set { - if (value == null) throw new NullArgumentException("_documentIdXPath value"); + if (value == null) throw new NullArgumentException("E-RSP31123: 'DocumentIdXPath' cannot not be set to null"); _documentIdXPath = value; } } @@ -507,7 +507,7 @@ namespace dk.gov.oiosi.communication.configuration /// Returns true if name and namespace of the root element matches public bool IsDocumentOfType(XmlDocument document) { - if (document == null) throw new NullArgumentException("document"); + if (document == null) throw new NullArgumentException("E-RSP31124: 'document' is null"); XmlElement root = document.DocumentElement; if (root.LocalName != RootName) return false; if (root.NamespaceURI != RootNamespace) return false; diff --git a/src/dk.gov.oiosi/communication/configuration/KeyTypeMappingExpression.cs b/src/dk.gov.oiosi/communication/configuration/KeyTypeMappingExpression.cs index 9f3c4dcb1e60a5566c8881a017e6eacedab0b35a..0e247b1fc100bf8269cce8c764700a5a457ce379 100644 --- a/src/dk.gov.oiosi/communication/configuration/KeyTypeMappingExpression.cs +++ b/src/dk.gov.oiosi/communication/configuration/KeyTypeMappingExpression.cs @@ -131,6 +131,7 @@ namespace dk.gov.oiosi.communication.configuration { } catch (Exception ex) { + //E-RSP31131 throw new KeyTypeMappingFailedException(value, ex); } diff --git a/src/dk.gov.oiosi/communication/configuration/NoDocumentTypeFoundException.cs b/src/dk.gov.oiosi/communication/configuration/NoDocumentTypeFoundException.cs index f036ff55afb6ce15c06b99e61bfc6a33e1ef5d92..7c2b622f49a43a60940943ce3995c12512170528 100644 --- a/src/dk.gov.oiosi/communication/configuration/NoDocumentTypeFoundException.cs +++ b/src/dk.gov.oiosi/communication/configuration/NoDocumentTypeFoundException.cs @@ -62,6 +62,6 @@ namespace dk.gov.oiosi.communication.configuration { /// /// /// - public NoDocumentTypeFoundException(ResourceManager errorMessages, Dictionary keywords) : base(errorMessages, keywords) { } + public NoDocumentTypeFoundException(ResourceManager errorMessages, Dictionary keywords, string errorCode = "") : base(errorMessages, keywords, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/communication/configuration/ProfileMappingCollectionConfig.cs b/src/dk.gov.oiosi/communication/configuration/ProfileMappingCollectionConfig.cs index 5d0a5e0960909893199cb44ab17b7bc723ee0e90..c386dd1e40f0df7e16fab8e54d082624023c2f6b 100644 --- a/src/dk.gov.oiosi/communication/configuration/ProfileMappingCollectionConfig.cs +++ b/src/dk.gov.oiosi/communication/configuration/ProfileMappingCollectionConfig.cs @@ -63,8 +63,9 @@ namespace dk.gov.oiosi.communication.configuration { /// documenttype to add public void AddProfileMapping(ProfileMapping profileMapping) { if (profileMapping == null) - throw new NullArgumentException("profileMapping"); + throw new NullArgumentException("E-RSP31141: 'profileMapping' is null"); if (ContainsProfileMappingByName(profileMapping.Name)) + //E-RSP31142 throw new DocumentAllreadyAddedException(profileMapping.Name); _profileMappings.Add(profileMapping); } diff --git a/src/dk.gov.oiosi/communication/fault/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/communication/fault/ErrorMessages.Designer.cs index 320d32e483f4550d2bb4f8d47848fe065ecff214..f819ba6ab584b59e9f60ebfc485866c17dc79590 100644 --- a/src/dk.gov.oiosi/communication/fault/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/communication/fault/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.communication.fault { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { @@ -61,7 +61,7 @@ namespace dk.gov.oiosi.communication.fault { } /// - /// Looks up a localized string similar to SOAP fault koden "[faultcode]" understøttes ikke.. + /// Looks up a localized string similar to E-RSP31201: SOAP fault koden "[faultcode]" understøttes ikke.. /// internal static string dk_gov_oiosi_communication_fault_OiosiMessageFaultUnexpectedFaultCode { get { diff --git a/src/dk.gov.oiosi/communication/fault/ErrorMessages.resx b/src/dk.gov.oiosi/communication/fault/ErrorMessages.resx index 0658eba6d58fa611beb9bacd40aa623cf110c58f..cf1e78e207a053b24999bc98e254bad7f9fe6532 100644 --- a/src/dk.gov.oiosi/communication/fault/ErrorMessages.resx +++ b/src/dk.gov.oiosi/communication/fault/ErrorMessages.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - SOAP fault koden "[faultcode]" understøttes ikke. + E-RSP31201: SOAP fault koden "[faultcode]" understøttes ikke. Den indre SOAP fault kode "[innerfaultcode]" er ikke understøttet som modtager fejlkode. diff --git a/src/dk.gov.oiosi/communication/fault/OiosiMessageFault.cs b/src/dk.gov.oiosi/communication/fault/OiosiMessageFault.cs index 746bb6028d8c7d527b5def1b541b03cf32ab88f7..773831b1bc3097c1575c2945df3cb3a75261a2cb 100644 --- a/src/dk.gov.oiosi/communication/fault/OiosiMessageFault.cs +++ b/src/dk.gov.oiosi/communication/fault/OiosiMessageFault.cs @@ -105,6 +105,7 @@ namespace dk.gov.oiosi.communication.fault { FaultCode recieverInnerFaultCode = CreateRecieverFaultCode(innerFaultCode); return FaultCode.CreateReceiverFaultCode(recieverInnerFaultCode); default: + //E-RSP31201 throw new OiosiMessageFaultUnexpectedFaultCode(faultCode); } } diff --git a/src/dk.gov.oiosi/communication/listener/Listener.cs b/src/dk.gov.oiosi/communication/listener/Listener.cs index d0361ec684fdf18b842e41d42467845f62fb66dd..711199111771f749a5f397a8f7990f04b44301bc 100644 --- a/src/dk.gov.oiosi/communication/listener/Listener.cs +++ b/src/dk.gov.oiosi/communication/listener/Listener.cs @@ -95,10 +95,10 @@ namespace dk.gov.oiosi.communication.listener { protected static void AddHost(Listener listener, ServiceHostBase host) { // 1. Check for null if (listener == null) { - throw new NullArgumentException("listener"); + throw new NullArgumentException("E-RSP31301: 'listener' is null"); } if (host == null) { - throw new NullArgumentException("host"); + throw new NullArgumentException("E-RSP31302: 'host' is null"); } // 2. Register host / listener pair: @@ -113,7 +113,7 @@ namespace dk.gov.oiosi.communication.listener { /// The ServiceHost to remove from the list protected static void RemoveHost(ServiceHostBase host) { if (host == null) { - throw new ArgumentNullException("host"); + throw new ArgumentNullException("E-RSP31302: 'host' is null"); } lock (pHostList) { pHostList.Remove(host); @@ -133,18 +133,27 @@ namespace dk.gov.oiosi.communication.listener { // 1. Find the relevant Listener object ServiceHostBase currentServiceHost = OperationContext.Current.Host; if (currentServiceHost == null) - throw new CurrentServiceHostSearchFailedException(); + { + //E-RSP31303 + throw new CurrentServiceHostSearchFailedException(); + } + Listener listener = null; lock (pHostList) { try { listener = pHostList[currentServiceHost]; } catch (KeyNotFoundException) { + throw new Exception("E-RSP31304: The listener was not found in host dictionary"); // The listener was not found! } if (listener == null) + { + //E-RSP31305 throw new WcfListenerSearchFailedException(currentServiceHost); + } + } // 3. Invoke the event @@ -173,7 +182,7 @@ namespace dk.gov.oiosi.communication.listener { /// A listener identity, defining this listener public Listener (ListenerIdentity listenerIdentity) { this.pListenerIdentity = listenerIdentity; - + //E-RSP31306 pExceptionThrownHandler = new AsyncExceptionThrownHandler(EmailTransportExceptionEvent_ExceptionThrown); if (listenerIdentity.ServiceType != null) @@ -186,6 +195,7 @@ namespace dk.gov.oiosi.communication.listener { /// Default constructor /// public Listener() { + //E-RSP31306 pExceptionThrownHandler = new AsyncExceptionThrownHandler(EmailTransportExceptionEvent_ExceptionThrown); CreateHost(typeof(ServiceImplementation)); } @@ -216,10 +226,18 @@ namespace dk.gov.oiosi.communication.listener { // Also make sure that it is a mail endpoint int numberOfEndpoints = pServiceHost.Description.Endpoints.Count; if (numberOfEndpoints != 1) + { + //E-RSP31307 throw new NoUniqueEndpointException(typeOfService); + } + // We only support mail services if(pServiceHost.Description.Endpoints[0].Address.Uri.Scheme != "mailto") + { + //E-RSP31308 throw new EndpointTypeNotSupportedException(pServiceHost.Description.Endpoints[0].Address.Uri.Scheme); + } + // Adds the behavior that will encrypt the bodies of WS-RM messages pServiceHost.Description.Behaviors.Add(new EncryptRmBodiesBehavior()); @@ -266,6 +284,7 @@ namespace dk.gov.oiosi.communication.listener { } catch (Exception ex) { RemoveHost(pServiceHost); + //E-RSP31309 throw new StartListeningFailedException(pServiceHost, ex); } @@ -284,6 +303,7 @@ namespace dk.gov.oiosi.communication.listener { pServiceHost.Close(); } catch (Exception ex) { + //E-RSP31310 throw new StopListeningFailedException(pServiceHost, ex); } finally { @@ -357,35 +377,35 @@ namespace dk.gov.oiosi.communication.listener { switch(State){ case ListenerState.uninitialized: if (!(newState == ListenerState.initializing || newState == ListenerState.faulted)) - throw new Exception("Invalid state change. Uninitialized->" + newState.ToString()); + throw new Exception("E-RSP31311: Invalid state change. Uninitialized->" + newState.ToString()); break; case ListenerState.initializing: if (!(newState == ListenerState.initialized || newState == ListenerState.faulted)) - throw new Exception("Invalid state change. Initializing->" + newState.ToString()); + throw new Exception("E-RSP31312: Invalid state change. Initializing->" + newState.ToString()); break; case ListenerState.initialized: if (!(newState == ListenerState.starting || newState == ListenerState.faulted)) - throw new Exception("Invalid state change. Initialized->" + newState.ToString()); + throw new Exception("E-RSP31313: Invalid state change. Initialized->" + newState.ToString()); break; case ListenerState.starting: if (!(newState == ListenerState.started || newState == ListenerState.stopping || newState == ListenerState.faulted)) - throw new Exception("Invalid state change. Starting->" + newState.ToString()); + throw new Exception("E-RSP31314: Invalid state change. Starting->" + newState.ToString()); break; case ListenerState.started: if (!(newState == ListenerState.stopping || newState == ListenerState.faulted || newState == ListenerState.starting)) - throw new Exception("Invalid state change. Started->" + newState.ToString()); + throw new Exception("E-RSP31315: Invalid state change. Started->" + newState.ToString()); break; case ListenerState.stopping: if (!(newState == ListenerState.stopped || newState == ListenerState.faulted)) - throw new Exception("Invalid state change. Stopping->" + newState.ToString()); + throw new Exception("E-RSP31316: Invalid state change. Stopping->" + newState.ToString()); break; case ListenerState.stopped: if (!(newState == ListenerState.faulted)) - throw new Exception("Invalid state change. Stopped->" + newState.ToString()); + throw new Exception("E-RSP31317: Invalid state change. Stopped->" + newState.ToString()); break; default: - throw new Exception("Invalid state change"); + throw new Exception("E-RSP31318: Invalid state change"); } // Raise event diff --git a/src/dk.gov.oiosi/communication/listener/ListenerRequest.cs b/src/dk.gov.oiosi/communication/listener/ListenerRequest.cs index 0247a260d1af65bfd75571a1ce3dbf86f437cabb..1f69c105bad38222ea35efd0226d0ab01021e42e 100644 --- a/src/dk.gov.oiosi/communication/listener/ListenerRequest.cs +++ b/src/dk.gov.oiosi/communication/listener/ListenerRequest.cs @@ -119,7 +119,7 @@ namespace dk.gov.oiosi.communication.listener { return messageIdentifierValue; } catch (Exception ex) { - throw new Exception("Failed to get message identification", ex); + throw new Exception("E-RSP31321: Failed to get message identification", ex); } } } diff --git a/src/dk.gov.oiosi/configuration/CacheFactory.cs b/src/dk.gov.oiosi/configuration/CacheFactory.cs index d1d3518288a9887d52e47bcca356bbca5d368337..10df39d4254346fa3bb216a5b7c30bf566a17a93 100644 --- a/src/dk.gov.oiosi/configuration/CacheFactory.cs +++ b/src/dk.gov.oiosi/configuration/CacheFactory.cs @@ -131,7 +131,7 @@ namespace dk.gov.oiosi.configuration if (string.IsNullOrEmpty(element.ImplementationNamespaceClass)) { - throw new NotImplementedException("The Assembly and NamespaceClass for the cache '" + name + "' is not defined correct."); + throw new NotImplementedException("E-RSP11001: The Assembly and NamespaceClass for the cache '" + name + "' is not defined correct."); } StringBuilder builder = new StringBuilder(); @@ -148,8 +148,9 @@ namespace dk.gov.oiosi.configuration if (cacheType == null) { - this.logger.Warn("Cache type not valid. The cache type with qualifiedTypename '" + qualifiedTypename + "' is null."); - throw new FailedToLoadLookupTypeException(qualifiedTypename); + this.logger.Warn("W-RSP11006 : Cache type not valid. The cache type with qualifiedTypename '" + qualifiedTypename + "' is null."); + //E-RSP11002 + throw new FailedToLoadLookupTypeException(qualifiedTypename, "E-RSP11002"); } // Add the cacheName to the cache, if the name does not already exist @@ -178,7 +179,7 @@ namespace dk.gov.oiosi.configuration ConstructorInfo constructorInfo = cacheType.GetConstructor(parameterArray); if (constructorInfo == null) { - throw new Exception("Cache implementation must contain a construtore, that takes a IDictionary as parameter."); + throw new Exception("E-RSP11003: Cache implementation must contain a constructor, that takes a IDictionary as parameter."); } cache = (T)constructorInfo.Invoke(objectArray); diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementNotInStackException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementNotInStackException.cs index 3fe68fbc78cf928a4815006fee02b23b984e6a1c..e9d3b4a6e329da6f36d45e156175fb6f3f919f6a 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementNotInStackException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementNotInStackException.cs @@ -44,9 +44,10 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { /// error message. /// /// - public BindingElementNotInStackException(Type[] expectedBindingElementTypes) : base(GetKeyword(expectedBindingElementTypes)) { } + public BindingElementNotInStackException(Type[] expectedBindingElementTypes, string errorCode = "") : base(GetKeyword(expectedBindingElementTypes), errorCode) { } - private static Dictionary GetKeyword(Type[] expectedBindingElementTypes) { + private static Dictionary GetKeyword(Type[] expectedBindingElementTypes) + { Dictionary keywords = new Dictionary(); StringBuilder expectedStringBuilder = new StringBuilder(); diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementOrderChecker.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementOrderChecker.cs index 09743f854c6babae7ced3834be82a4c2c12da2be..3a93a1a9f002460ad5b95df93ea84a6ba19e2c8a 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementOrderChecker.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementOrderChecker.cs @@ -89,9 +89,11 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } for (int i = 0; i < foundOrder.Length; i++) { if (foundOrder[i] == 0) - throw new BindingElementNotInStackException(_bindingOrder[i]); + //E-RSP21001 + throw new BindingElementNotInStackException(_bindingOrder[i], "E-RSP21001"); if (i == 0) continue; if (foundOrder[i - 1] > foundOrder[i]) + //E-RSP21002 throw new BindingElementOrderMismatchException(_bindingOrder[i - 1], _bindingOrder[i]); } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementStackVerifier.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementStackVerifier.cs index b240f858272a1325aae86a7fbd9960d936ba98ba..e48cb6402f7df8a7e06360bf7d5472d7e3343a4e 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementStackVerifier.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/BindingElementStackVerifier.cs @@ -87,7 +87,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { unverifiedBindingElements.RemoveAll(predicate); } if (unverifiedBindingElements.Count > 0) - throw new BindingElementNotInStackException(unverifiedBindingElements[0]); + //E-RSP21011 + throw new BindingElementNotInStackException(unverifiedBindingElements[0], "E-RSP21011"); } } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelBase.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelBase.cs index 1292d8c2c78846c1f17fa711aa4b4d06c3258bb9..f9ba8faea3da08f55ba19931ab73f9b293e977ad 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelBase.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelBase.cs @@ -56,7 +56,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { { if (innerChannel == null) { - throw new NullArgumentException("innerChannel"); + throw new NullArgumentException("E-RSP21101: 'innerChannel' is null"); } this.innerChannel = innerChannel; diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelException.cs index e24a58206ccd630ada2fd7210679fb5aae73b9e2..db14faa40d30644fb856f42853aa34573bd9f3b1 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelException.cs @@ -63,7 +63,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { /// Constructor /// /// The inner exception - public InterceptorChannelException(Exception innerException) : base(innerException) { + public InterceptorChannelException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { pFaultCode = OiosiFaultCode.Receiver; pInnerFaultCode = OiosiInnerFaultCode.InternalSystemFailureFault; } @@ -85,8 +85,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { /// /// /// The message - public InterceptorChannelException(OiosiFaultCode faultCode, OiosiInnerFaultCode innerFaultCode, string message) - : base(message) + public InterceptorChannelException(OiosiFaultCode faultCode, OiosiInnerFaultCode innerFaultCode, string message, string errorCode = "") + : base(message, errorCode) { pFaultCode = faultCode; pInnerFaultCode = innerFaultCode; @@ -98,8 +98,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { /// rasp message fault code /// rasp message innerfault code /// keywords for the message - public InterceptorChannelException(OiosiFaultCode faultCode, OiosiInnerFaultCode innerFaultCode, System.Collections.Generic.Dictionary keywords) - : base(keywords) { + public InterceptorChannelException(OiosiFaultCode faultCode, OiosiInnerFaultCode innerFaultCode, System.Collections.Generic.Dictionary keywords, string errorCode = "") + : base(keywords, errorCode) { pFaultCode = faultCode; pInnerFaultCode = innerFaultCode; } @@ -110,8 +110,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { /// rasp message fault code /// rasp message innerfault code /// innerexception of the thrown exception - public InterceptorChannelException(OiosiFaultCode faultCode, OiosiInnerFaultCode innerFaultCode, System.Exception innerException) - : base(innerException) { + public InterceptorChannelException(OiosiFaultCode faultCode, OiosiInnerFaultCode innerFaultCode, System.Exception innerException, string errorCode = "") + : base(innerException, errorCode) { pFaultCode = faultCode; pInnerFaultCode = innerFaultCode; } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelFactory.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelFactory.cs index 1c310578f58c037c711ebb737232a255caecf2f2..ebe28178ffd18b03552b7fc63e3b3b50a88e90f2 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelFactory.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelFactory.cs @@ -83,7 +83,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { return (TChannel)(IChannel)new InterceptorRequestChannel(this, (IRequestChannel)innerChannel, _channelInterceptor); if (typeof(TChannel) == typeof(IRequestSessionChannel)) return (TChannel)(IChannel)new InterceptorRequestSessionChannel(this, (IRequestSessionChannel)innerChannel, _channelInterceptor); - throw new UnsupportedChannelTypeException(typeof(TChannel)); + //E-RSP21111 + throw new UnsupportedChannelTypeException(typeof(TChannel), "E-RSP21111"); } /// diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelListener.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelListener.cs index 60caa41dfa43c454d3534681040113ea37f2d6a2..34077b3a80e253b9c023692e33201c462e5abba3 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelListener.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelListener.cs @@ -239,7 +239,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { } else { - throw new UnsupportedChannelTypeException(typeof(TChannel)); + //E-RSP21121 + throw new UnsupportedChannelTypeException(typeof(TChannel), "E-RSP21121"); } return channel; diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelWrapperException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelWrapperException.cs index 226cd96c8c7cdd9489b6e9e80e3d339f8b561887..f7ed90d0b6bffba6f7f1ce148345d007c46726a1 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelWrapperException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorChannelWrapperException.cs @@ -13,8 +13,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels /// Constructor /// /// The inner exception - public InterceptorChannelWrapperException(OiosiFaultCode oiosiFaultCode, OiosiInnerFaultCode oiosiInnerFaultCode, Exception innerException) - : base(oiosiFaultCode, oiosiInnerFaultCode, CreatKeywords(innerException.Message)) + public InterceptorChannelWrapperException(OiosiFaultCode oiosiFaultCode, OiosiInnerFaultCode oiosiInnerFaultCode, Exception innerException, string errorCode = "") + : base(oiosiFaultCode, oiosiInnerFaultCode, CreatKeywords(innerException.Message), errorCode) { } /// @@ -23,8 +23,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels /// /// /// The message - public InterceptorChannelWrapperException(OiosiFaultCode oiosiFaultCode, OiosiInnerFaultCode oiosiInnerFaultCode, string message) - : base(oiosiFaultCode, oiosiInnerFaultCode, CreatKeywords(message)) + public InterceptorChannelWrapperException(OiosiFaultCode oiosiFaultCode, OiosiInnerFaultCode oiosiInnerFaultCode, string message, string errorCode = "") + : base(oiosiFaultCode, oiosiInnerFaultCode, CreatKeywords(message), errorCode) { } private static Dictionary CreatKeywords(string message) diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorMessage.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorMessage.cs index cf54b5a0c9089524d2f1798fab8571ceeea8fcab..e1885b505f9fe7900648a9d16193ddabadd68d91 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorMessage.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorMessage.cs @@ -105,7 +105,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels } else { - throw new NotSupportedException("SecurityToken must be of type X509Certificate2"); + + throw new NotSupportedException("E-RSP21131: SecurityToken must be of type X509Certificate2"); } return x509Certificate2; diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorReplyChannel.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorReplyChannel.cs index 96e34dd15b87900d61e2ba3ecabd5dcc8dd64d7e..8ef9253da709e60a2d20ee68a50fd4d4eba6f13b 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorReplyChannel.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorReplyChannel.cs @@ -199,14 +199,14 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { } catch (Exception ex) { - this.logger.Error(ex.ToString()); + this.logger.Error("E-RSP21141: " + ex.ToString()); try { channel.Close(); } catch (Exception exception) { - this.logger.Fatal(exception.ToString()); + this.logger.Fatal("F-RSP21142: " + exception.ToString()); } context = null; diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorRequestChannel.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorRequestChannel.cs index 747e1d45c72540c10a99c0b46db4af1f243b22ff..0cd464410524da60dfde33c778339ea46d8bc1c7 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorRequestChannel.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/InterceptorRequestChannel.cs @@ -203,7 +203,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { { // Exception, if the service e.g. does not have acces to the private key in the certificate // So logging this special error - this.logger.Fatal("The service migth not have permission right to the private key in the certificate", exception); + this.logger.Fatal("F-RSP21151: The service migth not have permission right to the private key in the certificate", exception); // handling the error as normal HandleException(message); diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/UnsupportedChannelTypeException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/UnsupportedChannelTypeException.cs index bd196e26b339c6eef90490ba237ce9536c016358..979acfe02e6a01d2b43245b4e99a611c4f21e718 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/UnsupportedChannelTypeException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/UnsupportedChannelTypeException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Channels { /// UnsupportedChannelTypeException constructor /// /// - public UnsupportedChannelTypeException(Type type) : base(KeywordFromString.GetKeyword("ChannelType", type.ToString())) { } + public UnsupportedChannelTypeException(Type type, string errorCode = "") : base(KeywordFromString.GetKeyword("ChannelType", type.ToString()), errorCode) { } } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.Designer.cs index c79956c0d993655ec42e4673f3190899e19d77b3..d845c3f0c03044ba7574f1ba3ec667c200c67072 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { @@ -70,7 +70,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to BindingElement rækkefølge fejl. Elementet "[before]" skal være før "[current]".. + /// Looks up a localized string similar to E-RSP21002: BindingElement rækkefølge fejl. Elementet "[before]" skal være før "[current]".. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_BindingElementOrderMismatchException { get { @@ -108,7 +108,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to Kanaltypen "[type]" i protokolstakken er ikke understøttet.. + /// Looks up a localized string similar to E-RSP21111: Kanaltypen "[type]" i protokolstakken er ikke understøttet.. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Channels_UnsupportedChannelTypeException { get { @@ -126,7 +126,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to Der skete en intern fejl ved autorisationen.. + /// Looks up a localized string similar to E-RSP21212: Der skete en intern fejl ved autorisationen.. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Security_authorisation_AuthorisationProcessFailedException { get { @@ -136,7 +136,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to Der er ikke adgang til serveren med klientcertifikat med navn "[certificatefriendlyname]" og subject "[certificatesubject]" samt dokumenttypen "[documenttypefriendlyname]". . + /// Looks up a localized string similar to E-RSP21211: Der er ikke adgang til serveren med klientcertifikat med navn "[certificatefriendlyname]" og subject "[certificatesubject]" samt dokumenttypen "[documenttypefriendlyname]".. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Security_authorisation_NotAuthorisedException { get { @@ -146,7 +146,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to Afsender certifikatet er trukket tilbage.. + /// Looks up a localized string similar to E-RSP21203: Afsender certifikatet er trukket tilbage.. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Security_CertificateRevokedException { get { @@ -155,7 +155,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to Certifikatet valideringen fejlede med fejlen: [error]. + /// Looks up a localized string similar to E-RSP21202: Certifikatet valideringen fejlede med fejlen: [error]. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Security_CertificateRevokedValidationFailedException { get { @@ -165,7 +165,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to Kunner ikke hente certifikatsubject ud af beskeden i protokolstakken (WCF) med følgende SOAP action "[messageaction]". + /// Looks up a localized string similar to Kunne ikke hente certifikatsubject ud af beskeden i protokolstakken (WCF) med følgende SOAP action "[messageaction]". /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Security_FailedToGetCertificateSubjectException { get { @@ -214,7 +214,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { } /// - /// Looks up a localized string similar to SOAP-meddelelsens body var tom ved schema validerings interceptoren, dvs der fandtes ingen meddelelse som kunne valideres. + /// Looks up a localized string similar to E-RSP21311: SOAP-meddelelsens body var tom ved schema validerings interceptoren, dvs der fandtes ingen meddelelse som kunne valideres. /// internal static string dk_gov_oiosi_extension_wcf_Interceptor_Validation_Schema_SchemaValidationInterceptionEmptyBodyException { get { diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.resx b/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.resx index cda9d1be15643c4243f5c70ed54c7d05ae8237fc..8e2b60d16758c11ef1f17fe813e04d36907c6d3f 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.resx +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/ErrorMessages.resx @@ -121,7 +121,7 @@ Kunne ikke finde BindingElement "[type]" i WCF stakken. - BindingElement rækkefølge fejl. Elementet "[before]" skal være før "[current]". + E-RSP21002: BindingElement rækkefølge fejl. Elementet "[before]" skal være før "[current]". Der skete en fejl i interceptoren. @@ -131,20 +131,20 @@ Der skete en intern fejl i serveren. - Kanaltypen "[type]" i protokolstakken er ikke understøttet. + E-RSP21111: Kanaltypen "[type]" i protokolstakken er ikke understøttet. Der er sket en generel interceptor fejl i protokolstakken. This message should never be shown. - Der skete en intern fejl ved autorisationen. + E-RSP21212: Der skete en intern fejl ved autorisationen. - Der er ikke adgang til serveren med klientcertifikat med navn "[certificatefriendlyname]" og subject "[certificatesubject]" samt dokumenttypen "[documenttypefriendlyname]". + E-RSP21211: Der er ikke adgang til serveren med klientcertifikat med navn "[certificatefriendlyname]" og subject "[certificatesubject]" samt dokumenttypen "[documenttypefriendlyname]". - Kunner ikke hente certifikatsubject ud af beskeden i protokolstakken (WCF) med følgende SOAP action "[messageaction]" + Kunne ikke hente certifikatsubject ud af beskeden i protokolstakken (WCF) med følgende SOAP action "[messageaction]" Søgningen efter tag'et "[tagname]" i security headeren gav intet resultat. @@ -159,7 +159,7 @@ Kunne ikke validere (XML Schema validere) dokumentet. - SOAP-meddelelsens body var tom ved schema validerings interceptoren, dvs der fandtes ingen meddelelse som kunne valideres + E-RSP21311: SOAP-meddelelsens body var tom ved schema validerings interceptoren, dvs der fandtes ingen meddelelse som kunne valideres Schematron valideringen forløb ikke succesfuldt. @@ -171,10 +171,10 @@ Kunne ikke XSLT-transformere meddelelsen (med henblik på grafisk visning). Dette kan betyde, at der er fejl i meddelelsens struktur ift XSLT stylesheetet, eller at dette er forkert konfigureret. - Certifikatet valideringen fejlede med fejlen: [error] + E-RSP21202: Certifikatet valideringen fejlede med fejlen: [error] - Afsender certifikatet er trukket tilbage. + E-RSP21203: Afsender certifikatet er trukket tilbage. [message] diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs index e373d75b8086f3307f965f16d473cd496a336f3f..9c864686ae77cb658d77f5bc1ac08ba08207def5 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs @@ -65,9 +65,9 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { /// a base constructor with the keywords and the resource manager. /// /// A dictionary that contains keywords that are used in building the exception message - public InterceptorException(System.Collections.Generic.Dictionary keywords) + public InterceptorException(System.Collections.Generic.Dictionary keywords, string errorCode = "") { - this.SetMessage(resourceManager, keywords); + this.SetMessage(resourceManager, keywords, errorCode); } /// @@ -76,10 +76,10 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { /// resource manager. /// /// The reasone of this exception - public InterceptorException(string message) + public InterceptorException(string message, string errorCode = "") : base(message) { - this.SetMessage(resourceManager); + this.SetMessage(resourceManager, new Dictionary(), errorCode); } /// @@ -88,10 +88,10 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { /// resource manager. /// /// The inner exception of this exception - public InterceptorException(System.Exception innerException) + public InterceptorException(System.Exception innerException, string errorCode = "") : base("", innerException) { - this.SetMessage(resourceManager); + this.SetMessage(resourceManager, new Dictionary(), errorCode); } /// @@ -101,16 +101,16 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { /// /// A dictionary that contains keywords that are used in building the exception message /// The inner exception of this exception - public InterceptorException(Dictionary keywords, System.Exception innerException) + public InterceptorException(Dictionary keywords, System.Exception innerException, string errorCode = "") : base("", innerException) { - this.SetMessage(resourceManager, keywords); + this.SetMessage(resourceManager, keywords, errorCode); } /// /// Property to get the error message /// - public override string Message + public override string Message { get { @@ -124,12 +124,16 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { this.SetMessage(resource, keywords); } - private void SetMessage(ResourceManager resource, Dictionary keywords) + private void SetMessage(ResourceManager resource, Dictionary keywords, string errorCode = "") { Type exceptionType = this.GetType(); List collectiveResources = new List(resources); collectiveResources.Add(resource); - _message = exceptionMessageStore.GetExceptionMessage(collectiveResources, exceptionType, keywords); + _message = + !string.IsNullOrEmpty(errorCode) ? + string.Format("{0}: {1}", errorCode, exceptionMessageStore.GetExceptionMessage(collectiveResources, exceptionType, keywords)) + : + exceptionMessageStore.GetExceptionMessage(collectiveResources, exceptionType, keywords); } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/FailedToGetCertificateSubjectException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/FailedToGetCertificateSubjectException.cs index b2d6e5b3cfce1423fd0e749aacbe0099e1b9ac12..522d9ba0527633f4f4cc30d45260aae5c2519006 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/FailedToGetCertificateSubjectException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/FailedToGetCertificateSubjectException.cs @@ -47,8 +47,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { /// subject. /// /// - public FailedToGetCertificateSubjectException(InterceptorMessage interceptorMessage) - : base(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, GetKeywords(interceptorMessage)) { } + public FailedToGetCertificateSubjectException(InterceptorMessage interceptorMessage, string errorCode = "") + : base(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, GetKeywords(interceptorMessage), errorCode) { } private static Dictionary GetKeywords(InterceptorMessage interceptorMessage) { Dictionary keywords = new Dictionary(); diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/Header.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/Header.cs index 3fe1a639f1533bdfcb6c5423cd25d7dce803c28c..ba0715f8d010b804d175230d44f30c4ea2d302f1 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/Header.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/Header.cs @@ -68,8 +68,17 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security.Header { elements++; } } - if (elements < 1) throw new NoElementsFoundException(tagName); - if (elements > 1) throw new ToManyElementsFoundException(tagName, elements); + if (elements < 1) + { + //E-RSP21221 + throw new NoElementsFoundException(tagName, "E-RSP21221"); + } + if (elements > 1) + { + //E-RSP21222 + throw new ToManyElementsFoundException(tagName, elements, "E-RSP21222"); + } + return value; } @@ -91,8 +100,16 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security.Header { elements++; } } - if (elements < 1) throw new NoElementsFoundException(tagName); - if (elements > 1) throw new ToManyElementsFoundException(tagName, elements); + if (elements < 1) + { + //E-RSP21221 + throw new NoElementsFoundException(tagName, "E-RSP21221"); + } + if (elements > 1) + { + //E-RSP21222 + throw new ToManyElementsFoundException(tagName, elements, "E-RSP21222"); + } return value; } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/NoElementsFoundException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/NoElementsFoundException.cs index d205a93ce80da880a27fc32527fda8602528b779..2bcdd1f5da0aff6065d8e9858cce67c7df974d29 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/NoElementsFoundException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/NoElementsFoundException.cs @@ -42,6 +42,6 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security.Header { /// NoElementsFoundException constructor /// /// - public NoElementsFoundException(string tagName) : base(KeywordFromString.GetKeyword("tagname", tagName)) { } + public NoElementsFoundException(string tagName, string errorCode = "") : base(KeywordFromString.GetKeyword("tagname", tagName), errorCode) { } } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/ToManyElementsFoundException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/ToManyElementsFoundException.cs index e4ff23d5d477358407ddd497b644c3e94b913d62..8353ec3ff9486d1d5629e344648e17e29fbe9d3a 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/ToManyElementsFoundException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/Header/ToManyElementsFoundException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security.Header { /// /// /// - public ToManyElementsFoundException(string tagName, int results) : base(GetKeywords(tagName, results)) { } + public ToManyElementsFoundException(string tagName, int results, string errorCode = "") : base(GetKeywords(tagName, results), errorCode) { } private static Dictionary GetKeywords(string tagName, int results) { Dictionary keywords = KeywordFromString.GetKeyword("tagname", tagName); diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs index 0e6ade1438b310a00d3f61f60694a028f9d02591..24f946a3e65e1c1c536fe1c8631b7a8af2280fe3 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs @@ -123,7 +123,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { } catch { - throw new FailedToGetCertificateSubjectException(interceptorMessage); + //E-RSP21201 + throw new FailedToGetCertificateSubjectException(interceptorMessage, "E-RSP21201"); } @@ -145,33 +146,39 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { msg = "unknown"; } - this.logger.Warn(string.Format("The certificate '{0}' revocation check failed. Reason is: ", ocesCertificate.Certificate.SubjectName.Name, msg)); + this.logger.Warn(string.Format("The certificate '{0}' revocation check failed. Reason is: {1}", ocesCertificate.Certificate.SubjectName.Name, msg)); // some error checking the certificate // make sure the error is of the correct type, and throw it // note - if the original exception was not a communikation exception, it is wraped in a communikation exception if (response.Exception is CertificateRevokedTimeoutException) { + //E-RSP21202 throw new CertificateRevokedValidationFailedException(response.Exception); } else if (response.Exception is CertificateRevokedException) { + //E-RSP21203 throw response.Exception; } else if (response.Exception is CertificateRevokedValidationFailedException) { + //E-RSP21202 throw response.Exception; } else if (response.Exception is CheckCertificateOcspUnexpectedException) { + //E-RSP21202 throw new CertificateRevokedValidationFailedException(response.Exception); } else if (response.Exception is CheckCertificateRevokedUnexpectedException) { + //E-RSP21202 throw new CertificateRevokedValidationFailedException(response.Exception); } else { + //E-RSP21202 throw new CertificateRevokedValidationFailedException(response.Exception); } } @@ -190,14 +197,16 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { } case RevocationCheckStatus.CertificateRevoked: { - this.logger.Warn(string.Format("The certificate '{0}' is revoked.", ocesCertificate.Certificate.SubjectName.Name)); + this.logger.Warn(string.Format("W-RSP21206: The certificate '{0}' is revoked.", ocesCertificate.Certificate.SubjectName.Name)); + //E-RSP21203 throw new CertificateRevokedException(); //break; } default: { - this.logger.Warn(string.Format("The certificate '{0}' failed in revocation check - reason unknown", ocesCertificate.Certificate.SubjectName.Name)); - throw new CertificateRevokedValidationFailedException("The certificate failed in revocation check - reason unknown."); + this.logger.Warn(string.Format("W-RSP21207: The certificate '{0}' failed in revocation check - reason unknown", ocesCertificate.Certificate.SubjectName.Name)); + // + throw new CertificateRevokedValidationFailedException("E-RSP21202: The certificate failed in revocation check - reason unknown."); //break; } } @@ -206,8 +215,10 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { } catch (FailedToGetCertificateSubjectException) { + //E-RSP21204 // exception is of the correct type - rethrowing it - throw; + + throw new FailedToGetCertificateSubjectException(interceptorMessage, "E-RSP21204"); } /* catch (CertificateRevokedTimeoutException e) { @@ -216,11 +227,13 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { }*/ catch (CertificateRevokedException) { + //E-RSP21203 // exception is of the correct type - rethrowing it throw; } catch (CertificateRevokedValidationFailedException) { + //E-RSP21202 // exception is of the correct type - rethrowing it throw; } @@ -238,6 +251,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { catch (Exception ex) { this.logger.Debug("Security validate the foces certificate", ex); + //E-RSP21202 throw new CertificateRevokedValidationFailedException(ex); } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/authorisation/ServerAuthorisationBindingElement.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/authorisation/ServerAuthorisationBindingElement.cs index d18d2cb5340f61b0dc64f12ce4533e6ccce5a30d..7a96506be99cd42a476f55e0d9fad2d2ddb5d251 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/authorisation/ServerAuthorisationBindingElement.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/authorisation/ServerAuthorisationBindingElement.cs @@ -51,10 +51,13 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security.authorisation { DocumentTypeConfig documentType = searcher.FindUniqueDocumentType(xmlDocument); bool authorised = _authoriser.Authorise(certificate, xmlDocument, documentType); if (!authorised) + //E-RSP21211 throw new NotAuthorisedException(certificate, xmlDocument, documentType); } catch (NotAuthorisedException) { + //E-RSP21211 throw; } catch (Exception ex) { + //E-RSP21212 throw new AuthorisationProcessFailedException(ex); } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Certificate/CertificateValidatorWithLookup.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Certificate/CertificateValidatorWithLookup.cs index fcba4b5ccb48fee0ff7b8712c3d6093195515dbf..43bb8fb7519adfb45ddf145ae6b6a36865475f42 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Certificate/CertificateValidatorWithLookup.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Certificate/CertificateValidatorWithLookup.cs @@ -96,8 +96,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate if (certificate == null) { - - throw new FailedToGetCertificateSubjectException(interceptorMessage); + //E-RSP21301 + throw new FailedToGetCertificateSubjectException(interceptorMessage, "E-RSP21301"); } //Check if the certificate is valid (Activated, and not expired, and from trusted root) @@ -108,67 +108,67 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate { if (certificate != null) { - this.logger.Warn(string.Format("Certificate '{0}' is expired.", certificate.SubjectName.Name)); + this.logger.Warn(string.Format("W-RSP21303: Certificate '{0}' is expired.", certificate.SubjectName.Name)); } else { - this.logger.Warn("Unknown certificate is expired."); + this.logger.Warn("W-RSP21304: Unknown certificate is expired."); } - throw new InterceptorChannelWrapperException(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, ex); + throw new InterceptorChannelWrapperException(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, ex, "E-RSP21302"); } catch (CertificateNotActiveException ex) { if (certificate != null) { - this.logger.Warn(string.Format("Certificate '{0}' is not activated.", certificate.SubjectName.Name)); + this.logger.Warn(string.Format("W-RSP21305: Certificate '{0}' is not activated.", certificate.SubjectName.Name)); } else { - this.logger.Warn("Unknown certificate is not activated."); + this.logger.Warn("W-RSP21306: Unknown certificate is not activated."); } - throw new InterceptorChannelWrapperException(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, ex); + throw new InterceptorChannelWrapperException(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, ex, "E-RSP21302"); } catch (CertificateRootNotTrustedException ex) { if (certificate != null) { - this.logger.Warn(string.Format("The root certificate for certificate '{0}' is not trusted.", certificate.SubjectName.Name)); + this.logger.Warn(string.Format("W-RSP21307: The root certificate for certificate '{0}' is not trusted.", certificate.SubjectName.Name)); } else { - this.logger.Warn("The root certificate for a unknown certificate is not trusted."); + this.logger.Warn("W-RSP21308: The root certificate for a unknown certificate is not trusted."); } - throw new InterceptorChannelWrapperException(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, ex); + throw new InterceptorChannelWrapperException(OiosiFaultCode.Sender, OiosiInnerFaultCode.SignatureNotValidFault, ex, "E-RSP21302"); } catch (FailedToGetCertificateSubjectException) { if (certificate != null) { - this.logger.Warn(string.Format("Subject for certificate '{0}' was not found.", certificate.SubjectName.Name)); + this.logger.Warn(string.Format("W-RSP21309: Subject for certificate '{0}' was not found.", certificate.SubjectName.Name)); } else { - this.logger.Warn("Subject for unknown certificate was not found."); + this.logger.Warn("W-RSP21310: Subject for unknown certificate was not found."); } - throw; + throw new FailedToGetCertificateSubjectException(interceptorMessage, "E-RSP21301"); } catch (Exception ex) { if (certificate != null) { - this.logger.Warn(string.Format("The certificate '{0}' was rejected.", certificate.SubjectName.Name)); + this.logger.Warn(string.Format("W-RSP21311: The certificate '{0}' was rejected.", certificate.SubjectName.Name)); } else { - this.logger.Warn("Unknown certificate was rejected."); + this.logger.Warn("W-RSP21312: Unknown certificate was rejected."); } this.logger.Debug("Security validate the foces certificate", ex); - throw new InterceptorChannelWrapperException(OiosiFaultCode.Receiver, OiosiInnerFaultCode.InternalSystemFailureFault, "The client certificate is invalid."); + throw new InterceptorChannelWrapperException(OiosiFaultCode.Receiver, OiosiInnerFaultCode.InternalSystemFailureFault, "The client certificate is invalid.", "E-RSP21302"); } this.logger.Trace("Security validate the foces certificate - Finish."); diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/FailedToLoadSchemaException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/FailedToLoadSchemaException.cs index 79f93a0b54d6bf54f73f9aae17ee7a7052b30f18..a3c1723cdf905c2edfad5ac5eb51052745cf9adb 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/FailedToLoadSchemaException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/FailedToLoadSchemaException.cs @@ -45,6 +45,6 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema { /// /// /// - public FailedToLoadSchemaException(FileInfo fileInfo, Exception innerException) : base(KeywordsFromFileInfo.GetKeywords(fileInfo), innerException) { } + public FailedToLoadSchemaException(FileInfo fileInfo, Exception innerException, string errorCode = "") : base(KeywordsFromFileInfo.GetKeywords(fileInfo), innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidateDocumentFailedException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidateDocumentFailedException.cs index 167cb66951417c8a2c3878254fbe56d3686c3f88..503b5e9883a70a54b26327d45eb86071135df65e 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidateDocumentFailedException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidateDocumentFailedException.cs @@ -49,8 +49,8 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema /// Constuctor with innerexception /// /// innerexception of the thrown exception - public SchemaValidateDocumentFailedException(System.Exception innerException) - : base(GetFaultCode(innerException), GetInnerFaultCode(innerException), innerException) { } + public SchemaValidateDocumentFailedException(System.Exception innerException, string errorCode = "") + : base(GetFaultCode(innerException), GetInnerFaultCode(innerException), innerException, errorCode) { } private static OiosiFaultCode GetFaultCode(Exception innerException) { diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidatorWithLookup.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidatorWithLookup.cs index dc4a8dd5f7374f5a7bba5e1893566e93842de659..a237b397c344f98c1c1ffd353182982b62eb2a3c 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidatorWithLookup.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schema/SchemaValidatorWithLookup.cs @@ -79,6 +79,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema { { if (document == null) { + //E-RSP21311 throw new SchemaValidationInterceptionEmptyBodyException(); } @@ -99,13 +100,15 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema { schemaValidator.SchemaValidateXmlDocument(document, XmlSchemaSet, validationEventHandler); } } - catch (SchemaValidateDocumentFailedException) + catch (SchemaValidateDocumentFailedException ex) { - throw; + //E-RSP21312 + throw new SchemaValidateDocumentFailedException(ex.InnerException, "E-RSP21312"); } - catch (SchemaValidationFailedException) + catch (SchemaValidationFailedException ex) { - throw; + //E-RSP21313 + throw new SchemaValidationFailedException(document, ex, "E-RSP21313"); } catch (Exception ex) { @@ -156,17 +159,17 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema { catch (SchemaValidateDocumentFailedException ex) { this.logger.Debug("Schema validate xml document.", ex); - throw ex; + throw new SchemaValidateDocumentFailedException(ex, "E-RSP21312"); } catch (SchemaValidationFailedException ex) { this.logger.Debug("Schema validate xml document.", ex); - throw ex; + throw new SchemaValidationFailedException(ex, "E-RSP21313"); } catch (Exception ex) { - this.logger.Error("Schema validate xml document.", ex); - throw new SchemaValidateDocumentFailedException(ex); + this.logger.Error("E-RSP21314: Schema validate xml document.", ex); + throw new SchemaValidateDocumentFailedException(ex,"E-RSP21312"); } this.logger.Trace("Schema validate xml document - Finish."); @@ -181,7 +184,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema { { if (args.Severity == XmlSeverityType.Warning) { - this.logger.Warn("Matching schema not found. No schema validation occurred"); + this.logger.Warn("W-RSP21315: Matching schema not found. No schema validation occurred"); } else { diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidateDocumentFailedException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidateDocumentFailedException.cs index cd2f9d5f0530d50ca128f7313fb01ec27d4aed54..3c2c0c067aa05482519f332d5a463a8de8472e5e 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidateDocumentFailedException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidateDocumentFailedException.cs @@ -48,7 +48,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron { /// Constructor with innerexception /// /// Innerexception of the thrown exception - public SchematronValidateDocumentFailedException(Exception innerException) : base(GetFaultCode(innerException), GetInnerFaultCode(innerException), innerException) { } + public SchematronValidateDocumentFailedException(Exception innerException, string errorCode = "") : base(GetFaultCode(innerException), GetInnerFaultCode(innerException), innerException, errorCode) { } private static OiosiFaultCode GetFaultCode(Exception innerException) { diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidationInterceptionEmptyBodyException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidationInterceptionEmptyBodyException.cs index 40f2c722fef4f15442482a07d7965a37efc7df6e..8ff8174e3b444846f92b1fc03c4da7f26953eca4 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidationInterceptionEmptyBodyException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidationInterceptionEmptyBodyException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron { /// /// SchematronValidationInterceptionEmptyBodyException constructor /// - public SchematronValidationInterceptionEmptyBodyException() : base() { } + public SchematronValidationInterceptionEmptyBodyException(string errorCode = "") : base(new System.Collections.Generic.Dictionary(), errorCode) { } } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidatorWithLookup.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidatorWithLookup.cs index b32ad5006c367ab56ece6b052413fb74b5c6485b..a5aa8ff6a0441e7860f54981e4a856b3a6223df7 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidatorWithLookup.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidatorWithLookup.cs @@ -72,7 +72,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron this.logger.Trace("SchematronValidation"); if (document == null) { - throw new SchematronValidationInterceptionEmptyBodyException(); + throw new SchematronValidationInterceptionEmptyBodyException("E-RSP21321"); } DocumentTypeConfig documentType = searcher.FindUniqueDocumentType(document); @@ -87,13 +87,13 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron } catch (SchematronErrorException ex) { - this.logger.Info("XmlDocument rejected, as it contant at least one schematron error."); - throw new SchematronValidateDocumentFailedException(ex); + this.logger.Info("XmlDocument rejected, as it contains at least one schematron error."); + throw new SchematronValidateDocumentFailedException(ex, "E-RSP21322"); } catch (Exception ex) { - this.logger.Error("Schematron validation failed", ex); - throw new SchematronValidateDocumentFailedException(ex); + this.logger.Error("E-RSP15318: Schematron validation failed", ex); + throw new SchematronValidateDocumentFailedException(ex, "E-RSP21322"); } } @@ -108,7 +108,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron this.logger.Trace("SchematronValidation"); if (documentAsString == null) { - throw new SchematronValidationInterceptionEmptyBodyException(); + throw new SchematronValidationInterceptionEmptyBodyException("E-RSP21321"); } XmlDocument xmlDoc = new XmlDocument(); @@ -127,13 +127,13 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron } catch (SchematronErrorException ex) { - this.logger.Info("XmlDocument rejected, as it contant at least one schematron error."); - throw new SchematronValidateDocumentFailedException(ex); + this.logger.Info("XmlDocument rejected, as it contains at least one schematron error."); + throw new SchematronValidateDocumentFailedException(ex, "E-RSP21322"); } catch (Exception ex) { - this.logger.Error("Schematron validation failed", ex); - throw new SchematronValidateDocumentFailedException(ex); + this.logger.Error("E-RSP15319: Schematron validation failed", ex); + throw new SchematronValidateDocumentFailedException(ex, "E-RSP21322"); } } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/ServerXsltTransformationBindingElement.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/ServerXsltTransformationBindingElement.cs index b90076944820e4112aa4de8fb6fa8f2539606d78..f9940930f5a6bbcde347dd5be26cf2fb273727d4 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/ServerXsltTransformationBindingElement.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/ServerXsltTransformationBindingElement.cs @@ -114,7 +114,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.XsltTransform { message.AddProperty(ServerXsltTransformationBindingExtensionElement.ORIGINALBODYPROPERTYNAME, orgBody); } } catch (Exception ex) { - throw new XsltTransformFailedException(ex); + throw new XsltTransformFailedException(ex, "E-RSP21401"); } } diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/XsltTransformFailedException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/XsltTransformFailedException.cs index c1c2da0c0d2c205ee52896473b57c873f65f6f68..bd870ef5fbccec48b6921ae3c762428f88090d89 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/XsltTransformFailedException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/XsltTransform/XsltTransformFailedException.cs @@ -45,7 +45,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.XsltTransform { /// /// Default constructor. /// - public XsltTransformFailedException(Exception innerException) : base(GetFaultCode(innerException), GetInnerFaultCode(innerException), innerException) { } + public XsltTransformFailedException(Exception innerException, string errorCode = "") : base(GetFaultCode(innerException), GetInnerFaultCode(innerException), innerException, errorCode) { } private static OiosiFaultCode GetFaultCode(Exception innerException) { diff --git a/src/dk.gov.oiosi/security/CertificateChecker.cs b/src/dk.gov.oiosi/security/CertificateChecker.cs index f9785b1d66cfe5198ccff7b41da14f7e8f7dee0d..32a1a06f543726146d1d86467092b32be3540672 100644 --- a/src/dk.gov.oiosi/security/CertificateChecker.cs +++ b/src/dk.gov.oiosi/security/CertificateChecker.cs @@ -38,13 +38,15 @@ using dk.gov.oiosi.security.revocation; using dk.gov.oiosi.security.revocation.ocsp; using dk.gov.oiosi.security.validation; -namespace dk.gov.oiosi.security { +namespace dk.gov.oiosi.security +{ /// /// Methods for performing various certificate checks, such as revocation and /// root certificate relations /// - public class CertificateChecker { + public class CertificateChecker + { private X509Certificate2 _defaultOCESrootCertificate; private IRevocationLookup _lookup; @@ -52,27 +54,43 @@ namespace dk.gov.oiosi.security { /// Instantiates CertificateChecker /// /// default OCES root certificate - public CertificateChecker(X509Certificate2 defaultRootCertificate) { - try { + public CertificateChecker(X509Certificate2 defaultRootCertificate) + { + try + { _defaultOCESrootCertificate = defaultRootCertificate; //Initializes the component, that will do the actual ocsp lookup RevocationLookupFactory lookupFactory = new RevocationLookupFactory(); _lookup = lookupFactory.CreateRevocationLookupClient(); - } catch (UriFormatException) { - throw; - } catch (ArgumentNullException) { - throw; - } catch (OverflowException) { - throw; - } catch (FormatException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception) { - throw; + } + catch (UriFormatException ex) + { + throw new UriFormatException("E-RSP19001", ex); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (OverflowException ex) + { + throw new OverflowException("E-RSP19003", ex); + } + catch (FormatException ex) + { + throw new FormatException("E-RSP19004", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new Exception("E-RSP19007", ex); } } @@ -90,39 +108,47 @@ namespace dk.gov.oiosi.security { /// been performed, if individual checks fail. In that case, only the fields of the /// CertificateCheckResult structure that /// corresponds to checks already performed are valid. - public CertificateCheckResult CheckCertificate(X509Certificate2 certificate, X509Certificate2 rootCertificate) { + public CertificateCheckResult CheckCertificate(X509Certificate2 certificate, X509Certificate2 rootCertificate) + { CertificateCheckResult result = new CertificateCheckResult(); - try { + try + { //1. that the certificate has the default rootcertificate as root. // Also checks that the cert is not expired or not yet activated. CheckCertificateChain(certificate, result); - if (!result.CertificateActivated - || !result.CertificateValid + if (!result.CertificateActivated + || !result.CertificateValid || !result.RootCertificateAsRoot - ) { + ) + { result.AllTestsPassed = false; return result; } //2. that the rootcertificate is not expired or not activated - if (rootCertificate == null) { + if (rootCertificate == null) + { CheckRootCertificateValidation(_defaultOCESrootCertificate, result); CheckRootCertificateActivated(_defaultOCESrootCertificate, result); - } else { + } + else + { CheckRootCertificateValidation(rootCertificate, result); CheckRootCertificateActivated(rootCertificate, result); } - if (!result.RootCertificateValid || !result.RootCertificateActivated) { + if (!result.RootCertificateValid || !result.RootCertificateActivated) + { result.AllTestsPassed = false; return result; } //4. check if the certificate is revoked async RevocationResponse response = CheckCertificateRevocation(certificate); - if (!response.IsValid) { + if (!response.IsValid) + { result.AllTestsPassed = false; result.CertificateRevoked = true; return result; @@ -132,25 +158,42 @@ namespace dk.gov.oiosi.security { CheckCertificateType(certificate, result); if (result.CertificateActivated && !result.CertificateRevoked && result.CertificateValid - && result.RootCertificateActivated && result.RootCertificateAsRoot && result.RootCertificateValid) { + && result.RootCertificateActivated && result.RootCertificateAsRoot && result.RootCertificateValid) + { result.AllTestsPassed = true; } - } catch (ArgumentNullException) { - throw; - } catch (OverflowException) { - throw; - } catch (FormatException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (CheckCertificateOcspUnexpectedException) { - throw; - } catch (CertificateRevokedTimeoutException) { - throw; - } catch (Exception) { - throw; + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (OverflowException ex) + { + throw new OverflowException("E-RSP19003", ex); ; + } + catch (FormatException ex) + { + throw new FormatException("E-RSP19004", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (CheckCertificateOcspUnexpectedException ex) + { + throw new CheckCertificateOcspUnexpectedException("E-RSP19008", ex); + } + catch (CertificateRevokedTimeoutException ex) + { + throw new CertificateRevokedTimeoutException(TimeSpan.MinValue, "E-RSP19009"); + } + catch (Exception ex) + { + throw new CryptographicException("E-RSP19007", ex); } return result; } @@ -160,7 +203,8 @@ namespace dk.gov.oiosi.security { /// /// certificate to check /// - public CertificateCheckResult CheckCertificate(X509Certificate2 certificate) { + public CertificateCheckResult CheckCertificate(X509Certificate2 certificate) + { return CheckCertificate(certificate, null); } @@ -170,26 +214,42 @@ namespace dk.gov.oiosi.security { /// the certificate to validate /// the object to store the result /// This exception is thrown, if an unexpected exception is thrown during the method - private void CheckCertificateChain(X509Certificate2 certificate, CertificateCheckResult result) { - try { + private void CheckCertificateChain(X509Certificate2 certificate, CertificateCheckResult result) + { + try + { CertificateValidator.ValidateCertificate(certificate, _defaultOCESrootCertificate); result.RootCertificateAsRoot = true; result.CertificateActivated = true; result.CertificateValid = true; - } catch (CertificateFailedChainValidationException) { + } + catch (CertificateFailedChainValidationException) + { result.RootCertificateAsRoot = false; - } catch (CertificateNotActiveException) { + } + catch (CertificateNotActiveException) + { result.CertificateActivated = false; - } catch (CertificateExpiredException) { + } + catch (CertificateExpiredException) + { result.CertificateValid = false; - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception e) { - throw new CheckCertificateChainUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new CheckCertificateChainUnexpectedException(ex, "E-RSP19010"); } } @@ -199,20 +259,31 @@ namespace dk.gov.oiosi.security { /// The rootcertificate to check /// The object to store the result of the check /// This exception is thrown, if an unexpected exception is thrown during the method - private void CheckRootCertificateActivated(X509Certificate2 root, CertificateCheckResult result) { - try { + private void CheckRootCertificateActivated(X509Certificate2 root, CertificateCheckResult result) + { + try + { if (root.NotBefore.CompareTo(DateTime.Now) < 0 || - root.NotBefore.CompareTo(DateTime.Now) == 0) { + root.NotBefore.CompareTo(DateTime.Now) == 0) + { result.RootCertificateActivated = true; } - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception e) { - throw new CheckRootCertificateActivatedUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new CheckRootCertificateActivatedUnexpectedException(ex, "E-RSP19011"); } } @@ -222,20 +293,31 @@ namespace dk.gov.oiosi.security { /// The rootcertificate to check /// The object to store the result of the check /// This exception is thrown, if an unexpected exception is thrown during the method - private void CheckRootCertificateValidation(X509Certificate2 root, CertificateCheckResult result) { - try { + private void CheckRootCertificateValidation(X509Certificate2 root, CertificateCheckResult result) + { + try + { if (root.NotAfter.CompareTo(DateTime.Now) > 0 || - root.NotAfter.CompareTo(DateTime.Now) == 0) { + root.NotAfter.CompareTo(DateTime.Now) == 0) + { result.RootCertificateValid = true; } - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception e) { - throw new CheckRootCertificateValidUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new CheckRootCertificateValidUnexpectedException(ex, "E-RSP19012"); } } @@ -245,21 +327,33 @@ namespace dk.gov.oiosi.security { /// The certificate to check /// boolean stating whether the certificate is activated (true) or not (false) /// This exception is thrown, if an unexpected exception is thrown during the method - public bool CheckCertificateActivated(X509Certificate2 certificate) { + public bool CheckCertificateActivated(X509Certificate2 certificate) + { bool isActive = false; - try { + try + { CertificateValidator.CheckCertificateActivated(certificate); isActive = true; - } catch (CertificateNotActiveException) { + } + catch (CertificateNotActiveException) + { isActive = false; - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception e) { - throw new CheckCertificateActivatedUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new CheckCertificateActivatedUnexpectedException(ex, "E-RSP19013"); } return isActive; } @@ -270,21 +364,33 @@ namespace dk.gov.oiosi.security { /// The certificate to check /// boolean stating whether the certificate is valid (true) or not (false) /// This exception is thrown, if an unexpected exception is thrown during the method - public bool CheckCertificateValidation(X509Certificate2 certificate) { + public bool CheckCertificateValidation(X509Certificate2 certificate) + { bool isValid = false; - try { + try + { CertificateValidator.CheckCertificateExpired(certificate); isValid = true; - } catch (CertificateExpiredException) { + } + catch (CertificateExpiredException) + { isValid = false; - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception e) { - throw new CheckCertificateValidUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new CheckCertificateValidUnexpectedException(ex, "E-RSP19014"); } return isValid; } @@ -297,25 +403,41 @@ namespace dk.gov.oiosi.security { /// This exception is thrown, if an unexpected exception is thrown during the method /// This exception is thrown, if the call to Ocsp server takes longer time than the allowed timeout /// Thrown if an unexpected error occured - private RevocationResponse CheckCertificateRevocation(X509Certificate2 certificate) { + private RevocationResponse CheckCertificateRevocation(X509Certificate2 certificate) + { RevocationResponse validityCheck = null; - try { + try + { // Checks the certificate validityCheck = _lookup.CheckCertificate(certificate); - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (ArithmeticException) { - throw; - } catch (CheckCertificateOcspUnexpectedException) { - throw; - } catch (CertificateRevokedTimeoutException) { - throw; - } catch (Exception e) { - throw new CheckCertificateRevokedUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (ArithmeticException ex) + { + throw new ArithmeticException("E-RSP19015", ex); + } + catch (CheckCertificateOcspUnexpectedException ex) + { + throw new CheckCertificateOcspUnexpectedException("E-RSP19008", ex); + } + catch (CertificateRevokedTimeoutException ex) + { + throw new CertificateRevokedTimeoutException(TimeSpan.MinValue, "E-RSP19009"); + } + catch (Exception ex) + { + throw new CheckCertificateRevokedUnexpectedException(ex, "E-RSP19016"); } return validityCheck; } @@ -325,29 +447,45 @@ namespace dk.gov.oiosi.security { /// /// The certificate to check /// Returns the OCES certificate type - public static OcesCertificateType GetCertificateType(X509Certificate certificate) { + public static OcesCertificateType GetCertificateType(X509Certificate certificate) + { OcesCertificateType certType = OcesCertificateType.NonOces; - try { + try + { //no check included for LRA and Device string subjectString = certificate.Subject; - if (subjectString.Contains("PID")) { + if (subjectString.Contains("PID")) + { certType = OcesCertificateType.OcesPersonal; - } else if (subjectString.Contains("CVR")) { - if (subjectString.Contains("RID")) { + } + else if (subjectString.Contains("CVR")) + { + if (subjectString.Contains("RID")) + { certType = OcesCertificateType.OcesEmployee; - } else if (subjectString.Contains("UID")) { + } + else if (subjectString.Contains("UID")) + { certType = OcesCertificateType.OcesOrganisation; } } - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (Exception e) { - throw new CheckCertificateTypeUnexpectedException(e); + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (Exception ex) + { + throw new CheckCertificateTypeUnexpectedException(ex, "E-RSP19017"); } return certType; } @@ -357,19 +495,31 @@ namespace dk.gov.oiosi.security { /// /// The certificate to check /// The result object to store the result - private void CheckCertificateType(X509Certificate2 certificate, CertificateCheckResult result) { - try { + private void CheckCertificateType(X509Certificate2 certificate, CertificateCheckResult result) + { + try + { result.CertificateType = GetCertificateType(certificate); - } catch (ArgumentNullException) { - throw; - } catch (CryptographicUnexpectedOperationException) { - throw; - } catch (CryptographicException) { - throw; - } catch (CheckCertificateTypeUnexpectedException) { - throw; - } catch (Exception) { - throw; + } + catch (ArgumentNullException ex) + { + throw new ArgumentNullException("E-RSP19002", ex); + } + catch (CryptographicUnexpectedOperationException ex) + { + throw new CryptographicUnexpectedOperationException("E-RSP19005", ex); + } + catch (CryptographicException ex) + { + throw new CryptographicException("E-RSP19006", ex); + } + catch (CheckCertificateTypeUnexpectedException ex) + { + throw new CheckCertificateTypeUnexpectedException(ex, "E-RSP19017"); + } + catch (Exception ex) + { + throw new Exception("E-RSP19007", ex); } } } diff --git a/src/dk.gov.oiosi/security/CertificateHandlingException.cs b/src/dk.gov.oiosi/security/CertificateHandlingException.cs index b588dc6436927f08fd6b2c312c78b9a5ca6daeda..b49bdde681c204bde42c5b3a0c055adc55ec3ef8 100644 --- a/src/dk.gov.oiosi/security/CertificateHandlingException.cs +++ b/src/dk.gov.oiosi/security/CertificateHandlingException.cs @@ -53,21 +53,21 @@ namespace dk.gov.oiosi.security { /// /// The keywords to add public CertificateHandlingException( - System.Collections.Generic.Dictionary keywords) - : base(resourceManager, keywords) { } + System.Collections.Generic.Dictionary keywords, string errorCode = "") + : base(resourceManager, keywords, errorCode) { } /// /// Constructor. Takes an exception and displays it as an inner exception /// /// The exception to display as an inner exception - public CertificateHandlingException(System.Exception innerException) - : base(resourceManager, innerException) { } + public CertificateHandlingException(System.Exception innerException, string errorCode = "") + : base(resourceManager, innerException, errorCode) { } /// /// Constructor. Takes a set of keywords and an inner exception /// /// The keywords to add /// The exception to display as an inner exception - public CertificateHandlingException(System.Collections.Generic.Dictionary keywords, System.Exception innerException) : base(resourceManager, keywords, innerException) { } + public CertificateHandlingException(System.Collections.Generic.Dictionary keywords, System.Exception innerException, string errorCode = "") : base(resourceManager, keywords, innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/CertificateSubject.cs b/src/dk.gov.oiosi/security/CertificateSubject.cs index 13304376548e048cb790c15707df4c89bd750cc0..60a219f13fd16c541aa2359917401a2d059447bb 100644 --- a/src/dk.gov.oiosi/security/CertificateSubject.cs +++ b/src/dk.gov.oiosi/security/CertificateSubject.cs @@ -123,10 +123,10 @@ namespace dk.gov.oiosi.security { /// The subject of the certificate public CertificateSubject(string subjectString) { if (subjectString == null){ - throw new NullArgumentException("SubjectSerialNumber"); + throw new NullArgumentException("E-RSP19021: SubjectSerialNumber is null"); } if (subjectString.Trim().Length < 1) { - throw new EmptyStringException("SubjectSerialNumber"); + throw new EmptyStringException("E-RSP19022: SubjectSerialNumber is an empty string"); } _subjectString = subjectString.Trim(); @@ -150,7 +150,7 @@ namespace dk.gov.oiosi.security { const string cnRegExpPattern = "(c|C)(n|N)(\\s)*=([^+,])*"; Regex cn = new Regex(cnRegExpPattern); if ((!o.IsMatch(_subjectString)) || (!c.IsMatch(_subjectString)) || (!cn.IsMatch(_subjectString))) - throw new dk.gov.oiosi.security.ldap.PatternsDoesNotMatchException(_subjectString, new string[] { oRegExpPattern, cRegExpPattern }); + throw new dk.gov.oiosi.security.ldap.PatternsDoesNotMatchException(_subjectString, new string[] { oRegExpPattern, cRegExpPattern }, "E-RSP19023"); string[] subjectParts = _subjectString.Split(','); Match oMatch = o.Match(_subjectString); diff --git a/src/dk.gov.oiosi/security/CheckCertificateActivatedUnexpectedException.cs b/src/dk.gov.oiosi/security/CheckCertificateActivatedUnexpectedException.cs index 5cefbf9adeccb009013b681572794711afdd871f..a94fa336b24ea32cbef495d529b1e682bf213819 100644 --- a/src/dk.gov.oiosi/security/CheckCertificateActivatedUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/CheckCertificateActivatedUnexpectedException.cs @@ -44,6 +44,6 @@ namespace dk.gov.oiosi.security { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckCertificateActivatedUnexpectedException(Exception innerException) : base(innerException) { } + public CheckCertificateActivatedUnexpectedException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/CheckCertificateChainUnexpectedException.cs b/src/dk.gov.oiosi/security/CheckCertificateChainUnexpectedException.cs index 40cbff2633e9ad9e42fe2094f61aafa2d3ec9d98..5fa921fd7c7f33f8b968b390cbe84356b80c8eb9 100644 --- a/src/dk.gov.oiosi/security/CheckCertificateChainUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/CheckCertificateChainUnexpectedException.cs @@ -43,7 +43,7 @@ namespace dk.gov.oiosi.security { /// /// Constructor with innerexception /// - /// innerexception of the thrown exception - public CheckCertificateChainUnexpectedException(Exception innerException) : base(innerException) { } + /// innerexception of the thrown exceptions + public CheckCertificateChainUnexpectedException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/CheckCertificateTypeUnexpectedException.cs b/src/dk.gov.oiosi/security/CheckCertificateTypeUnexpectedException.cs index e2f17cf5bed37bb4f73a8870579c568aebdf95c5..122fc508fa21287dae5245b43f6f11ee98ccb4cd 100644 --- a/src/dk.gov.oiosi/security/CheckCertificateTypeUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/CheckCertificateTypeUnexpectedException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.security { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckCertificateTypeUnexpectedException(Exception innerException) : base(innerException) { } + public CheckCertificateTypeUnexpectedException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/CheckCertificateValidUnexpectedException.cs b/src/dk.gov.oiosi/security/CheckCertificateValidUnexpectedException.cs index 0cd9d878191647380ed91e917828d5d5347ff4ec..5395ad73712e5854cce0a25fc8be5a6f461cb6e9 100644 --- a/src/dk.gov.oiosi/security/CheckCertificateValidUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/CheckCertificateValidUnexpectedException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.security { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckCertificateValidUnexpectedException(Exception innerException) : base(innerException) { } + public CheckCertificateValidUnexpectedException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/CheckRootCertificateActivatedUnexpectedException.cs b/src/dk.gov.oiosi/security/CheckRootCertificateActivatedUnexpectedException.cs index e4342d5158a265e359363e63049c6e2cea416d09..4c9f3208957cc272b70dbbd9bceeda6cb8b96bfb 100644 --- a/src/dk.gov.oiosi/security/CheckRootCertificateActivatedUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/CheckRootCertificateActivatedUnexpectedException.cs @@ -44,6 +44,6 @@ namespace dk.gov.oiosi.security { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckRootCertificateActivatedUnexpectedException(Exception innerException) : base(innerException) { } + public CheckRootCertificateActivatedUnexpectedException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/CheckRootCertificateValidUnexpectedException.cs b/src/dk.gov.oiosi/security/CheckRootCertificateValidUnexpectedException.cs index 90cc85c68a9d6bb3ea4dc5f256709bd4d765bcde..e8ee795799524abca4811259f9b416e5bfeafaf1 100644 --- a/src/dk.gov.oiosi/security/CheckRootCertificateValidUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/CheckRootCertificateValidUnexpectedException.cs @@ -44,6 +44,6 @@ namespace dk.gov.oiosi.security { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckRootCertificateValidUnexpectedException(Exception innerException) : base(innerException) { } + public CheckRootCertificateValidUnexpectedException(Exception innerException,string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/security/ErrorMessages.Designer.cs index 0efc5585ce9d2586ce0e594611016c0ac5ed857a..98bf3d16a0aef606dbe10bc3fca78ccc6147f608 100644 --- a/src/dk.gov.oiosi/security/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/security/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.security { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { diff --git a/src/dk.gov.oiosi/security/SignatureValidationProof.cs b/src/dk.gov.oiosi/security/SignatureValidationProof.cs index 1054dd55179201a1b40dec3a93ad9380ccebb0dd..a8542afecaafafaa4f97fe9bd5751460e90eefca 100644 --- a/src/dk.gov.oiosi/security/SignatureValidationProof.cs +++ b/src/dk.gov.oiosi/security/SignatureValidationProof.cs @@ -80,7 +80,7 @@ namespace dk.gov.oiosi.security { /// public void CompleteValidation(string certificateSubject) { if (_completed) - throw new SignatureValidationProofAllreadyCompletedException(certificateSubject); + throw new SignatureValidationProofAllreadyCompletedException(certificateSubject, "E-RSP19031"); _timeStamp = DateTime.Now; _certificateSubject = certificateSubject; _validCertificate = true; @@ -114,7 +114,7 @@ namespace dk.gov.oiosi.security { public DateTime TimeStamp { get { return _timeStamp; } set { - if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject); + if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject, "E-RSP19031"); _timeStamp = value; } } @@ -125,7 +125,7 @@ namespace dk.gov.oiosi.security { public string CertificateSubject { get { return _certificateSubject; } set { - if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject); + if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject, "E-RSP19031"); _certificateSubject = value; } } @@ -136,7 +136,7 @@ namespace dk.gov.oiosi.security { public bool ValidCertificate { get { return _validCertificate; } set { - if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject); + if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject, "E-RSP19031"); _validCertificate = value; } } @@ -147,7 +147,7 @@ namespace dk.gov.oiosi.security { public bool ValidSignature { get { return _validSignature; } set { - if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject); + if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject, "E-RSP19031"); _validSignature = value; } } @@ -158,7 +158,7 @@ namespace dk.gov.oiosi.security { public bool UnchangedMessage { get { return _unchangedMessage; } set { - if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject); + if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject, "E-RSP19031"); _unchangedMessage = value; } } @@ -169,7 +169,7 @@ namespace dk.gov.oiosi.security { public bool EncryptedMessage { get { return _encryptedMessage; } set { - if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject); + if (_completed) throw new SignatureValidationProofAllreadyCompletedException(_certificateSubject, "E-RSP19031"); _encryptedMessage = value; } } diff --git a/src/dk.gov.oiosi/security/SignatureValidationProofAllreadyCompletedException.cs b/src/dk.gov.oiosi/security/SignatureValidationProofAllreadyCompletedException.cs index eec9c355bbe091d5619bedb0a7b8625f7aff44c5..3deea80ff9783a76300488ebdaeffb40f7131a0a 100644 --- a/src/dk.gov.oiosi/security/SignatureValidationProofAllreadyCompletedException.cs +++ b/src/dk.gov.oiosi/security/SignatureValidationProofAllreadyCompletedException.cs @@ -44,6 +44,6 @@ namespace dk.gov.oiosi.security { /// Constructor /// /// The certificate subject - public SignatureValidationProofAllreadyCompletedException(string certificateSubject) : base(KeywordFromString.GetKeyword("certificatesubject", certificateSubject)) { } + public SignatureValidationProofAllreadyCompletedException(string certificateSubject, string errorCode = "") : base(KeywordFromString.GetKeyword("certificatesubject", certificateSubject), errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/ldap/ConnectingToLdapServerFailedException.cs b/src/dk.gov.oiosi/security/ldap/ConnectingToLdapServerFailedException.cs index 02fefec7cdaf71a0416a1f384d71e5ff3dafed8e..204025e975d61f43ee831e917fd11856ff060a99 100644 --- a/src/dk.gov.oiosi/security/ldap/ConnectingToLdapServerFailedException.cs +++ b/src/dk.gov.oiosi/security/ldap/ConnectingToLdapServerFailedException.cs @@ -47,7 +47,7 @@ namespace dk.gov.oiosi.security.ldap /// /// The settings used when attempting connection /// The cause exception - public ConnectingToLdapServerFailedException(CertificateInfrastructure certificateInfrastructure, System.Exception innerException) + public ConnectingToLdapServerFailedException(CertificateInfrastructure certificateInfrastructure, System.Exception innerException, string errorCode = "") : base(CreateKeywords(certificateInfrastructure), innerException) { } private static Dictionary CreateKeywords(CertificateInfrastructure certificateInfrastructure) { diff --git a/src/dk.gov.oiosi/security/ldap/ConvertingSearchResultToCertificateFailedException.cs b/src/dk.gov.oiosi/security/ldap/ConvertingSearchResultToCertificateFailedException.cs index 36bad44e08ae79ebc00d6cc263dd41bf944d4cd7..63e6889d56402dbdb5296ad38ad1ed5c5f25aa8d 100644 --- a/src/dk.gov.oiosi/security/ldap/ConvertingSearchResultToCertificateFailedException.cs +++ b/src/dk.gov.oiosi/security/ldap/ConvertingSearchResultToCertificateFailedException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.security.ldap /// with the exception. /// /// - public ConvertingSearchResultToCertificateFailedException(System.Exception innerException) : base(innerException) { } + public ConvertingSearchResultToCertificateFailedException(System.Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/ldap/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/security/ldap/ErrorMessages.Designer.cs index c20461184a4e296e3522e886f4158be9685edba0..02db93aaf44c62a7c17a84833d8d3d01aa4fadf4 100644 --- a/src/dk.gov.oiosi/security/ldap/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/security/ldap/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.security.ldap { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { diff --git a/src/dk.gov.oiosi/security/ldap/FailedToLoadLookupTypeException.cs b/src/dk.gov.oiosi/security/ldap/FailedToLoadLookupTypeException.cs index 45a8e351974bcfe3c3307a6721ed5c917ba21051..265ba09db881b7c36fbcd08e887b1a7f56d33207 100644 --- a/src/dk.gov.oiosi/security/ldap/FailedToLoadLookupTypeException.cs +++ b/src/dk.gov.oiosi/security/ldap/FailedToLoadLookupTypeException.cs @@ -44,6 +44,6 @@ namespace dk.gov.oiosi.security.ldap { /// Constuctor with the lookuptype attempted to load /// /// attempted load lookuptype - public FailedToLoadLookupTypeException(string lookupType) : base(KeywordFromString.GetKeyword("lookuptype", lookupType)) { } + public FailedToLoadLookupTypeException(string lookupType, string errorCode = "") : base(KeywordFromString.GetKeyword("lookuptype", lookupType), errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookup.cs b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookup.cs index 1c370f530f8feaa191e3f17df036cfcc7b8fa46e..1c7a1a8d71af2c179897630c3252a88a3a27b878 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookup.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookup.cs @@ -99,7 +99,7 @@ namespace dk.gov.oiosi.security.ldap { if (subject == null) { - throw new ArgumentNullException("subject"); + throw new ArgumentNullException("E-RSP19101: 'subject' is null"); } X509Certificate2 certificateToBeReturned; @@ -180,7 +180,7 @@ namespace dk.gov.oiosi.security.ldap return ldapConnection; } catch (Exception e) { - throw new ConnectingToLdapServerFailedException(certificateInfrastructure, e); + throw new ConnectingToLdapServerFailedException(certificateInfrastructure, e, "E-RSP19102"); } } @@ -209,7 +209,7 @@ namespace dk.gov.oiosi.security.ldap searchBase, LdapConnection.SCOPE_SUB, searchFilter, attributes, false, ldapSearchConstraints); } catch (Exception e) { - throw new SearchFailedException(e); + throw new SearchFailedException(e, "E-RSP19103"); } return ldapSearchResults; @@ -231,7 +231,7 @@ namespace dk.gov.oiosi.security.ldap bool searchResultFound = ldapSearchResults.hasMore(); if (searchResultFound == false) { - throw new LdapCertificateNotFoundException(subject); + throw new LdapCertificateNotFoundException(subject, "E-RSP19104"); } LdapEntry ldapEntry = ldapSearchResults.next(); @@ -239,7 +239,7 @@ namespace dk.gov.oiosi.security.ldap bool moreThanOneSearchResultFound = ldapSearchResults.hasMore(); if (moreThanOneSearchResultFound) { - throw new LdapMultipleCertificatesFoundException(subject); + throw new LdapMultipleCertificatesFoundException(subject, "E-RSP19105"); } try { @@ -256,7 +256,7 @@ namespace dk.gov.oiosi.security.ldap return certificate; } catch (Exception e) { - throw new ConvertingSearchResultToCertificateFailedException(e); + throw new ConvertingSearchResultToCertificateFailedException(e, "E-RSP19106"); } } @@ -276,7 +276,7 @@ namespace dk.gov.oiosi.security.ldap bw.Flush(); } catch (Exception e) { - throw new StoringCertificateFailedException(e); + throw new StoringCertificateFailedException(e, "E-RSP19107"); } finally { if (bw != null) bw.Close(); diff --git a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupInitializationFailedException.cs b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupInitializationFailedException.cs index f940ee11e0a369cc76942dc0bc15bf514a771017..0dfc799a6471b353136556b6d781ac1edd2d5e75 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupInitializationFailedException.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupInitializationFailedException.cs @@ -40,6 +40,6 @@ namespace dk.gov.oiosi.security.ldap /// Constructor /// /// - public LdapCertificateLookupInitializationFailedException(System.Exception innerException) : base(innerException) { } + public LdapCertificateLookupInitializationFailedException(System.Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupTest.cs b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupTest.cs index bc9bdd4826f4c10cf161ec8a28591631c64dbc50..02fed1d8a78b2788db72e909968114a8f7be5b8c 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupTest.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookupTest.cs @@ -70,13 +70,13 @@ namespace dk.gov.oiosi.security.ldap { var certificateInfrastructure = certificateSubject.SubjectString.Contains("FID") ? settings.HostPortForNemId : settings.HostPortForMitId; - throw new ConnectingToLdapServerFailedException(certificateInfrastructure, new Exception(this.ToString())); + throw new ConnectingToLdapServerFailedException(certificateInfrastructure, new Exception(this.ToString()), "E-RSP19111"); case LdapCertificateLookupTestConfig.LookupAction.SearchFailed: - throw new SearchFailedException(new Exception(this.ToString())); + throw new SearchFailedException(new Exception(this.ToString()), "E-RSP19112"); default: - throw new NotImplementedException(); + throw new NotImplementedException("E-RSP19113"); } } diff --git a/src/dk.gov.oiosi/security/ldap/LdapCertificateNotFoundException.cs b/src/dk.gov.oiosi/security/ldap/LdapCertificateNotFoundException.cs index 64ce95b84181533f5395907d048052b323299169..2032d5bd73190b1173051fd9a0fb680905737d3b 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapCertificateNotFoundException.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapCertificateNotFoundException.cs @@ -46,7 +46,7 @@ namespace dk.gov.oiosi.security.ldap { /// Constructor /// /// The certificate subject - public LdapCertificateNotFoundException(CertificateSubject subject) : base(resources, GetKeywords(subject)) { } + public LdapCertificateNotFoundException(CertificateSubject subject, string errorCode = "") : base(resources, GetKeywords(subject), errorCode) { } private static Dictionary GetKeywords(CertificateSubject subject) { Dictionary keywords = new Dictionary(); diff --git a/src/dk.gov.oiosi/security/ldap/LdapException.cs b/src/dk.gov.oiosi/security/ldap/LdapException.cs index 421cb812b3a12e24e633f70962987b635d6f7a08..bd9feaa22453cb21c6d800fc29661599a015aa44 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapException.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapException.cs @@ -31,6 +31,7 @@ * */ +using System; using System.Resources; using dk.gov.oiosi.exception; @@ -53,14 +54,14 @@ namespace dk.gov.oiosi.security.ldap /// Standard default constructor, gives the base constructor the resource manager as /// parameter. /// - public LdapException() : base(resourceManager) { } + public LdapException(string errorCode = "") : base(resourceManager, new Exception(), errorCode) { } /// /// Standard constructor that takes a dictionary with keywords as parameter and calls /// a base constructor with the keywords and the resource manager. /// /// A dictionary that contains keywords that are used in building the exception message - public LdapException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public LdapException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Standard constructor that takes an exception that is the inner exception as @@ -68,7 +69,7 @@ namespace dk.gov.oiosi.security.ldap /// resource manager. /// /// The inner exception of this exception - public LdapException(System.Exception innerException) : base(resourceManager, innerException) { } + public LdapException(System.Exception innerException, string errorCode = "") : base(resourceManager, innerException, errorCode) { } /// /// Standard constructor that takes a dictionary with keywords and an exception @@ -77,6 +78,6 @@ namespace dk.gov.oiosi.security.ldap /// /// A dictionary that contains keywords that are used in building the exception message /// The inner exception of this exception - public LdapException(System.Collections.Generic.Dictionary keywords, System.Exception innerException) : base(resourceManager, keywords, innerException) { } + public LdapException(System.Collections.Generic.Dictionary keywords, System.Exception innerException, string errorCode = "") : base(resourceManager, keywords, innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/ldap/LdapLookupFactory.cs b/src/dk.gov.oiosi/security/ldap/LdapLookupFactory.cs index 0e39f926f378e064242628317ce4f803f9388a61..888ed0dbe6b95cf17db8e5771c0a214d2832dddc 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapLookupFactory.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapLookupFactory.cs @@ -53,11 +53,11 @@ namespace dk.gov.oiosi.security.ldap { // 2. Get the type to load: if (config.ImplementationNamespaceClass == null || config.ImplementationNamespaceClass == "") { - throw new LdapNoImplementingClassException(); + throw new LdapNoImplementingClassException("E-RSP19121"); } if (config.ImplementationAssembly == null || config.ImplementationAssembly == "") { - throw new LdapNoImplementingAssemblyException(); + throw new LdapNoImplementingAssemblyException("E-RSP19122"); } string qualifiedTypename = config.ImplementationNamespaceClass + ", " + config.ImplementationAssembly; @@ -65,7 +65,7 @@ namespace dk.gov.oiosi.security.ldap { if (lookupClientType == null) { - throw new FailedToLoadLookupTypeException(qualifiedTypename); + throw new FailedToLoadLookupTypeException(qualifiedTypename, "E-RSP19123"); } // 3. Instantiate the type: @@ -76,7 +76,7 @@ namespace dk.gov.oiosi.security.ldap { } catch (Exception e) { - throw new LdapCertificateLookupInitializationFailedException(e); + throw new LdapCertificateLookupInitializationFailedException(e, "E-RSP19124"); } return lookupClient; diff --git a/src/dk.gov.oiosi/security/ldap/LdapMultipleCertificatesFoundException.cs b/src/dk.gov.oiosi/security/ldap/LdapMultipleCertificatesFoundException.cs index 696314fff4a359a91f61c64b2605f1006f5eb532..e84ab03b75a9ce35026b34394411f7c85fdca22f 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapMultipleCertificatesFoundException.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapMultipleCertificatesFoundException.cs @@ -50,7 +50,7 @@ namespace dk.gov.oiosi.security.ldap { /// Constructor /// /// The certificate subject - public LdapMultipleCertificatesFoundException(CertificateSubject subject) : base(resourceManager, GetKeywords(subject)) { } + public LdapMultipleCertificatesFoundException(CertificateSubject subject, string errorCode = "") : base(resourceManager, GetKeywords(subject), errorCode) { } private static Dictionary GetKeywords(CertificateSubject subject) { Dictionary keywords = new Dictionary(); diff --git a/src/dk.gov.oiosi/security/ldap/LdapNoImplementingAssemblyException.cs b/src/dk.gov.oiosi/security/ldap/LdapNoImplementingAssemblyException.cs index 07557c733779acac85ff48cbe7d173bef9e3c621..26e07c44971d5d693dd92be8d4d5d6fade570a5d 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapNoImplementingAssemblyException.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapNoImplementingAssemblyException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.security.ldap /// /// Constructor /// - public LdapNoImplementingAssemblyException() : base() { } + public LdapNoImplementingAssemblyException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/ldap/LdapNoImplementingClassException.cs b/src/dk.gov.oiosi/security/ldap/LdapNoImplementingClassException.cs index 038b70b69fcdbf6de1b59703765026e3f269836a..ffdd899865d821e3f389876dc1747aa454d33db7 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapNoImplementingClassException.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapNoImplementingClassException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.security.ldap /// /// Constructor /// - public LdapNoImplementingClassException() : base() { } + public LdapNoImplementingClassException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/ldap/PatternsDoesNotMatchException.cs b/src/dk.gov.oiosi/security/ldap/PatternsDoesNotMatchException.cs index a47746258f83a7efd734bb49ef7165da7141b353..2198381f76907dec1983cd5ff15aaffba0b9b5e6 100644 --- a/src/dk.gov.oiosi/security/ldap/PatternsDoesNotMatchException.cs +++ b/src/dk.gov.oiosi/security/ldap/PatternsDoesNotMatchException.cs @@ -47,7 +47,7 @@ namespace dk.gov.oiosi.security.ldap /// /// subject string to test /// the regulary expression - public PatternsDoesNotMatchException(string subject, string[] patternsArray) : base(SetMessage(subject, patternsArray)) { } + public PatternsDoesNotMatchException(string subject, string[] patternsArray, string errorCode = "") : base(SetMessage(subject, patternsArray), errorCode) { } private static Dictionary SetMessage(string subject, string[] patternsArray) { diff --git a/src/dk.gov.oiosi/security/ldap/StoringCertificateFailedException.cs b/src/dk.gov.oiosi/security/ldap/StoringCertificateFailedException.cs index 772a600d48d0dec5bb54be10629fcda5f7375574..05a08cd7e36bf62addd384a8fee7fadea3895f34 100644 --- a/src/dk.gov.oiosi/security/ldap/StoringCertificateFailedException.cs +++ b/src/dk.gov.oiosi/security/ldap/StoringCertificateFailedException.cs @@ -42,6 +42,6 @@ namespace dk.gov.oiosi.security.ldap /// as parameter. Then it calls the base constructor with the inner exception. /// /// The cause to why the exception is thrown - public StoringCertificateFailedException(System.Exception innerException) : base(innerException) { } + public StoringCertificateFailedException(System.Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/lookup/CertificateLoader.cs b/src/dk.gov.oiosi/security/lookup/CertificateLoader.cs index 67e98ff406fc65b94b7864c595a74ac13999606c..3e870d9a4b532f434753e0cd75506f66af5a59be 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateLoader.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateLoader.cs @@ -158,7 +158,7 @@ namespace dk.gov.oiosi.security.lookup { if (result.Count < 1) { - throw new CertificateLoaderCertificateNotFoundException(store, findType, searchString); + throw new CertificateLoaderCertificateNotFoundException(store, findType, searchString, "E-RSP19201"); } else if (result.Count == 1) { @@ -184,7 +184,7 @@ namespace dk.gov.oiosi.security.lookup { } else { - throw new CertificateLoaderMultipleCertificatesFoundException(store, findType, searchString); + throw new CertificateLoaderMultipleCertificatesFoundException(store, findType, searchString, "E-RSP19202"); } } } diff --git a/src/dk.gov.oiosi/security/lookup/CertificateLoaderCertificateNotFoundException.cs b/src/dk.gov.oiosi/security/lookup/CertificateLoaderCertificateNotFoundException.cs index 11057aa75a990992b1efadaa0b1d1591e5a99188..845601144153ae1f71e3bffe25de46d464588b99 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateLoaderCertificateNotFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateLoaderCertificateNotFoundException.cs @@ -47,8 +47,8 @@ namespace dk.gov.oiosi.security.lookup { /// /// /// - public CertificateLoaderCertificateNotFoundException(X509Store store, X509FindType findType, string searchString) - : base(GetKeywords(store, findType, searchString)) { + public CertificateLoaderCertificateNotFoundException(X509Store store, X509FindType findType, string searchString, string errorCode = "") + : base(GetKeywords(store, findType, searchString), errorCode) { } private static Dictionary GetKeywords(X509Store store, X509FindType findType, string searchString) { diff --git a/src/dk.gov.oiosi/security/lookup/CertificateLoaderMultipleCertificatesFoundException.cs b/src/dk.gov.oiosi/security/lookup/CertificateLoaderMultipleCertificatesFoundException.cs index 97b40c419f68b7826d02b0a2c5d74f3e937289a7..e5f26c1109b7e040a272a5881d15fa2db60d0d28 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateLoaderMultipleCertificatesFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateLoaderMultipleCertificatesFoundException.cs @@ -48,8 +48,8 @@ namespace dk.gov.oiosi.security.lookup { /// /// /// - public CertificateLoaderMultipleCertificatesFoundException(X509Store store, X509FindType findType, string searchString) - : base(GetKeywords(store, findType, searchString)) { + public CertificateLoaderMultipleCertificatesFoundException(X509Store store, X509FindType findType, string searchString, string errorCode = "") + : base(GetKeywords(store, findType, searchString), errorCode) { } private static Dictionary GetKeywords(X509Store store, X509FindType findType, string searchString) { diff --git a/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs b/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs index 51cfcc3651ec62add8eba93a00ecb1893eee81c6..e93d544ea479de7e8969d5af8d33e986651dabbf 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs @@ -59,7 +59,7 @@ namespace dk.gov.oiosi.security.lookup { /// a base constructor with the keywords and the resource manager. /// /// A dictionary that contains keywords that are used in building the exception message - public CertificateLookupException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public CertificateLookupException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Standard constructor that takes an exception that is the inner exception as @@ -67,7 +67,7 @@ namespace dk.gov.oiosi.security.lookup { /// resource manager. /// /// The inner exception of this exception - public CertificateLookupException(System.Exception innerException) : base(resourceManager, innerException) { } + public CertificateLookupException(System.Exception innerException, string errorCode = "") : base(resourceManager, innerException, errorCode) { } /// /// Standard constructor that takes a dictionary with keywords and an exception @@ -83,6 +83,6 @@ namespace dk.gov.oiosi.security.lookup { /// /// /// - public CertificateLookupException(ResourceManager resourceManager, Dictionary keywords) : base(resourceManager, keywords) { } + public CertificateLookupException(ResourceManager resourceManager, Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs b/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs index f9e37ee3cad320cc5667e192853858f14e80da8a..463eeb3a2ec935aae47e8d9e486109bce62a0bb2 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs @@ -42,12 +42,12 @@ namespace dk.gov.oiosi.security.lookup { /// Constructor that takes a dictionay with keywords. /// /// - public CertificateNotFoundException(Dictionary keywords) : base(keywords) { } + public CertificateNotFoundException(Dictionary keywords, string errorCode = "") : base(keywords, errorCode) { } /// /// Constructor that takes a resource manager and a dictionary with keywords. /// /// /// - public CertificateNotFoundException(ResourceManager errorMessages, Dictionary keywords) : base(errorMessages, keywords) { } + public CertificateNotFoundException(ResourceManager errorMessages, Dictionary keywords, string errorCode = "") : base(errorMessages, keywords, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/lookup/CertificateStoreIdentification.cs b/src/dk.gov.oiosi/security/lookup/CertificateStoreIdentification.cs index 80e3e31891c800660117c2298b0ff72ccc1c45ac..4e9daf0a91fb988b0670bfb60ed3997759c927e9 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateStoreIdentification.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateStoreIdentification.cs @@ -60,7 +60,7 @@ namespace dk.gov.oiosi.security.lookup { /// /// public CertificateStoreIdentification(StoreLocation storeLocation, StoreName storeName, string serialNumber) { - if (serialNumber == null) throw new NullArgumentException("serialNumber"); + if (serialNumber == null) throw new NullArgumentException("E-RSP19211: 'serialNumber' is null"); _storeLocation = storeLocation; _storeName = storeName; _serialNumber = serialNumber; @@ -88,7 +88,7 @@ namespace dk.gov.oiosi.security.lookup { public string SerialNumber { get { return _serialNumber; } set { - if (value == null) throw new NullArgumentException("CertificateStoreIdentification.SerialNumber"); + if (value == null) throw new NullArgumentException("E-RSP19211: Cannot set 'CertificateStoreIdentification.SerialNumber' to null"); _serialNumber = value; } } diff --git a/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs b/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs index 2233e7f87362a3d91fec26b2f4cbb5f6ab403d4d..e69d9e8f8ce181abde9c1a0af42a0b74666d4857 100644 --- a/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs @@ -42,12 +42,12 @@ namespace dk.gov.oiosi.security.lookup { /// Constructor that takes a dictionary with keywords. /// /// - public MultipleCertificatesFoundException(Dictionary keywords) : base(keywords) { } + public MultipleCertificatesFoundException(Dictionary keywords, string errorCode = "") : base(keywords, errorCode) { } /// /// Constructor that takes a resource manager and a dictionary with keywords. /// /// /// - public MultipleCertificatesFoundException(ResourceManager errorMessages, Dictionary keywords) : base(errorMessages, keywords) { } + public MultipleCertificatesFoundException(ResourceManager errorMessages, Dictionary keywords, string errorCode = "") : base(errorMessages, keywords, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/lookup/SearchFailedException.cs b/src/dk.gov.oiosi/security/lookup/SearchFailedException.cs index a3be1d47ddd550e9566a462a4db92c3944a1a5fa..2bb32279ca432fdf340764e5579bf9fd4a3663df 100644 --- a/src/dk.gov.oiosi/security/lookup/SearchFailedException.cs +++ b/src/dk.gov.oiosi/security/lookup/SearchFailedException.cs @@ -30,6 +30,8 @@ * Christian Lanng, ITST * */ +using System.Collections.Generic; + namespace dk.gov.oiosi.security.lookup { /// @@ -41,6 +43,6 @@ namespace dk.gov.oiosi.security.lookup /// more detailed exception. /// /// The exception that occured when searching. - public SearchFailedException(System.Exception innerException) : base(innerException) { } + public SearchFailedException(System.Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/oces/AmbigousSubjectCvrNumberException.cs b/src/dk.gov.oiosi/security/oces/AmbigousSubjectCvrNumberException.cs index 8b31904671c5c5e2a4c8d76e03ab8978e76a523a..6fdbb36fa2cda5fb2393188251ba2e7c2d2a3150 100644 --- a/src/dk.gov.oiosi/security/oces/AmbigousSubjectCvrNumberException.cs +++ b/src/dk.gov.oiosi/security/oces/AmbigousSubjectCvrNumberException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.security.oces { /// Constructor that takes the certificate that has multiple cvr numbers in its subject. /// /// - public AmbigousSubjectCvrNumberException(X509Certificate2 certificate) : base(KeywordsFromX509Certificate2.GetKeywords(certificate)) { } + public AmbigousSubjectCvrNumberException(X509Certificate2 certificate, string errorCode = "") : base(KeywordsFromX509Certificate2.GetKeywords(certificate), errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/oces/EmployeeOcesX509Certificate.cs b/src/dk.gov.oiosi/security/oces/EmployeeOcesX509Certificate.cs index 9d8f376295dbbd921c0dbf8fb32cbb1c65a5951c..b50a74abf6519b14ea81add09b06a50f2fa759a4 100644 --- a/src/dk.gov.oiosi/security/oces/EmployeeOcesX509Certificate.cs +++ b/src/dk.gov.oiosi/security/oces/EmployeeOcesX509Certificate.cs @@ -48,7 +48,7 @@ namespace dk.gov.oiosi.security.oces { /// public EmployeeOcesX509Certificate(X509Certificate2 certificate) : base(certificate) { if (OcesCertificateType != OcesCertificateType.OcesEmployee) - throw new InvalidOcesEmployeeCertificateException(certificate); + throw new InvalidOcesEmployeeCertificateException(certificate, "E-RSP19301"); SetCvrNumber(); } @@ -60,7 +60,7 @@ namespace dk.gov.oiosi.security.oces { /// public EmployeeOcesX509Certificate(OcesX509Certificate certifcate) : this(certifcate.Certificate) { if (OcesCertificateType != OcesCertificateType.OcesEmployee) - throw new InvalidOcesEmployeeCertificateException(certifcate.Certificate); + throw new InvalidOcesEmployeeCertificateException(certifcate.Certificate, "E-RSP19301"); SetCvrNumber(); } @@ -75,8 +75,8 @@ namespace dk.gov.oiosi.security.oces { string serialNumber = SubjectSerialNumber.SerialNumberValue; Regex regex = new Regex("(cvr:)(\\d)*", RegexOptions.IgnoreCase); MatchCollection matches = regex.Matches(serialNumber); - if (matches.Count < 1) throw new NoSubjectCvrNumberException(Certificate); - if (matches.Count > 1) throw new AmbigousSubjectCvrNumberException(Certificate); + if (matches.Count < 1) throw new NoSubjectCvrNumberException(Certificate, "E-RSP19302"); + if (matches.Count > 1) throw new AmbigousSubjectCvrNumberException(Certificate, "E-RSP19303"); string fullCvrString = matches[0].Value; _cvrNumber = fullCvrString.Substring(4); } diff --git a/src/dk.gov.oiosi/security/oces/FailedGetOcesCertificateTypeException.cs b/src/dk.gov.oiosi/security/oces/FailedGetOcesCertificateTypeException.cs index f7279ce1b669ee4f34dc2b78aa9e072a772e2271..67f9ccb4a4f3108b4002c97b70104d25e70d517a 100644 --- a/src/dk.gov.oiosi/security/oces/FailedGetOcesCertificateTypeException.cs +++ b/src/dk.gov.oiosi/security/oces/FailedGetOcesCertificateTypeException.cs @@ -14,6 +14,6 @@ namespace dk.gov.oiosi.security.oces { /// /// /// - public FailedGetOcesCertificateTypeException(X509Certificate2 certificate, Exception innerException) : base(KeywordsFromX509Certificate2.GetKeywords(certificate), innerException) { } + public FailedGetOcesCertificateTypeException(X509Certificate2 certificate, Exception innerException, string errorCode = "") : base(KeywordsFromX509Certificate2.GetKeywords(certificate), innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/oces/InvalidOcesCertificateException.cs b/src/dk.gov.oiosi/security/oces/InvalidOcesCertificateException.cs index 4f07888de487791e18049ff245f9eb15bb436a95..074af02490cfda56576cfd901cac355dbbb5bc8f 100644 --- a/src/dk.gov.oiosi/security/oces/InvalidOcesCertificateException.cs +++ b/src/dk.gov.oiosi/security/oces/InvalidOcesCertificateException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.security.oces { /// Constructor that takes the certificate that is not a valid oces certificate /// /// - public InvalidOcesCertificateException(X509Certificate2 certificate) : base(KeywordsFromX509Certificate2.GetKeywords(certificate)) {} + public InvalidOcesCertificateException(X509Certificate2 certificate, string errorCode = "") : base(KeywordsFromX509Certificate2.GetKeywords(certificate), errorCode) {} } } diff --git a/src/dk.gov.oiosi/security/oces/InvalidOcesEmployeeCertificateException.cs b/src/dk.gov.oiosi/security/oces/InvalidOcesEmployeeCertificateException.cs index 8969ceaf5293653635a14d3ffd3330a435cd4d8e..c8e002b95b9a80fa3d54a4263fd329a58485bb2b 100644 --- a/src/dk.gov.oiosi/security/oces/InvalidOcesEmployeeCertificateException.cs +++ b/src/dk.gov.oiosi/security/oces/InvalidOcesEmployeeCertificateException.cs @@ -45,6 +45,6 @@ namespace dk.gov.oiosi.security.oces { /// employee certificate with. /// /// - public InvalidOcesEmployeeCertificateException(X509Certificate2 certificate) : base(KeywordsFromX509Certificate2.GetKeywords(certificate)) { } + public InvalidOcesEmployeeCertificateException(X509Certificate2 certificate, string errorCode = "") : base(KeywordsFromX509Certificate2.GetKeywords(certificate), errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/oces/NoSubjectCvrNumberException.cs b/src/dk.gov.oiosi/security/oces/NoSubjectCvrNumberException.cs index 860e14fff458d93c07cd65abcb0d357df552d50a..97ef8baee1cac59352832a5a7eefd4e95f1e3bb7 100644 --- a/src/dk.gov.oiosi/security/oces/NoSubjectCvrNumberException.cs +++ b/src/dk.gov.oiosi/security/oces/NoSubjectCvrNumberException.cs @@ -43,6 +43,6 @@ namespace dk.gov.oiosi.security.oces { /// Constructor that takes the certificate that has no cvr number in its subject. /// /// - public NoSubjectCvrNumberException(X509Certificate2 certificate) : base(KeywordsFromX509Certificate2.GetKeywords(certificate)) { } + public NoSubjectCvrNumberException(X509Certificate2 certificate, string errorCode = "") : base(KeywordsFromX509Certificate2.GetKeywords(certificate), errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs b/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs index 13f17150666c8762d3f989871a834cbfd03c629b..086b963d4a8c2baf322e3c5044afa2d33edd175d 100644 --- a/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs +++ b/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs @@ -47,7 +47,7 @@ namespace dk.gov.oiosi.security.oces { /// Constructor that takes a dictionary of keywords as parameter /// /// - public OcesCertificateException(Dictionary keywords) : base(keywords) { } + public OcesCertificateException(Dictionary keywords, string errorCode = "") : base(keywords, errorCode) { } /// /// Constructor that takes an inner exception as parameter /// @@ -59,6 +59,6 @@ namespace dk.gov.oiosi.security.oces { /// /// /// - public OcesCertificateException(Dictionary keywords, Exception innerException) : base(keywords, innerException) { } + public OcesCertificateException(Dictionary keywords, Exception innerException, string errorCode = "") : base(keywords, innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/oces/OcesCertificateSubjectKey.cs b/src/dk.gov.oiosi/security/oces/OcesCertificateSubjectKey.cs index 7f2ba70856cd95094fea06aacef375ab59b285d2..fbba60eaa368889e1a9c9f277bb2d7d50db54c28 100644 --- a/src/dk.gov.oiosi/security/oces/OcesCertificateSubjectKey.cs +++ b/src/dk.gov.oiosi/security/oces/OcesCertificateSubjectKey.cs @@ -41,9 +41,9 @@ namespace dk.gov.oiosi.security.oces { } private void CheckSubjectKeyString(string subjectKeyString) { - if (string.IsNullOrEmpty(subjectKeyString)) throw new NullOrEmptyArgumentException("keyString"); + if (string.IsNullOrEmpty(subjectKeyString)) throw new NullOrEmptyArgumentException("'keyString' is null or empty", "E-RSP19311"); if (Regex.IsMatch(subjectKeyString, @"(^\\)+")) - throw new Exception("Invalid subject key string."); + throw new Exception("E-RSP19312: Invalid subject key string."); } } } diff --git a/src/dk.gov.oiosi/security/oces/OcesX509Certificate.cs b/src/dk.gov.oiosi/security/oces/OcesX509Certificate.cs index f56a421984df2c71e30deaadffce24bb56bb108a..643f6eddb92f88f79652acfbd3b763f72626a27d 100644 --- a/src/dk.gov.oiosi/security/oces/OcesX509Certificate.cs +++ b/src/dk.gov.oiosi/security/oces/OcesX509Certificate.cs @@ -62,7 +62,7 @@ namespace dk.gov.oiosi.security.oces { { if (certificate == null) { - throw new ArgumentNullException("certificate"); + throw new ArgumentNullException("E-RSP19321: 'certificate' is null"); } this.x509Certificate = certificate; @@ -70,7 +70,7 @@ namespace dk.gov.oiosi.security.oces { this.SetCertificateType(); if (this.ocesCertificateType == OcesCertificateType.NonOces) { - throw new InvalidOcesCertificateException(certificate); + throw new InvalidOcesCertificateException(certificate, "E-RSP19322"); } } @@ -237,7 +237,7 @@ namespace dk.gov.oiosi.security.oces { { if (certificate == null) { - throw new NullArgumentException("certificate"); + throw new ArgumentNullException("E-RSP19321: 'certificate' is null"); } OcesCertificateType ocesCertificateType; @@ -248,7 +248,7 @@ namespace dk.gov.oiosi.security.oces { } catch (Exception ex) { - throw new FailedGetOcesCertificateTypeException(certificate, ex); + throw new FailedGetOcesCertificateTypeException(certificate, ex, "E-RSP19323"); } return ocesCertificateType; @@ -261,7 +261,7 @@ namespace dk.gov.oiosi.security.oces { { if (subject == null) { - throw new NullArgumentException("subject"); + throw new ArgumentNullException("E-RSP19324: 'certificateSubject' is null"); } //The code is using the subject as identifier of the the oces type. OcesCertificateType ocesCertificateType = GetFromSubject(subject); diff --git a/src/dk.gov.oiosi/security/oces/OcesX509CertificateConfig.cs b/src/dk.gov.oiosi/security/oces/OcesX509CertificateConfig.cs index f7b56cb1a36431df32ce5e84190b7ec74b3081ea..d96f0063dbb5b3eb1702021b40f47a462115ecdb 100644 --- a/src/dk.gov.oiosi/security/oces/OcesX509CertificateConfig.cs +++ b/src/dk.gov.oiosi/security/oces/OcesX509CertificateConfig.cs @@ -67,10 +67,10 @@ namespace dk.gov.oiosi.security.oces { OcesCertificateSubjectKey employeeCertificateSubjectKey, OcesCertificateSubjectKey organizationCertificateSubjectKey, OcesCertificateSubjectKey functionCertificateSubjectKey) { - if (personalCertificateSubjectKey == null) throw new NullArgumentException("personalCertificateSubjectKey"); - if (employeeCertificateSubjectKey == null) throw new NullArgumentException("employeeCertificateSubjectKey"); - if (organizationCertificateSubjectKey == null) throw new NullArgumentException("organizationCertificateSubjectKey"); - if (functionCertificateSubjectKey == null) throw new NullArgumentException("functionCertificateSubjectKey"); + if (personalCertificateSubjectKey == null) throw new NullArgumentException("'personalCertificateSubjectKey' is null", "E-RSP19331"); + if (employeeCertificateSubjectKey == null) throw new NullArgumentException("'employeeCertificateSubjectKey' is null", "E-RSP19332"); + if (organizationCertificateSubjectKey == null) throw new NullArgumentException("'organizationCertificateSubjectKey' is null", "E-RSP19333"); + if (functionCertificateSubjectKey == null) throw new NullArgumentException("'functionCertificateSubjectKey' is null", "E-RSP19334"); _personalCertificateSubjectKey = personalCertificateSubjectKey; _employeeCertificateSubjectKey = employeeCertificateSubjectKey; _organizationCertificateSubjectKey = organizationCertificateSubjectKey; @@ -87,7 +87,7 @@ namespace dk.gov.oiosi.security.oces { { if (value == null) { - throw new NullArgumentException("OcesX509CertificateConfig.PersonalCertificateSubjectKey"); + throw new NullArgumentException("'OcesX509CertificateConfig.PersonalCertificateSubjectKey' can not be set to null", "E-RSP19335"); } else { @@ -105,7 +105,7 @@ namespace dk.gov.oiosi.security.oces { set { if (value == null) { - throw new NullArgumentException("OcesX509CertificateConfig.EmployeeCertificateSubjectKey"); + throw new NullArgumentException("'OcesX509CertificateConfig.EmployeeCertificateSubjectKey' can not be set to null", "E-RSP19336"); } else { @@ -123,7 +123,7 @@ namespace dk.gov.oiosi.security.oces { set { if (value == null) { - throw new NullArgumentException("OcesX509CertificateConfig.OrganizationCertificateSubjectKey"); + throw new NullArgumentException("'OcesX509CertificateConfig.OrganizationCertificateSubjectKey' can not be set to null", "E-RSP19337"); } else { @@ -141,7 +141,7 @@ namespace dk.gov.oiosi.security.oces { set { if (value == null) { - throw new NullArgumentException("OcesX509CertificateConfig.FunctionCertificateSubjetKey"); + throw new NullArgumentException("'OcesX509CertificateConfig.FunctionCertificateSubjetKey' can not be set to null", "E-RSP19338"); } else { diff --git a/src/dk.gov.oiosi/security/revocation/CheckCertificateRevokedUnexpectedException.cs b/src/dk.gov.oiosi/security/revocation/CheckCertificateRevokedUnexpectedException.cs index afb165a3edae7a8e28a1a5d5b9717ce4b38fe685..cdca2bc9d53d5b4006d1b8bf32c19edec6abdd32 100644 --- a/src/dk.gov.oiosi/security/revocation/CheckCertificateRevokedUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/revocation/CheckCertificateRevokedUnexpectedException.cs @@ -44,6 +44,6 @@ namespace dk.gov.oiosi.security.revocation { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckCertificateRevokedUnexpectedException(Exception innerException) : base(innerException) { } + public CheckCertificateRevokedUnexpectedException(Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/revocation/FailedToLoadLookupTypeException.cs b/src/dk.gov.oiosi/security/revocation/FailedToLoadLookupTypeException.cs index 6df12a79cdac5d1770c2f6760e2b6c10bfe48e0b..ce0c7ced286623be04fbe2f924c151f6a4defbaf 100644 --- a/src/dk.gov.oiosi/security/revocation/FailedToLoadLookupTypeException.cs +++ b/src/dk.gov.oiosi/security/revocation/FailedToLoadLookupTypeException.cs @@ -42,6 +42,6 @@ namespace dk.gov.oiosi.security.revocation { /// Constructor /// /// Assembly qualified name of the type that could not be loaded - public FailedToLoadLookupTypeException(string lookupType) : base(KeywordFromString.GetKeyword("lookuptype", lookupType)) { } + public FailedToLoadLookupTypeException(string lookupType, string errorCode = "") : base(KeywordFromString.GetKeyword("lookuptype", lookupType), errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/revocation/RevocationException.cs b/src/dk.gov.oiosi/security/revocation/RevocationException.cs index 7aca2e852648e6618c2688cb4007a3c2f3cb47b0..c4b4c86501a29dba7856c87c6c96b0482484d095 100644 --- a/src/dk.gov.oiosi/security/revocation/RevocationException.cs +++ b/src/dk.gov.oiosi/security/revocation/RevocationException.cs @@ -44,18 +44,18 @@ namespace dk.gov.oiosi.security.revocation { /// /// Base constructor /// - public RevocationException() : base(resourceManager) { } + public RevocationException(string errorCode = "") : base(resourceManager, errorCode) { } /// /// Constructor with keywords /// /// keywords for the message - public RevocationException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public RevocationException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Constructor with innerexception /// /// innerexception of the thrown exception - public RevocationException(System.Exception innerException) : base(resourceManager, innerException) { } + public RevocationException(System.Exception innerException, string errorCode = "") : base(resourceManager, innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/revocation/RevocationLookupFactory.cs b/src/dk.gov.oiosi/security/revocation/RevocationLookupFactory.cs index 708248e8fa9f922e39bb66f5c3b07c403ec92ba1..be7842dec0249a8c6f159e4c3a735d1cbb2c422f 100644 --- a/src/dk.gov.oiosi/security/revocation/RevocationLookupFactory.cs +++ b/src/dk.gov.oiosi/security/revocation/RevocationLookupFactory.cs @@ -80,13 +80,13 @@ namespace dk.gov.oiosi.security.revocation { { // 1. Get the type to load: if (config.ImplementationNamespaceClass == null || config.ImplementationNamespaceClass == "") - throw new RevocationNoImplementingClassException(); + throw new RevocationNoImplementingClassException("E-RSP19451"); if (config.ImplementationAssembly == null || config.ImplementationAssembly == "") - throw new RevocationNoImplementingAssemblyException(); + throw new RevocationNoImplementingAssemblyException("E-RSP19452"); string qualifiedTypename = config.ImplementationNamespaceClass + ", " + config.ImplementationAssembly; Type lookupClientType = Type.GetType(qualifiedTypename); if (lookupClientType == null) - throw new FailedToLoadLookupTypeException(qualifiedTypename); + throw new FailedToLoadLookupTypeException(qualifiedTypename, "E-RSP19453"); // 3. Instantiate the type: IRevocationLookup lookupClient = (IRevocationLookup)lookupClientType.GetConstructor(new Type[0]).Invoke(null); diff --git a/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingAssemblyException.cs b/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingAssemblyException.cs index 586e6f1629c7fd310360208dc7aa7957c1072f8b..2c91054358fcc72da77bc28d89e9c4e9b33fad39 100644 --- a/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingAssemblyException.cs +++ b/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingAssemblyException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.security.revocation /// /// Constructor /// - public RevocationNoImplementingAssemblyException() : base() { } + public RevocationNoImplementingAssemblyException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingClassException.cs b/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingClassException.cs index bfde02ca2681fa59dd7f9854e7f7d17793f42b55..ad10688101fcd64e3d290819a4a67f6683e44617 100644 --- a/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingClassException.cs +++ b/src/dk.gov.oiosi/security/revocation/RevocationNoImplementingClassException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.security.revocation /// /// Constructor /// - public RevocationNoImplementingClassException() : base() { } + public RevocationNoImplementingClassException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs b/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs index 73ad216dbceedf56b3876a366a27361dec4dbab0..bfd29c754c974c811986fe313c98f2d3ea17ec48 100644 --- a/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs +++ b/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs @@ -139,7 +139,7 @@ namespace dk.gov.oiosi.security.revocation.crl Org.BouncyCastle.X509.X509Certificate certificateToValidate = this.cp.ReadCertificate(cert.RawData); if (this.data == null) { - throw new CrlUnavailableForDownloadException(url.ToString()); + throw new CrlUnavailableForDownloadException(url.ToString(), "E-RSP19401"); } else { @@ -181,7 +181,7 @@ namespace dk.gov.oiosi.security.revocation.crl { if (stream == null) { - this.logger.Warn(string.Format("The downloaded CRL stream from {0} is null.", url.ToString())); + this.logger.Warn(string.Format("W-RSP19406: The downloaded CRL stream from {0} is null.", url.ToString())); } // Downloads the .crl file into an X509CRL object. @@ -248,15 +248,15 @@ namespace dk.gov.oiosi.security.revocation.crl urlString = url.ToString(); } - this.logger.Error(string.Format("Error downloading CRL from url '{0}'. Reason was {1}.", urlString, response.StatusDescription)); - throw new CheckCertificateRevokedUnexpectedException(new Exception("CRL could not be downloaded: " + response.StatusDescription)); + this.logger.Error(string.Format("E-RSP19407: Error downloading CRL from url '{0}'. Reason was {1}.", urlString, response.StatusDescription)); + throw new CheckCertificateRevokedUnexpectedException(new Exception("CRL could not be downloaded: " + response.StatusDescription), "E-RSP19402"); } } - catch (CheckCertificateRevokedUnexpectedException) + catch (CheckCertificateRevokedUnexpectedException ex) { // This has already been logged. // Re-throw original exception - throw; + throw new CheckCertificateRevokedUnexpectedException(ex, "E-RSP19402"); } catch (IOException e) { @@ -267,8 +267,8 @@ namespace dk.gov.oiosi.security.revocation.crl urlString = url.ToString(); } - this.logger.Error(string.Format("Error downloading/parsing the CRL from url: '{0}'.", urlString), e); - throw new CheckCertificateRevokedUnexpectedException(e); + this.logger.Error(string.Format("E-RSP19408: Error downloading/parsing the CRL from url: '{0}'.", urlString), e); + throw new CheckCertificateRevokedUnexpectedException(e, "E-RSP19402"); } catch (Exception e) { @@ -279,10 +279,10 @@ namespace dk.gov.oiosi.security.revocation.crl urlString = url.ToString(); } - this.logger.Error(string.Format("Error downolading/parsing the CRL from url: '{0}'.", urlString), e); + this.logger.Error(string.Format("E-RSP19409: Error downolading/parsing the CRL from url: '{0}'.", urlString), e); // Re-throw original exception - throw; + throw new Exception("E-RSP19405", e); } return; diff --git a/src/dk.gov.oiosi/security/revocation/crl/CrlUnavailableForDownloadException.cs b/src/dk.gov.oiosi/security/revocation/crl/CrlUnavailableForDownloadException.cs index a23867c8d1e0e6b1e9df7f8101f2d8f96f980a78..f7a8b7794fbde26fcfed98b4f87b8af0ecd01186 100644 --- a/src/dk.gov.oiosi/security/revocation/crl/CrlUnavailableForDownloadException.cs +++ b/src/dk.gov.oiosi/security/revocation/crl/CrlUnavailableForDownloadException.cs @@ -8,8 +8,8 @@ namespace dk.gov.oiosi.security.revocation.crl { public class CrlUnavailableForDownloadException: RevocationException { - public CrlUnavailableForDownloadException(string cerUrl) - : base(MakeDir(cerUrl)) + public CrlUnavailableForDownloadException(string cerUrl, string errorCode = "") + : base(MakeDir(cerUrl), errorCode) { } private static Dictionary MakeDir(string cerUrl) diff --git a/src/dk.gov.oiosi/security/revocation/ocsp/CertificateRevokedTimeoutException.cs b/src/dk.gov.oiosi/security/revocation/ocsp/CertificateRevokedTimeoutException.cs index ce98f927a0258c70af6ab86cbdf6e452f5d5f2b5..6857b6fd43b9114ef3304e41d5393b4a53b84006 100644 --- a/src/dk.gov.oiosi/security/revocation/ocsp/CertificateRevokedTimeoutException.cs +++ b/src/dk.gov.oiosi/security/revocation/ocsp/CertificateRevokedTimeoutException.cs @@ -45,7 +45,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { /// Constructor with the timeout as keyword /// /// the timeout - public CertificateRevokedTimeoutException(TimeSpan ocspTimeout) : base(GetKeywords(ocspTimeout)) { } + public CertificateRevokedTimeoutException(TimeSpan ocspTimeout, string errorCode = "") : base(GetKeywords(ocspTimeout), errorCode) { } private static Dictionary GetKeywords(TimeSpan ocspTimeout) { diff --git a/src/dk.gov.oiosi/security/revocation/ocsp/CheckCertificateOcspUnexpectedException.cs b/src/dk.gov.oiosi/security/revocation/ocsp/CheckCertificateOcspUnexpectedException.cs index aff16e82005737a2a45a9f2d974e9c7adf987ff1..1277556877cda40b2d893e20a32dbbd03b4d1cfe 100644 --- a/src/dk.gov.oiosi/security/revocation/ocsp/CheckCertificateOcspUnexpectedException.cs +++ b/src/dk.gov.oiosi/security/revocation/ocsp/CheckCertificateOcspUnexpectedException.cs @@ -51,8 +51,8 @@ namespace dk.gov.oiosi.security.revocation.ocsp { /// Constructor with innerexception /// /// innerexception of the thrown exception - public CheckCertificateOcspUnexpectedException(string message) - : base(message) + public CheckCertificateOcspUnexpectedException(string message, string errorCode = "") + : base((!string.IsNullOrEmpty(errorCode) ? errorCode + ": " : "") + message) { } /// @@ -60,8 +60,8 @@ namespace dk.gov.oiosi.security.revocation.ocsp { /// /// Message /// innerexception of the thrown exception - public CheckCertificateOcspUnexpectedException(string message, Exception innerException) - : base(message, innerException) + public CheckCertificateOcspUnexpectedException(string message, Exception innerException, string errorCode = "") + : base((!string.IsNullOrEmpty(errorCode) ? errorCode + ": " : "") + message, innerException) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/revocation/ocsp/InvalidOcspTimeoutValueException.cs b/src/dk.gov.oiosi/security/revocation/ocsp/InvalidOcspTimeoutValueException.cs index ba3ca0476881372317ccd06ace286e0788b801b7..098475f1a4f22308c10f21fd1ea2ba9cd075e520 100644 --- a/src/dk.gov.oiosi/security/revocation/ocsp/InvalidOcspTimeoutValueException.cs +++ b/src/dk.gov.oiosi/security/revocation/ocsp/InvalidOcspTimeoutValueException.cs @@ -13,7 +13,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { /// /// /// - public InvalidOcspTimeoutValueException(int timeoutValue, int minValue, int maxValue) : base(KeywordFromNumber.GetKeyword("timeoutvalue", timeoutValue)) { } + public InvalidOcspTimeoutValueException(int timeoutValue, int minValue, int maxValue, string errorCode = "") : base(KeywordFromNumber.GetKeyword("timeoutvalue", timeoutValue), errorCode) { } private static Dictionary GetKeywords(int timeoutValue, int minValue, int maxValue) { Dictionary keywords = KeywordFromNumber.GetKeyword("timeoutvalue", timeoutValue); diff --git a/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs b/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs index 59ce1963da959f485995bba5358d883a21758c04..2e9a55b8b3503a129514ce9dca0b5b100dda509e 100644 --- a/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs +++ b/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs @@ -37,6 +37,7 @@ using dk.gov.oiosi.configuration; using dk.gov.oiosi.security.lookup; using System.Collections.Generic; using dk.gov.oiosi.logging; +using System.Linq; namespace dk.gov.oiosi.security.revocation.ocsp { @@ -77,7 +78,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { get { return _defaultTimeoutMsec; } set { if (value < 0) - throw new InvalidOcspTimeoutValueException(value, 0, int.MaxValue); + throw new InvalidOcspTimeoutValueException(value, 0, int.MaxValue, "E-RSP19411"); _defaultTimeoutMsec = value; } } @@ -124,19 +125,20 @@ namespace dk.gov.oiosi.security.revocation.ocsp { // logging the exception foreach (Exception exception in exceptions) { - this.logger.Error(exceptions); + //No errorcode added here, as this will return a list of exception with errorcodes + this.logger.Error(exception); } // and throw the latest exception if (exceptions.Count > 0) { - throw exceptions[exceptions.Count - 1]; + throw new Exception("E-RSP19412: " + exceptions[exceptions.Count - 1].Message); } else { // no exception // an no root certificate - throw new CertificateHandlingException(new Exception("No root certificate was found!")); + throw new CertificateHandlingException(new Exception("No root certificate was found!"), "E-RSP19413"); } } else diff --git a/src/dk.gov.oiosi/security/validation/CertificateExpiredException.cs b/src/dk.gov.oiosi/security/validation/CertificateExpiredException.cs index bd511fdb09db5b8d69d09af29350a7f087a436a5..c9de0108ca375af4cb0068f58114324ff8fb6f33 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateExpiredException.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateExpiredException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.security.validation /// Constructor /// /// the date the certificate expired - public CertificateExpiredException(DateTime expireDate, string subject) : base(GetKeywords(expireDate, subject)) { } + public CertificateExpiredException(DateTime expireDate, string subject, string errorCode = "") : base(GetKeywords(expireDate, subject), errorCode) { } private static Dictionary GetKeywords(DateTime expireDate, string subject) { diff --git a/src/dk.gov.oiosi/security/validation/CertificateFailedChainValidationException.cs b/src/dk.gov.oiosi/security/validation/CertificateFailedChainValidationException.cs index 8acf4e09af0535c8a848a094fa77772319f95b7d..809cbab2926049a3a3e5431d67e0e98c30e43831 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateFailedChainValidationException.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateFailedChainValidationException.cs @@ -44,15 +44,15 @@ namespace dk.gov.oiosi.security.validation /// Constructor with chainstatus as keyword /// /// chainstatus as keyword - public CertificateFailedChainValidationException(X509ChainStatus chainStatus, string subject) - : base(GetKeywords(chainStatus, subject)) { } + public CertificateFailedChainValidationException(X509ChainStatus chainStatus, string subject, string errorCode = "") + : base(GetKeywords(chainStatus, subject), errorCode) { } /// /// Constructor with status /// /// chainstatus as string - public CertificateFailedChainValidationException(string chainStatusString, string subject) - : base(GetKeywords(chainStatusString, subject)) { } + public CertificateFailedChainValidationException(string chainStatusString, string subject, string errorCode = "") + : base(GetKeywords(chainStatusString, subject), errorCode) { } private static Dictionary GetKeywords(X509ChainStatus chainStatus, string subject) { diff --git a/src/dk.gov.oiosi/security/validation/CertificateNotActiveException.cs b/src/dk.gov.oiosi/security/validation/CertificateNotActiveException.cs index d7683d672035a491de6e9212daa62efaec35f711..81a03a137f4460bd6351989be35a52ebdb987f50 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateNotActiveException.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateNotActiveException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.security.validation /// Constructor with the date the certificate was made active /// /// the date the certificate was activated - public CertificateNotActiveException(DateTime activeDate, string subject) : base(GetKeywords(activeDate, subject)) { } + public CertificateNotActiveException(DateTime activeDate, string subject, string errorCode = "") : base(GetKeywords(activeDate, subject), errorCode) { } private static Dictionary GetKeywords(DateTime activeDate, string subject) { diff --git a/src/dk.gov.oiosi/security/validation/CertificateNotInCorrectFormatException.cs b/src/dk.gov.oiosi/security/validation/CertificateNotInCorrectFormatException.cs index 338ef694c94c95f820284b97bd16837390b2f5cc..583745dacbc6b3ab410e449d19bb209947787f29 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateNotInCorrectFormatException.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateNotInCorrectFormatException.cs @@ -41,6 +41,6 @@ namespace dk.gov.oiosi.security.validation /// Constructor with innerexception /// /// the innerexception of the thrown exception - public CertificateNotInCorrectFormatException(System.Exception innerException) : base(innerException) { } + public CertificateNotInCorrectFormatException(System.Exception innerException, string errorCode = "") : base(innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/security/validation/CertificateRootNotTrustedException.cs b/src/dk.gov.oiosi/security/validation/CertificateRootNotTrustedException.cs index bb3b1893c18b662cbb995d3a07dab4ed067eff78..08035e22c13bd9c96ee36efa18b3e38f51b9ef79 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateRootNotTrustedException.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateRootNotTrustedException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.security.validation /// Constructor with the date the certificate was made active /// /// the date the certificate was activated - public CertificateRootNotTrustedException(string rootCertificate) : base(GetKeywords(rootCertificate)) { } + public CertificateRootNotTrustedException(string rootCertificate, string errorCode= "") : base(GetKeywords(rootCertificate), errorCode) { } private static Dictionary GetKeywords(string rootCertificate) { diff --git a/src/dk.gov.oiosi/security/validation/CertificateValidationException.cs b/src/dk.gov.oiosi/security/validation/CertificateValidationException.cs index 2b1cd9f190248eb349c7d3265768b680972ecbf0..e641b66f1897b7a6637cdf285b4a2df793acdab1 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateValidationException.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateValidationException.cs @@ -50,13 +50,13 @@ namespace dk.gov.oiosi.security.validation { /// Constructor with keywords /// /// keyword for the message - public CertificateValidationException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public CertificateValidationException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Constructor with innerexception /// /// innerexception of the thrown exception - public CertificateValidationException(System.Exception innerException) : base(resourceManager, innerException) { } + public CertificateValidationException(System.Exception innerException, string errorCode = "") : base(resourceManager, innerException, errorCode) { } /// /// Constructor with keywords and innerexception diff --git a/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs b/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs index 6fce44e310cb616e988be827e39f2589418455fe..3168c96dfbcd2c38f9172ea4c313f4065c2616cf 100644 --- a/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs +++ b/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs @@ -38,10 +38,10 @@ namespace dk.gov.oiosi.security.validation { catch (Exception exception) { // log the exception to the log fil, and then throw it again - this.logger.Fatal(exception); + this.logger.Fatal("F-RSP19516: " + exception.ToString() ); throw; } - } + }s public MultipleRootX509CertificateValidator(RootCertificateCollectionConfig rootCertificateCollectionConfig) { @@ -65,7 +65,7 @@ namespace dk.gov.oiosi.security.validation { } else { - throw new SecurityTokenValidationException("The client certificate is invalid."); + throw new SecurityTokenValidationException("E-RSP19511: The client certificate is invalid."); } } @@ -88,12 +88,12 @@ namespace dk.gov.oiosi.security.validation { if (certificate.NotAfter < DateTime.Now) { - throw new CertificateExpiredException(certificate.NotAfter, certificate.Subject); + throw new CertificateExpiredException(certificate.NotAfter, certificate.Subject, "E-RSP19512"); } else if (certificate.NotBefore > DateTime.Now) { // yet valid - throw new CertificateNotActiveException(certificate.NotBefore, certificate.Subject); + throw new CertificateNotActiveException(certificate.NotBefore, certificate.Subject, "E-RSP19513"); } else { @@ -103,7 +103,7 @@ namespace dk.gov.oiosi.security.validation { //isValid = this.IsCertificateChildOfRoot(certificate, rootCertificateDirectory); if (this.IsCertificateChildOfRoot(certificate, rootCertificateDirectory) == false) { - throw new CertificateRootNotTrustedException(certificate.Issuer); + throw new CertificateRootNotTrustedException(certificate.Issuer, "E-RSP19514"); } } @@ -156,14 +156,14 @@ namespace dk.gov.oiosi.security.validation { case X509ChainStatusFlags.Revoked: case X509ChainStatusFlags.UntrustedRoot: { - this.logger.Warn("X509ChainStatusFlags '" + status.Status + "' is not valid, so the certificate '" + certificate.Subject + "' is not valid."); + this.logger.Warn("W-RSP19517: X509ChainStatusFlags '" + status.Status + "' is not valid, so the certificate '" + certificate.Subject + "' is not valid."); this.logger.Debug("x509Chain.ChainStatus.Length:" + x509Chain.ChainStatus.Length +". Index: "+index+"."); isValid = false; break; } default: { - this.logger.Warn("The certificate chain.ChainStatus '" + status.Status + "' is not implemented."); + this.logger.Warn("W-RSP19518: The certificate chain.ChainStatus '" + status.Status + "' is not implemented."); isValid = false; break; } @@ -230,11 +230,11 @@ namespace dk.gov.oiosi.security.validation { // So, this root certificate was not found. try { - this.logger.Warn(notFoundException.Message); + this.logger.Warn("W-RSP19519: " + notFoundException.Message); } catch (Exception) { - this.logger.Warn(string.Format("Root certificate ({0}) not found. StoreLocation: {1}. StoreName: {2}. SerialNumber: {3}.", rootCertificateLocation.Description, rootCertificateLocation.StoreLocation, rootCertificateLocation.StoreName, rootCertificateLocation.SerialNumber)); + this.logger.Warn(string.Format("W-RSP19520: Root certificate ({0}) not found. StoreLocation: {1}. StoreName: {2}. SerialNumber: {3}.", rootCertificateLocation.Description, rootCertificateLocation.StoreLocation, rootCertificateLocation.StoreName, rootCertificateLocation.SerialNumber)); } } catch (Exception ex) @@ -263,7 +263,7 @@ namespace dk.gov.oiosi.security.validation { } catch (Exception e) { - throw new CertificateNotInCorrectFormatException(e); + throw new CertificateNotInCorrectFormatException(e, "E-RSP19515"); } return chain; diff --git a/src/dk.gov.oiosi/uddi/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/uddi/ErrorMessages.Designer.cs index 2eb684062caf15b244271db979eafb07f3fa5239..11564dd6fd6f2d41913c45105fca3d4f06f95eac 100644 --- a/src/dk.gov.oiosi/uddi/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/uddi/ErrorMessages.Designer.cs @@ -19,7 +19,7 @@ namespace dk.gov.oiosi.uddi { // 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", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ErrorMessages { @@ -123,6 +123,15 @@ namespace dk.gov.oiosi.uddi { } } + /// + /// Looks up a localized string similar to Parametren "[parameterName]" må ikke være null. + /// + internal static string dk_gov_oiosi_uddi_UddiLookupParameterNullException { + get { + return ResourceManager.GetString("dk_gov_oiosi_uddi_UddiLookupParameterNullException", resourceCulture); + } + } + /// /// Looks up a localized string similar to Der blev returneret mere end ét endpoint fra serviceregisteret (UDDI). Dette kan skyldes at der både er registreret endpoints for fx email og http (hvilket er lovligt), men at opslagsbiblioteket er konfigureret til ikke at acceptere dette. /// diff --git a/src/dk.gov.oiosi/uddi/ErrorMessages.resx b/src/dk.gov.oiosi/uddi/ErrorMessages.resx index 838287e780ca81ab15870e7f31e05b9487b6d984..6cf4e5342b93e8ef098c77ad873c54ee05e4fda3 100644 --- a/src/dk.gov.oiosi/uddi/ErrorMessages.resx +++ b/src/dk.gov.oiosi/uddi/ErrorMessages.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Kunne ikke finde kategorien med følgende TModel-nøgle "[categorytmodelkey]". @@ -139,6 +139,9 @@ Opslaget i serviceregisteret (UDDI) for endpointet med ID "[endpointKey]" fejlede. + + Parametren "[parameterName]" må ikke være null + Der blev returneret mere end ét endpoint fra serviceregisteret (UDDI). Dette kan skyldes at der både er registreret endpoints for fx email og http (hvilket er lovligt), men at opslagsbiblioteket er konfigureret til ikke at acceptere dette diff --git a/src/dk.gov.oiosi/uddi/LookupParameters.cs b/src/dk.gov.oiosi/uddi/LookupParameters.cs index 33a6c644563291a41648d9ff1052aa943c8d325b..6ff0930c988e985c9663a0e74b23c255a7f0765b 100644 --- a/src/dk.gov.oiosi/uddi/LookupParameters.cs +++ b/src/dk.gov.oiosi/uddi/LookupParameters.cs @@ -65,13 +65,13 @@ namespace dk.gov.oiosi.uddi { string profileRoleIdentifier, string profileConformanceClaim) { - if (identifier == null) throw new ArgumentNullException("identifier"); - if (serviceId == null) throw new ArgumentNullException("serviceId"); - if (profileIds == null) throw new ArgumentNullException("profileIds"); - if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); - if (profileRoleIdentifier == null) throw new ArgumentNullException("profileRoleIdentifier"); - if (profileIds.Count == 0) throw new ArgumentException("profileIds must contain at least one item"); - if (string.IsNullOrEmpty(profileConformanceClaim)) throw new ArgumentException("profileConformanceClaim cannot be null or empty"); + if (identifier == null) throw new ArgumentNullException("E-RSP16001: 'identifier' is null"); + if (serviceId == null) throw new ArgumentNullException("E-RSP16002: 'serviceId' is null"); + if (profileIds == null) throw new ArgumentNullException("E-RSP16003: 'profileIds' is null"); + if (acceptedTransportProtocols == null) throw new ArgumentNullException("E-RSP16004: 'acceptedTransportProtocols' is null"); + if (profileRoleIdentifier == null) throw new ArgumentNullException("E-RSP16005: 'profileRoleIdentifier' is null"); + if (profileIds.Count == 0) throw new ArgumentException("E-RSP16006: profileIds must contain at least one item"); + if (string.IsNullOrEmpty(profileConformanceClaim)) throw new ArgumentException("E-RSP16007: profileConformanceClaim cannot be null or empty"); Identifier = identifier; ServiceId = serviceId; @@ -95,13 +95,14 @@ namespace dk.gov.oiosi.uddi { List profileIds, List acceptedTransportProtocols, string profileRoleIdentifier) { - - if (identifier == null) throw new ArgumentNullException("identifier"); - if (serviceId == null) throw new ArgumentNullException("serviceId"); - if (profileIds == null) throw new ArgumentNullException("profileIds"); - if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); - if (profileRoleIdentifier == null) throw new ArgumentNullException("profileRoleIdentifier"); - if (profileIds.Count == 0) throw new ArgumentException("profileIds must contain at least one item"); + + + if (identifier == null) throw new ArgumentNullException("E-RSP16001: 'identifier' is null"); + if (serviceId == null) throw new ArgumentNullException("E-RSP16002: 'serviceId' is null"); + if (profileIds == null) throw new ArgumentNullException("E-RSP16003: 'profileIds' is null"); + if (acceptedTransportProtocols == null) throw new ArgumentNullException("E-RSP16004: 'acceptedTransportProtocols' is null"); + if (profileRoleIdentifier == null) throw new ArgumentNullException("E-RSP16005: 'profileRoleIdentifier' is null"); + if (profileIds.Count == 0) throw new ArgumentException("E-RSP16006: profileIds must contain at least one item"); Identifier = identifier; ServiceId = serviceId; @@ -125,11 +126,11 @@ namespace dk.gov.oiosi.uddi { List profileIds, List acceptedTransportProtocols) { - if (identifier == null) throw new ArgumentNullException("identifier"); - if (serviceId == null) throw new ArgumentNullException("serviceId"); - if (profileIds == null) throw new ArgumentNullException("profileIds"); - if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); - if (profileIds.Count == 0) throw new ArgumentException("profileIds must contain at least one item"); + if (identifier == null) throw new ArgumentNullException("E-RSP16001: 'identifier' is null"); + if (serviceId == null) throw new ArgumentNullException("E-RSP16002: 'serviceId' is null"); + if (profileIds == null) throw new ArgumentNullException("E-RSP16003: 'profileIds' is null"); + if (acceptedTransportProtocols == null) throw new ArgumentNullException("E-RSP16004: 'acceptedTransportProtocols' is null"); + if (profileIds.Count == 0) throw new ArgumentException("E-RSP16006: profileIds must contain at least one item"); Identifier = identifier; ServiceId = serviceId; @@ -150,10 +151,12 @@ namespace dk.gov.oiosi.uddi { UddiId serviceId, List acceptedTransportProtocols, string profileConformanceClaim) { - if (identifier == null) throw new ArgumentNullException("identifier"); - if (serviceId == null) throw new ArgumentNullException("serviceId"); - if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); - if (string.IsNullOrEmpty(profileConformanceClaim)) throw new ArgumentException("string profileConformanceClaim cannot be null or empty"); + + + if (identifier == null) throw new ArgumentNullException("E-RSP16001: 'identifier' is null"); + if (serviceId == null) throw new ArgumentNullException("E-RSP16002: 'serviceId' is null"); + if (acceptedTransportProtocols == null) throw new ArgumentNullException("E-RSP16004: 'acceptedTransportProtocols' is null"); + if (string.IsNullOrEmpty(profileConformanceClaim)) throw new ArgumentException("E-RSP16007: profileConformanceClaim cannot be null or empty"); Identifier = identifier; ServiceId = serviceId; @@ -174,9 +177,10 @@ namespace dk.gov.oiosi.uddi { List acceptedTransportProtocols) { // Test code call this one - if (identifier == null) throw new ArgumentNullException("identifier"); - if (serviceId == null) throw new ArgumentNullException("serviceId"); - if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); + + if (identifier == null) throw new ArgumentNullException("E-RSP16001: 'identifier' is null"); + if (serviceId == null) throw new ArgumentNullException("E-RSP16002: 'serviceId' is null"); + if (acceptedTransportProtocols == null) throw new ArgumentNullException("E-RSP16004: 'acceptedTransportProtocols' is null"); Identifier = identifier; ServiceId = serviceId; @@ -191,9 +195,8 @@ namespace dk.gov.oiosi.uddi { /// The identifier on the service (endpointKey and endpointKeyType) /// The accepted transport protocols (http, mail) public LookupParameters(Identifier identifier, List acceptedTransportProtocols) { - if (identifier == null) throw new ArgumentNullException("identifier"); - if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); - + if (identifier == null) throw new ArgumentNullException("E-RSP16001: 'identifier' is null"); + if (acceptedTransportProtocols == null) throw new ArgumentNullException("E-RSP16004: 'acceptedTransportProtocols' is null"); Identifier = identifier; AcceptedTransportProtocols = acceptedTransportProtocols; ProfileConformanceClaim = RASPPROFILECONFORMANCECLAIM; diff --git a/src/dk.gov.oiosi/uddi/ProcessRoleDefinition.cs b/src/dk.gov.oiosi/uddi/ProcessRoleDefinition.cs index 6100cba4970ef1aed895d077bb3c60ce2c771fbe..c1b9e4f8ccb19f3fffa614d0896ab6d47c0f48fd 100644 --- a/src/dk.gov.oiosi/uddi/ProcessRoleDefinition.cs +++ b/src/dk.gov.oiosi/uddi/ProcessRoleDefinition.cs @@ -20,11 +20,11 @@ namespace dk.gov.oiosi.uddi { /// Role type of the process information /// Identifier of the process information public ProcessRoleDefinition(string name, string description, string role, string roleType, UddiId processDefinitionId) { - if (string.IsNullOrEmpty(name)) throw new NullOrEmptyArgumentException("name"); - if (description == null) throw new NullArgumentException("description"); - if (role == null) throw new NullArgumentException("role"); - if (roleType == null) throw new NullArgumentException("roleType"); - if (processDefinitionId == null) throw new NullArgumentException("processDefinitionId"); + if (string.IsNullOrEmpty(name)) throw new NullOrEmptyArgumentException("name", "E-RSP16011"); + if (description == null) throw new NullArgumentException("description", "E-RSP16012"); + if (role == null) throw new NullArgumentException("role", "E-RSP16013"); + if (roleType == null) throw new NullArgumentException("roleType", "E-RSP16014"); + if (processDefinitionId == null) throw new NullArgumentException("processDefinitionId", "E-RSP16015"); Name = name; Description = description; Role = role; diff --git a/src/dk.gov.oiosi/uddi/RegistryLookupClientFactory.cs b/src/dk.gov.oiosi/uddi/RegistryLookupClientFactory.cs index 8e9df6fa35b16888167de2d8404ffd370e63812e..af172826d038e683060aa1606c06279b32bd13d3 100644 --- a/src/dk.gov.oiosi/uddi/RegistryLookupClientFactory.cs +++ b/src/dk.gov.oiosi/uddi/RegistryLookupClientFactory.cs @@ -52,14 +52,14 @@ namespace dk.gov.oiosi.uddi { // 2. Get the type to load: if (_config.ImplementationNamespaceClass == null || _config.ImplementationNamespaceClass == "") { - throw new UddiNoImplementingClassException(); } + throw new UddiNoImplementingClassException("E-RSP16021"); } if (_config.ImplementationAssembly == null || _config.ImplementationAssembly == "") { - throw new UddiNoImplementingAssemblyException(); } + throw new UddiNoImplementingAssemblyException("E-RSP16022"); } string qualifiedTypename = _config.ImplementationNamespaceClass + ", " + _config.ImplementationAssembly; Type lookupClientType = Type.GetType(qualifiedTypename); if (lookupClientType == null) { - throw new CouldNotLoadTypeException(qualifiedTypename); + throw new CouldNotLoadTypeException(qualifiedTypename, "E-RSP16023"); } // 3. Instantiate the type: diff --git a/src/dk.gov.oiosi/uddi/UddiBinding.cs b/src/dk.gov.oiosi/uddi/UddiBinding.cs index 6dc6051f92c19c9077303c607b812d29875a70f5..5a014e0f176ea23de4517c3460d44867185f2d18 100644 --- a/src/dk.gov.oiosi/uddi/UddiBinding.cs +++ b/src/dk.gov.oiosi/uddi/UddiBinding.cs @@ -12,8 +12,8 @@ namespace dk.gov.oiosi.uddi public UddiBinding(bindingTemplate template, List tModels) { - if (template == null) throw new ArgumentNullException("template"); - if (tModels == null) throw new ArgumentNullException("tModels"); + if (template == null) throw new ArgumentNullException("E-RSP16031: 'template' is null"); + if (tModels == null) throw new ArgumentNullException("E-RSP16032: 'tModels' is null"); this.template = template; Converter converter = delegate(tModel tmodel) { return new UddiTModel(tmodel); }; @@ -23,7 +23,7 @@ namespace dk.gov.oiosi.uddi public EndpointAddress GetEndpointAddress() { accessPoint accessPointItem = template.Item as accessPoint; - if (accessPointItem == null) throw new Exception("accessPoint type expected"); + if (accessPointItem == null) throw new Exception("E-RSP16033: accessPoint type expected"); return IdentifierUtility.GetEndpointAddressFromString(accessPointItem.Value); } diff --git a/src/dk.gov.oiosi/uddi/UddiCategoryBag.cs b/src/dk.gov.oiosi/uddi/UddiCategoryBag.cs index 83f2e1ac26575fef79c8df20c8162fa06c3b7ecd..3595662070dc3ed3e0aa082c82b620757828bee8 100644 --- a/src/dk.gov.oiosi/uddi/UddiCategoryBag.cs +++ b/src/dk.gov.oiosi/uddi/UddiCategoryBag.cs @@ -35,12 +35,12 @@ namespace dk.gov.oiosi.uddi { } public bool TryGetKeyedReference(string tModelKey, out keyedReference keyedRef) { - if (string.IsNullOrEmpty(tModelKey)) throw new ArgumentException("tModelKey"); + if (string.IsNullOrEmpty(tModelKey)) throw new ArgumentException("E-RSP16041: 'tModelKey' is null or empty"); return keyedReferenceBag.TryGetValue(tModelKey.ToLower(), out keyedRef); } public bool TryGetKeyedReferenceGroup(string tModelKey, out keyedReferenceGroup keyedRefGroup) { - if (string.IsNullOrEmpty(tModelKey)) throw new ArgumentException("tModelKey"); + if (string.IsNullOrEmpty(tModelKey)) throw new ArgumentException("E-RSP16041: 'tModelKey' is null or empty"); return keyedReferenceGroupBag.TryGetValue(tModelKey.ToLower(), out keyedRefGroup); } } diff --git a/src/dk.gov.oiosi/uddi/UddiEmptyGuidException.cs b/src/dk.gov.oiosi/uddi/UddiEmptyGuidException.cs index 1a5fcb3d26a3d140d00b5b90414b08227f3fdb50..f21840558d8091589eaf2ed387b8287d949b8750 100644 --- a/src/dk.gov.oiosi/uddi/UddiEmptyGuidException.cs +++ b/src/dk.gov.oiosi/uddi/UddiEmptyGuidException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.uddi /// /// Constructor /// - public UddiEmptyGuidException() : base() { } + public UddiEmptyGuidException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/uddi/UddiException.cs b/src/dk.gov.oiosi/uddi/UddiException.cs index 967fe0706da9c976cb529905f6995c0283e5bd52..df3a64d87dcb8eec33be406d7e9b158bdab5f65d 100644 --- a/src/dk.gov.oiosi/uddi/UddiException.cs +++ b/src/dk.gov.oiosi/uddi/UddiException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.uddi { /// /// Constructor /// - public UddiException() : base(resourceManager) { } + public UddiException(string errorCode = "") : base(resourceManager, errorCode) { } /// /// Constructor /// diff --git a/src/dk.gov.oiosi/uddi/UddiId.cs b/src/dk.gov.oiosi/uddi/UddiId.cs index cfdd918b86ddc52eb54415cc6190130408384b1d..e635a9ccf50dd4849be170f1f724976e2df3117f 100644 --- a/src/dk.gov.oiosi/uddi/UddiId.cs +++ b/src/dk.gov.oiosi/uddi/UddiId.cs @@ -53,7 +53,7 @@ namespace dk.gov.oiosi.uddi { /// The object to compare to /// Returns true if the two objects have identical values public bool Equals(UddiId other) { - if (ID == null) throw new NullArgumentException("ID in UddiId"); + if (ID == null) throw new NullArgumentException("ID in UddiId is null", "E-RSP16051"); if (other == null) return false; if (ID.Equals(other.ID, StringComparison.CurrentCultureIgnoreCase)) return true; return false; diff --git a/src/dk.gov.oiosi/uddi/UddiLookupClient.cs b/src/dk.gov.oiosi/uddi/UddiLookupClient.cs index 8d2b6806293491f63091c4c9d8f08d4903199a1d..4189b4ea230f1de86777e548cffb9e99c32aae64 100644 --- a/src/dk.gov.oiosi/uddi/UddiLookupClient.cs +++ b/src/dk.gov.oiosi/uddi/UddiLookupClient.cs @@ -89,7 +89,7 @@ namespace dk.gov.oiosi.uddi { // If this creation failed, it is possible that the library version in in configuration file must be update to current version. // Se configuration/system.serviceModel/extensions/behaviorExtensions/add[name="signCustomHeaders"] - this.logger.Error("Creation of lookup client failed. It is possible that you are missing the app.config file in your project, or the library version in in configuration file must be update to current version. configuration/system.serviceModel/extensions/behaviorExtensions/add[@name=signCustomHeaders)/@type=... RaspVersion: '"+ raspVersion + "'. Address: '" + (address!= null ? address.ToString() : string.Empty) + "'."); + this.logger.Error("E-RSP16064: Creation of lookup client failed. It is possible that you are missing the app.config file in your project, or the library version in in configuration file must be update to current version. configuration/system.serviceModel/extensions/behaviorExtensions/add[@name=signCustomHeaders)/@type=... RaspVersion: '" + raspVersion + "'. Address: '" + (address!= null ? address.ToString() : string.Empty) + "'."); throw; } } @@ -144,7 +144,7 @@ namespace dk.gov.oiosi.uddi { if (lookupParameters == null) { - throw new ArgumentNullException("lookupParameters"); + throw new ArgumentNullException("E-RSP16061: 'lookupParameters' is null"); } List supportedResponses = new List(); diff --git a/src/dk.gov.oiosi/uddi/UddiLookupClientFactory.cs b/src/dk.gov.oiosi/uddi/UddiLookupClientFactory.cs index 3419abc605152b9684f343f008954cfceabe6d24..d25fa0f0777172ea5c29450c871e6de319c44d93 100644 --- a/src/dk.gov.oiosi/uddi/UddiLookupClientFactory.cs +++ b/src/dk.gov.oiosi/uddi/UddiLookupClientFactory.cs @@ -56,12 +56,12 @@ namespace dk.gov.oiosi.uddi { // 2. Get the type to load: if (string.IsNullOrEmpty(_config.ImplementationNamespaceClass)) { - throw new UddiNoImplementingClassException(); + throw new UddiNoImplementingClassException("E-RSP16071"); } if (string.IsNullOrEmpty(_config.ImplementationAssembly)) { - throw new UddiNoImplementingAssemblyException(); + throw new UddiNoImplementingAssemblyException("E-RSP16072"); } string qualifiedTypename = _config.ImplementationNamespaceClass + ", " + _config.ImplementationAssembly; @@ -69,7 +69,7 @@ namespace dk.gov.oiosi.uddi { Type lookupClientType = Type.GetType(qualifiedTypename); if (lookupClientType == null) { - throw new CouldNotLoadTypeException(qualifiedTypename); + throw new CouldNotLoadTypeException(qualifiedTypename, "E-RSP16073"); } // 3. Instantiate the type: diff --git a/src/dk.gov.oiosi/uddi/UddiNoImplementingAssemblyException.cs b/src/dk.gov.oiosi/uddi/UddiNoImplementingAssemblyException.cs index e10996f3f395ac42b04f7537d9a71b4adfcd6362..aa60b01f56e81d5c58c15cb84a7ec1457e8e022c 100644 --- a/src/dk.gov.oiosi/uddi/UddiNoImplementingAssemblyException.cs +++ b/src/dk.gov.oiosi/uddi/UddiNoImplementingAssemblyException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.uddi /// /// Constructor /// - public UddiNoImplementingAssemblyException() : base() { } + public UddiNoImplementingAssemblyException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs b/src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs index e641cfe29d5a181a873e77054376ef380d052f32..4e8c0c6b02b96f97d07199fb9cbad5a47f126165 100644 --- a/src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs +++ b/src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs @@ -39,6 +39,6 @@ namespace dk.gov.oiosi.uddi /// /// Constructor /// - public UddiNoImplementingClassException() : base() { } + public UddiNoImplementingClassException(string errorCode = "") : base(errorCode) { } } } diff --git a/src/dk.gov.oiosi/uddi/UddiService.cs b/src/dk.gov.oiosi/uddi/UddiService.cs index 3c7dd1f418c584b17940a93f2c264c7a8163108e..809546b5311e96d4b539262ef4288701d3e3fb3b 100644 --- a/src/dk.gov.oiosi/uddi/UddiService.cs +++ b/src/dk.gov.oiosi/uddi/UddiService.cs @@ -23,8 +23,8 @@ namespace dk.gov.oiosi.uddi private readonly List bindings; public UddiService(businessService service, List uddiBindings) { - if (service == null) throw new ArgumentNullException("service"); - if (uddiBindings == null) throw new ArgumentNullException("uddiBindings"); + if (service == null) throw new ArgumentNullException("E-RSP16081: 'service' is null"); + if (uddiBindings == null) throw new ArgumentNullException("E-RSP16082: 'uddiBindings' is null"); this.service = service; this.categoryBag = new UddiCategoryBag(service.categoryBag); diff --git a/src/dk.gov.oiosi/uddi/UddiStringId.cs b/src/dk.gov.oiosi/uddi/UddiStringId.cs index e8b2aef699109283247832e1a3b30f92260f1d4d..6c078b3a7328596c1151c340aeafd5a12a53d46f 100644 --- a/src/dk.gov.oiosi/uddi/UddiStringId.cs +++ b/src/dk.gov.oiosi/uddi/UddiStringId.cs @@ -22,8 +22,8 @@ namespace dk.gov.oiosi.uddi { /// uddi id /// is it uddi type public UddiStringId(string id, bool isUddiType) { - if (String.IsNullOrEmpty(id)) throw new NullOrEmptyArgumentException("id"); - if (id.Length < 10) throw new UnexpectedNumberOfCharactersException("id", 10); + if (String.IsNullOrEmpty(id)) throw new NullOrEmptyArgumentException("id", "E-RSP16091"); + if (id.Length < 10) throw new UnexpectedNumberOfCharactersException("id", 10, "E-RSP16092"); if (isUddiType) { _noUddiPrefix = id.Substring(5); } else { @@ -37,7 +37,7 @@ namespace dk.gov.oiosi.uddi { /// guid public UddiStringId(Guid guid) { if (guid == Guid.Empty) { - throw new UddiEmptyGuidException(); + throw new UddiEmptyGuidException("E-RSP16093"); } _noUddiPrefix = guid.ToString(); } diff --git a/src/dk.gov.oiosi/uddi/UddiTModel.cs b/src/dk.gov.oiosi/uddi/UddiTModel.cs index 469ff43632dea4c767ad26b1f4322af449edb006..0723a604a91832d61539eb32285a8ecbf8126223 100644 --- a/src/dk.gov.oiosi/uddi/UddiTModel.cs +++ b/src/dk.gov.oiosi/uddi/UddiTModel.cs @@ -21,7 +21,7 @@ namespace dk.gov.oiosi.uddi private readonly UddiCategoryBag categoryBag; public UddiTModel(tModel tModel) { - if (tModel == null) throw new ArgumentNullException("tModel"); + if (tModel == null) throw new ArgumentNullException("E-RSP16094: 'tModel' is null"); this.tModel= tModel; this.categoryBag = new UddiCategoryBag(tModel.categoryBag); diff --git a/src/dk.gov.oiosi/xml/UrlToLocalFilelResolver.cs b/src/dk.gov.oiosi/xml/UrlToLocalFilelResolver.cs index cad13b3d426c6823593cd648baa97aeff1a89ce3..52f3ded7d88546a1b5326c23186a9dced2967126 100644 --- a/src/dk.gov.oiosi/xml/UrlToLocalFilelResolver.cs +++ b/src/dk.gov.oiosi/xml/UrlToLocalFilelResolver.cs @@ -103,7 +103,7 @@ namespace dk.gov.oiosi.xml baseUriString = baseUri.LocalPath; } - this.logger.Warn("The resource identified by the relative uri '" + relativeUri + "' and the baseUri '" + baseUriString + "' and base path '" + this.basePathForResources + "' could not be located. The resource was not found."); + this.logger.Warn("W-RSP15701: The resource identified by the relative uri '" + relativeUri + "' and the baseUri '" + baseUriString + "' and base path '" + this.basePathForResources + "' could not be located. The resource was not found."); } } diff --git a/src/dk.gov.oiosi/xml/XmlException.cs b/src/dk.gov.oiosi/xml/XmlException.cs index 035971fefad9f93b2a6d8f1b050b2c5cbe1b64cb..ac9eea5012f8473575469acb9384384c1d09d6df 100644 --- a/src/dk.gov.oiosi/xml/XmlException.cs +++ b/src/dk.gov.oiosi/xml/XmlException.cs @@ -51,7 +51,7 @@ namespace dk.gov.oiosi.xml { /// Constructor with keywords /// /// keywords for the message - public XmlException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public XmlException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Constructor with innerexception @@ -64,6 +64,6 @@ namespace dk.gov.oiosi.xml { /// /// keywords for the message /// innerexception of the thrown exception - public XmlException(System.Collections.Generic.Dictionary keywords, System.Exception innerException) : base(resourceManager, keywords, innerException) { } + public XmlException(System.Collections.Generic.Dictionary keywords, System.Exception innerException, string errorCode = "") : base(resourceManager, keywords, innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/xml/documentType/AmbiguousDocumentTypeFoundFromXmlDocumentException.cs b/src/dk.gov.oiosi/xml/documentType/AmbiguousDocumentTypeFoundFromXmlDocumentException.cs index 9df1a8cec0fcc48bf68ef96fd4ab722057561829..32fd29bbe13e31e0ca62e67c454785034325f16e 100644 --- a/src/dk.gov.oiosi/xml/documentType/AmbiguousDocumentTypeFoundFromXmlDocumentException.cs +++ b/src/dk.gov.oiosi/xml/documentType/AmbiguousDocumentTypeFoundFromXmlDocumentException.cs @@ -47,6 +47,6 @@ namespace dk.gov.oiosi.xml.documentType { /// Constructor /// /// The xml document from which to find a configuration - public AmbiguousDocumentTypeFoundFromXmlDocumentException(XmlDocument xmlDocument) : base(errorMessages, KeywordFromXmlDocument.GetKeywords(xmlDocument)) { } + public AmbiguousDocumentTypeFoundFromXmlDocumentException(XmlDocument xmlDocument, string errorCode = "") : base(errorMessages, KeywordFromXmlDocument.GetKeywords(xmlDocument), errorCode) { } } } diff --git a/src/dk.gov.oiosi/xml/documentType/DocumentTypeConfigSearcher.cs b/src/dk.gov.oiosi/xml/documentType/DocumentTypeConfigSearcher.cs index dc785a2403869ab651ea7aa0f68fcfe8c4d81dcb..7f31356ca1233aaeab70d92218604ba37de97e09 100644 --- a/src/dk.gov.oiosi/xml/documentType/DocumentTypeConfigSearcher.cs +++ b/src/dk.gov.oiosi/xml/documentType/DocumentTypeConfigSearcher.cs @@ -63,7 +63,7 @@ namespace dk.gov.oiosi.xml.documentType { { if (document == null) { - throw new NullArgumentException("document"); + throw new NullArgumentException("E-RSP15101: 'document' is null"); } try @@ -71,18 +71,18 @@ namespace dk.gov.oiosi.xml.documentType { DocumentTypeConfig documentType; if (!TryFindUniqueDocumentType(document, out documentType)) { - throw new NoDocumentTypeFoundFromXmlDocumentException(document); + throw new NoDocumentTypeFoundFromXmlDocumentException(document, "E-RSP15102"); } return documentType; } - catch (NoDocumentTypeFoundFromXmlDocumentException ex) + catch (NoDocumentTypeFoundFromXmlDocumentException) { - throw ex; + throw; } catch (Exception ex) { - throw new SearchForDocumentTypeFromXmlDocumentFailedException(document, ex); + throw new SearchForDocumentTypeFromXmlDocumentFailedException(document, ex, "E-RSP15103"); } } @@ -99,7 +99,7 @@ namespace dk.gov.oiosi.xml.documentType { { if (document == null) { - throw new NullArgumentException("document"); + throw new NullArgumentException("E-RSP15101: 'document' is null"); } documentType = null; @@ -111,7 +111,7 @@ namespace dk.gov.oiosi.xml.documentType { List currentDocumentTypes = allDocumentTypes.FindAll(isDocumentType); if (currentDocumentTypes.Count > 1) { - throw new AmbiguousDocumentTypeFoundFromXmlDocumentException(document); + throw new AmbiguousDocumentTypeFoundFromXmlDocumentException(document, "E-RSP15104"); } if (currentDocumentTypes.Count < 1) { diff --git a/src/dk.gov.oiosi/xml/documentType/NoDocumentTypeFoundFromXmlDocumentException.cs b/src/dk.gov.oiosi/xml/documentType/NoDocumentTypeFoundFromXmlDocumentException.cs index 8f37bc34d46f7921e62de91b9dc7db2be2c0705f..90350a2c4edd1b30e2ca17fae190b7c8152e879f 100644 --- a/src/dk.gov.oiosi/xml/documentType/NoDocumentTypeFoundFromXmlDocumentException.cs +++ b/src/dk.gov.oiosi/xml/documentType/NoDocumentTypeFoundFromXmlDocumentException.cs @@ -48,6 +48,6 @@ namespace dk.gov.oiosi.xml.documentType { /// Constructor /// /// The XML document - public NoDocumentTypeFoundFromXmlDocumentException(XmlDocument xmlDocument) : base(errorMessages, KeywordFromXmlDocument.GetKeywords(xmlDocument)) { } + public NoDocumentTypeFoundFromXmlDocumentException(XmlDocument xmlDocument, string errorCode = "") : base(errorMessages, KeywordFromXmlDocument.GetKeywords(xmlDocument), errorCode) { } } } diff --git a/src/dk.gov.oiosi/xml/documentType/SearchForDocumentTypeFromXmlDocumentFailedException.cs b/src/dk.gov.oiosi/xml/documentType/SearchForDocumentTypeFromXmlDocumentFailedException.cs index 0e6bc0d350dbe5529166dd3311abc1b68e61dc85..ba30f9a103eb72b5937da3da0a83d482d6c2dfae 100644 --- a/src/dk.gov.oiosi/xml/documentType/SearchForDocumentTypeFromXmlDocumentFailedException.cs +++ b/src/dk.gov.oiosi/xml/documentType/SearchForDocumentTypeFromXmlDocumentFailedException.cs @@ -46,6 +46,6 @@ namespace dk.gov.oiosi.xml.documentType { /// /// The xml document for which the search was performed /// The inner exception - public SearchForDocumentTypeFromXmlDocumentFailedException(XmlDocument xmlDocument, Exception innerException) : base(KeywordFromXmlDocument.GetKeywords(xmlDocument), innerException) { } + public SearchForDocumentTypeFromXmlDocumentFailedException(XmlDocument xmlDocument, Exception innerException, string errorCode = "") : base(KeywordFromXmlDocument.GetKeywords(xmlDocument), innerException, errorCode) { } } } diff --git a/src/dk.gov.oiosi/xml/schema/SchemaStore.cs b/src/dk.gov.oiosi/xml/schema/SchemaStore.cs index 13a75f14e5a08d690f3647fcc19d7b2a576c0d35..cebb39d8114cdf8c493d97f5079631259e82b159 100644 --- a/src/dk.gov.oiosi/xml/schema/SchemaStore.cs +++ b/src/dk.gov.oiosi/xml/schema/SchemaStore.cs @@ -156,7 +156,7 @@ namespace dk.gov.oiosi.xml.schema } catch (Exception ex) { - throw new FailedToLoadSchemaException(schemaFile, ex); + throw new FailedToLoadSchemaException(schemaFile, ex, "E-RSP15201"); } finally { @@ -238,7 +238,7 @@ namespace dk.gov.oiosi.xml.schema if (documentNamespace != expectedNamespace) { - throw new UnexpectedNamespaceException(documentNamespace, expectedNamespace); + throw new UnexpectedNamespaceException(documentNamespace, expectedNamespace, "E-RSP15202"); } } diff --git a/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs b/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs index fe9eba5078c8ff24f237bed7942358d97276d166..43a1ee8f5fc55aecff87ee5cc2d1c6c9936f87e3 100644 --- a/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs +++ b/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs @@ -50,19 +50,19 @@ namespace dk.gov.oiosi.xml.schema /// Constructor with keywords /// /// keyword for the message - public SchemaValidationException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public SchemaValidationException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Constructor with innerexception /// /// innerexception of the thrown exception - public SchemaValidationException(System.Exception innerException) : base(resourceManager, innerException) { } + public SchemaValidationException(System.Exception innerException, string errorCode = "") : base(resourceManager, innerException, errorCode) { } /// /// Constructor with keywords and innerexception /// /// keyword for the message /// innerexception of the thrown exception - public SchemaValidationException(System.Collections.Generic.Dictionary keywords, System.Exception innerException) : base(resourceManager, keywords, innerException) { } + public SchemaValidationException(System.Collections.Generic.Dictionary keywords, System.Exception innerException, string errorCode = "") : base(resourceManager, keywords, innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/xml/schema/SchemaValidationFailedException.cs b/src/dk.gov.oiosi/xml/schema/SchemaValidationFailedException.cs index b80d83d6e2ab9a3f4dc8a9efe607ebdf4c29e03b..b3b06c4617d28d1f83b3ce4104949537a7bd0ea1 100644 --- a/src/dk.gov.oiosi/xml/schema/SchemaValidationFailedException.cs +++ b/src/dk.gov.oiosi/xml/schema/SchemaValidationFailedException.cs @@ -48,8 +48,12 @@ namespace dk.gov.oiosi.xml.schema /// /// the schema /// innerexception of the thrown exception - public SchemaValidationFailedException(XmlDocument document, Exception innerException) - : base(XmlDocumentKeywords.GetKeywords(document), innerException) + public SchemaValidationFailedException(XmlDocument document, Exception innerException, string errorCode = "") + : base(XmlDocumentKeywords.GetKeywords(document), innerException, errorCode) + { } + + public SchemaValidationFailedException(Exception innerException, string errorCode = "") + : base(innerException, errorCode) { } /// diff --git a/src/dk.gov.oiosi/xml/schema/SchemaValidator.cs b/src/dk.gov.oiosi/xml/schema/SchemaValidator.cs index a3db83d66d15b109d42722d5587989d456d359dc..b338ca200eafaa464a1c7667e1007e4344e8d249 100644 --- a/src/dk.gov.oiosi/xml/schema/SchemaValidator.cs +++ b/src/dk.gov.oiosi/xml/schema/SchemaValidator.cs @@ -118,13 +118,13 @@ namespace dk.gov.oiosi.xml.schema { } } } - catch (SchemaValidateDocumentFailedException) + catch (SchemaValidateDocumentFailedException ex) { - throw; + throw new SchemaValidateDocumentFailedException(ex, "E-RSP15211"); } catch (Exception ex) { - throw new SchemaValidationFailedException(xmlDocument, ex); + throw new SchemaValidationFailedException(xmlDocument, ex, "E-RSP15212"); } } diff --git a/src/dk.gov.oiosi/xml/schema/UnexpectedNamespaceException.cs b/src/dk.gov.oiosi/xml/schema/UnexpectedNamespaceException.cs index 46a3326da5bc1a4ee994547977e18a743a83fa15..863d8a18f124f032836b77e8c13c5eecf7a69df5 100644 --- a/src/dk.gov.oiosi/xml/schema/UnexpectedNamespaceException.cs +++ b/src/dk.gov.oiosi/xml/schema/UnexpectedNamespaceException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.xml.schema /// /// namespace in the document /// the expected namespace - public UnexpectedNamespaceException(string documentNamespace, string expectedNamespace) : base(GetKeywords(documentNamespace, expectedNamespace)) { } + public UnexpectedNamespaceException(string documentNamespace, string expectedNamespace, string errorCode = "") : base(GetKeywords(documentNamespace, expectedNamespace), errorCode) { } /// /// Gets keywords diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronErrorException.cs b/src/dk.gov.oiosi/xml/schematron/SchematronErrorException.cs index 0f93df9c2b428fd8b8201b142978984a98f934c8..67a75928541715d7789c1db50889bfd7e2bf88ed 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronErrorException.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronErrorException.cs @@ -54,7 +54,7 @@ namespace dk.gov.oiosi.xml.schematron /// /// The schematron result /// The first error message - public SchematronErrorException(XmlDocument schematronResult, string firstErrorMessage) : base(KeywordFromString.GetKeyword("schematronerror", firstErrorMessage)) { + public SchematronErrorException(XmlDocument schematronResult, string firstErrorMessage, string errorCode = "") : base(KeywordFromString.GetKeyword("schematronerror", firstErrorMessage), errorCode) { _schematronResult = schematronResult; } } diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronStore.cs b/src/dk.gov.oiosi/xml/schematron/SchematronStore.cs index 252b7650797ff60201cc05165ce9e14882cc80fa..3a6168e60e09972fec3a39ab3eac6ab908988d3d 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronStore.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronStore.cs @@ -52,7 +52,7 @@ namespace dk.gov.oiosi.xml.schematron { { if (path == null) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException("E-RSP15301: 'path' is null"); } string cacheKey = path; diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronValidationConfig.cs b/src/dk.gov.oiosi/xml/schematron/SchematronValidationConfig.cs index 015c39f29cbc43a9ab6132eb124d6ca85283b9a7..c93b93c5290513dcf4e623a40968f4d4062dc060 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronValidationConfig.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronValidationConfig.cs @@ -59,9 +59,9 @@ namespace dk.gov.oiosi.xml.schematron { /// The error xpath /// The error message xpath public SchematronValidationConfig(string schematronDocumentPath, string errorXPath, string errorMessageXPath) { - if (schematronDocumentPath == null) throw new NullArgumentException("schematronDocumentPath"); - if (errorXPath == null) throw new NullArgumentException("errorXPath"); - if (errorMessageXPath == null) throw new NullArgumentException("errorMessageXPath"); + if (schematronDocumentPath == null) throw new NullArgumentException("'schematronDocumentPath' is null", "E-RSP15311"); + if (errorXPath == null) throw new NullArgumentException("'errorXPath' is null", "E-RSP15312"); + if (errorMessageXPath == null) throw new NullArgumentException("'errorMessageXPath' is null", "E-RSP15313"); _schematronDocumentPath = schematronDocumentPath; _errorXPath = errorXPath; _errorMessageXPath = errorMessageXPath; @@ -73,7 +73,7 @@ namespace dk.gov.oiosi.xml.schematron { public string SchematronDocumentPath { get { return _schematronDocumentPath; } set { - if (value == null) throw new NullArgumentException("SchematronDocumentPath.value"); + if (value == null) throw new NullArgumentException("'SchematronDocumentPath.value' can not be set to null", "E-RSP15314"); _schematronDocumentPath = value; } } @@ -85,7 +85,7 @@ namespace dk.gov.oiosi.xml.schematron { public string ErrorXPath { get { return _errorXPath; } set { - if (value == null) throw new NullArgumentException("ErrorXPath.value"); + if (value == null) throw new NullArgumentException("'ErrorXPath.value' can not be set to null", "E-RSP15315"); _errorXPath = value; } } @@ -97,7 +97,7 @@ namespace dk.gov.oiosi.xml.schematron { public string ErrorMessageXPath { get { return _errorMessageXPath; } set { - if (value == null) throw new NullArgumentException("ErrorMessageXPath.value"); + if (value == null) throw new NullArgumentException("'ErrorMessageXPath.value' can not be set to null", "E-RSP15316"); _errorMessageXPath = value; } } @@ -123,7 +123,7 @@ namespace dk.gov.oiosi.xml.schematron { _schematronDocument = xmlDocument; } catch (Exception ex) { - throw new Exception("Failed to load schematron document", ex); + throw new Exception("E-RSP15317: Failed to load schematron document", ex); } } } diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs b/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs index 28af8dc2c1ee4ef1f32ae91dbde3fe210a0088db..05a16b70b738ded1e8fb480a5658331d94f66628 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs @@ -53,7 +53,7 @@ namespace dk.gov.oiosi.xml.schematron { /// Constructor with keywords /// /// keywords for the message - public SchematronValidationException(System.Collections.Generic.Dictionary keywords) : base(resourceManager, keywords) { } + public SchematronValidationException(System.Collections.Generic.Dictionary keywords, string errorCode = "") : base(resourceManager, keywords, errorCode) { } /// /// Constructor with innerexception @@ -66,6 +66,6 @@ namespace dk.gov.oiosi.xml.schematron { /// /// keywords for the message /// innerexception of the thrown exception - public SchematronValidationException(System.Collections.Generic.Dictionary keywords, System.Exception innerException) : base(resourceManager, keywords, innerException) { } + public SchematronValidationException(System.Collections.Generic.Dictionary keywords, System.Exception innerException, string errorCode = "") : base(resourceManager, keywords, innerException, errorCode) { } } } \ No newline at end of file diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronValidationFailedException.cs b/src/dk.gov.oiosi/xml/schematron/SchematronValidationFailedException.cs index e134836a582a14c56e470e2459196b39a72caa2c..1f9fafb201e3c379082e943f43b7a94762469c1d 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronValidationFailedException.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronValidationFailedException.cs @@ -47,8 +47,8 @@ namespace dk.gov.oiosi.xml.schematron /// /// the current document /// innerexception of the thrown exception - public SchematronValidationFailedException(XmlDocument document, Exception innerException) - : base(XmlDocumentKeywords.GetKeywords(document), innerException) + public SchematronValidationFailedException(XmlDocument document, Exception innerException, string errorCode = "") + : base(XmlDocumentKeywords.GetKeywords(document), innerException, errorCode) { } /// diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronValidator.cs b/src/dk.gov.oiosi/xml/schematron/SchematronValidator.cs index 9c92ce00f4f3dd9f942799075b782bcf9f286480..6c7f2c6e96cc00d2a55ab7adc99b0cbedf8b88e6 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronValidator.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronValidator.cs @@ -115,15 +115,15 @@ namespace dk.gov.oiosi.xml.schematron { if (this.compiledXsltEntry == null) { - throw new Exception("No schematron document is set"); + throw new Exception("E-RSP15321: No schematron document is set"); } if (this.errorXPath == null) { - throw new Exception("No error XPath is set"); + throw new Exception("E-RSP15322: No error XPath is set"); } if (this.errorMessageXPath == null) { - throw new Exception("No error message XPath is set"); + throw new Exception("E-RSP15323: No error message XPath is set"); } this.SchematronValidateXmlDocument(xmlDocument, this.compiledXsltEntry); @@ -138,11 +138,11 @@ namespace dk.gov.oiosi.xml.schematron { if (this.errorXPath == null) { - throw new Exception("No error XPath is set"); + throw new Exception("E-RSP15322: No error XPath is set"); } if (this.errorMessageXPath == null) { - throw new Exception("No error message XPath is set"); + throw new Exception("E-RSP15323: No error message XPath is set"); } bool documentValidated = false; @@ -238,19 +238,19 @@ namespace dk.gov.oiosi.xml.schematron catch (Exception ex) { Debug.Fail(ex.Message); - throw new SchematronValidationFailedException(xmlDocument, ex); + throw new SchematronValidationFailedException(xmlDocument, ex, "E-RSP15324"); } } if (documentValidated == false) { - throw new SchematronValidationFailedException(xmlDocument, new Exception("Failed to validate the document.")); + throw new SchematronValidationFailedException(xmlDocument, new Exception("Failed to validate the document."), "E-RSP15324"); } if (hasAnyErrors) { string firstErrorMessage = DocumentXPathResolver.GetFirstElementValueByXPath(schematronResultXmlDocument, this.errorMessageXPath, prefixedNamespaces); - throw new SchematronErrorException(schematronResultXmlDocument, firstErrorMessage); + throw new SchematronErrorException(schematronResultXmlDocument, firstErrorMessage, "E-RSP15325"); } else { @@ -361,11 +361,11 @@ namespace dk.gov.oiosi.xml.schematron { if (this.errorXPath == null) { - throw new Exception("No error XPath is set"); + throw new Exception("E-RSP15322: No error XPath is set"); } if (this.errorMessageXPath == null) { - throw new Exception("No error message XPath is set"); + throw new Exception("E-RSP15323: No error message XPath is set"); } XmlDocument schematronResultXmlDocument = null; @@ -492,7 +492,7 @@ namespace dk.gov.oiosi.xml.schematron Debug.Fail(ex.Message); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(documentAsString.ToStream()); - throw new SchematronValidationFailedException(xmlDocument, ex); + throw new SchematronValidationFailedException(xmlDocument, ex, "E-RSP15324"); } } @@ -500,13 +500,13 @@ namespace dk.gov.oiosi.xml.schematron { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(documentAsString.ToStream()); - throw new SchematronValidationFailedException(xmlDocument, new Exception("Failed to validate the document.")); + throw new SchematronValidationFailedException(xmlDocument, new Exception("Failed to validate the document."), "E-RSP15324"); } if (hasAnyErrors) { string firstErrorMessage = DocumentXPathResolver.GetFirstElementValueByXPath(schematronResultXmlDocument, this.errorMessageXPath, prefixedNamespaces); - throw new SchematronErrorException(schematronResultXmlDocument, firstErrorMessage); + throw new SchematronErrorException(schematronResultXmlDocument, firstErrorMessage, "E-RSP15325"); } else { diff --git a/src/dk.gov.oiosi/xml/xpath/DocumentXPathResolver.cs b/src/dk.gov.oiosi/xml/xpath/DocumentXPathResolver.cs index 287836817468712a481008530be8489f96227c4f..b96ea910bc3c7f300135852fc434cf736a39bd8b 100644 --- a/src/dk.gov.oiosi/xml/xpath/DocumentXPathResolver.cs +++ b/src/dk.gov.oiosi/xml/xpath/DocumentXPathResolver.cs @@ -86,8 +86,8 @@ namespace dk.gov.oiosi.xml.xpath XmlNodeList nodes = GetNodes(xmlDocument, xpath, prefixedNamespaces); //Check whether the contrains are followed int nodesCount = nodes.Count; - if (nodesCount < 1) throw new NoXPathResultsException(xpath); - if (nodesCount > 1) throw new TooManyXpathResultsException(xpath, nodesCount); + if (nodesCount < 1) throw new NoXPathResultsException(xpath, "E-RSP15401"); + if (nodesCount > 1) throw new TooManyXpathResultsException(xpath, nodesCount, "E-RSP15402"); XmlNode node = nodes[0]; return node.InnerText; } @@ -109,8 +109,8 @@ namespace dk.gov.oiosi.xml.xpath { string[] lineIter = DocumentXPathResolver.GetXPathValues(xmlDocument, xpath, prefixedNamespaces); int nodesCount = lineIter.Length; - if (nodesCount < 1) throw new NoXPathResultsException(xpath); - if (nodesCount > 1) throw new TooManyXpathResultsException(xpath, nodesCount); + if (nodesCount < 1) throw new NoXPathResultsException(xpath, "E-RSP15401"); + if (nodesCount > 1) throw new TooManyXpathResultsException(xpath, nodesCount, "E-RSP15402"); result = lineIter[0]; } @@ -135,7 +135,7 @@ namespace dk.gov.oiosi.xml.xpath CheckParameters(xmlDocument, xpath, prefixedNamespaces); string value = null; if (!TryGetFirstElementValueByXPath(xmlDocument, xpath, prefixedNamespaces, out value)) - throw new NoXPathResultsException(xpath); + throw new NoXPathResultsException(xpath, "E-RSP15401"); return value; } @@ -233,12 +233,12 @@ namespace dk.gov.oiosi.xml.xpath ) { if (String.IsNullOrEmpty(xpath)) - throw new NullOrEmptyArgumentException("xpath"); + throw new NullOrEmptyArgumentException("'xpath' is null or empty", "E-RSP15403"); if (xmlDocument == null) - throw new NullArgumentException("xmlDocument"); + throw new NullArgumentException("'xmlDocument' is null", "E-RSP15404"); if (prefixedNamespaces == null) - throw new NullArgumentException("prefixedNamespaces"); - if (xpath.Trim().Length <= 1) throw new XPathSizeTooSmallException(xpath); + throw new NullArgumentException("'prefixedNamespaces' is null", "E-RSP15405"); + if (xpath.Trim().Length <= 1) throw new XPathSizeTooSmallException(xpath, "E-RSP15406"); } private static void CheckParameters( @@ -247,9 +247,9 @@ namespace dk.gov.oiosi.xml.xpath ) { if (xmlDocument == null) - throw new NullArgumentException("xmlDocument"); + throw new NullArgumentException("'xmlDocument' is null", "E-RSP15404"); if (prefixedNamespaces == null) - throw new NullArgumentException("prefixedNamespaces"); + throw new NullArgumentException("'prefixedNamespaces' is null", "E-RSP15405"); } private static XmlNodeList GetNodes( diff --git a/src/dk.gov.oiosi/xml/xpath/NoXPathResultsException.cs b/src/dk.gov.oiosi/xml/xpath/NoXPathResultsException.cs index aa1484332d283811df604ed91437a11d0a4ea435..64ff2fbb35de188e4f08d4ec6b36b6e72b118071 100644 --- a/src/dk.gov.oiosi/xml/xpath/NoXPathResultsException.cs +++ b/src/dk.gov.oiosi/xml/xpath/NoXPathResultsException.cs @@ -43,7 +43,7 @@ namespace dk.gov.oiosi.xml.xpath { /// Constructor /// /// xpath used - public NoXPathResultsException(string xpath) : base(GetKeywords(xpath)) { } + public NoXPathResultsException(string xpath, string errorCode = "") : base(GetKeywords(xpath), errorCode) { } private static Dictionary GetKeywords(string xpath) { Dictionary keywords = new Dictionary(); diff --git a/src/dk.gov.oiosi/xml/xpath/TooManyXpathResultsException.cs b/src/dk.gov.oiosi/xml/xpath/TooManyXpathResultsException.cs index a20812a12ad03a4afde76ae5ee6305afa015abbc..582d304c2ef8135ac05df0a4a0377117dbd1758c 100644 --- a/src/dk.gov.oiosi/xml/xpath/TooManyXpathResultsException.cs +++ b/src/dk.gov.oiosi/xml/xpath/TooManyXpathResultsException.cs @@ -44,7 +44,7 @@ namespace dk.gov.oiosi.xml.xpath { /// /// the used xpath /// number of results - public TooManyXpathResultsException(string xpath, int count) : base(GetKeywords(xpath, count)) { } + public TooManyXpathResultsException(string xpath, int count, string errorCode = "") : base(GetKeywords(xpath, count), errorCode) { } private static Dictionary GetKeywords(string xpath, int count) { Dictionary keywords = new Dictionary(); diff --git a/src/dk.gov.oiosi/xml/xpath/XPathSizeTooSmallException.cs b/src/dk.gov.oiosi/xml/xpath/XPathSizeTooSmallException.cs index 3222e10af83f5ce6ab3d21dbe5f262dce1ae9d38..178acce12ff49a487bc0c276e4e684fa6369366d 100644 --- a/src/dk.gov.oiosi/xml/xpath/XPathSizeTooSmallException.cs +++ b/src/dk.gov.oiosi/xml/xpath/XPathSizeTooSmallException.cs @@ -41,7 +41,7 @@ namespace dk.gov.oiosi.xml.xpath { /// XPathSizeTooSmallException constructor /// /// - public XPathSizeTooSmallException(string xpath) : base(GetXPath(xpath)) { } + public XPathSizeTooSmallException(string xpath, string errorCode = "") : base(GetXPath(xpath), errorCode) { } private static Dictionary GetXPath(string xpath) { Dictionary keywords = new Dictionary();