From f95672ac51439b8e044d4a4087b55adf1927360e Mon Sep 17 00:00:00 2001 From: "kristian.teddy" Date: Thu, 18 Feb 2021 09:44:21 +0100 Subject: [PATCH 1/6] Initial push --- MSBuild.build.bat | 9 ++++++ MSBuild.build.xml | 31 +++++++++++++++++++ MSBuild.build_Debug.log | 19 ++++++++++++ MSBuild.build_Release.log | 19 ++++++++++++ build.xml | 10 ++++-- src/dk.gov.oiosi/addressing/Identifier.cs | 6 ++-- .../common/ErrorMessages.Designer.cs | 4 +-- src/dk.gov.oiosi/common/ErrorMessages.resx | 6 ++-- .../common/ExternalCodeFactory.cs | 9 +++--- src/dk.gov.oiosi/common/IdentifierUtility.cs | 2 +- .../common/cache/QuantityCache.cs | 24 +++++++------- src/dk.gov.oiosi/common/cache/TimedCache.cs | 12 +++---- .../uddi/ErrorMessages.Designer.cs | 11 ++++++- src/dk.gov.oiosi/uddi/ErrorMessages.resx | 7 +++-- src/dk.gov.oiosi/uddi/LookupParameters.cs | 2 +- 15 files changed, 133 insertions(+), 38 deletions(-) create mode 100644 MSBuild.build.bat create mode 100644 MSBuild.build.xml create mode 100644 MSBuild.build_Debug.log create mode 100644 MSBuild.build_Release.log diff --git a/MSBuild.build.bat b/MSBuild.build.bat new file mode 100644 index 00000000..94acfa84 --- /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 00000000..a864eb0f --- /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 00000000..9d48093f --- /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 00000000..72fda286 --- /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 f543479e..765de01a 100644 --- a/build.xml +++ b/build.xml @@ -3,7 +3,9 @@ - + + + @@ -44,8 +46,10 @@ - - + + + + diff --git a/src/dk.gov.oiosi/addressing/Identifier.cs b/src/dk.gov.oiosi/addressing/Identifier.cs index 21d0277b..f8070010 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/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs index 94faea5e..1866e14b 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-RSP32015: 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 1e0a379d..df7717a2 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-RSP32015: 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 001bf1b0..8c7b2319 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-RSP32011: '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-RSP32012: 'implementationNamespaceClass' is null"); + if (implementationAssembly == null) throw new NullArgumentException("E-RSP32013: '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-RSP32014: '{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-RSP32015 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 1914e570..c6c9a7c1 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/cache/QuantityCache.cs b/src/dk.gov.oiosi/common/cache/QuantityCache.cs index a2c27576..2fadf58d 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-RSP32021: 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-RSP32022: 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-RSP32023: 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-RSP32024: 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-RSP32025: '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-RSP32026: '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-RSP32025: '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-RSP32025: '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-RSP32025: '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-RSP32025: '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-RSP32025: '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 43a1fec8..2747dfee 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-RSP32031: 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-RSP32031: 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-RSP32032: 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-RSP32032: 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-RSP32033: 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-RSP32034: 'key' is null"); } else { diff --git a/src/dk.gov.oiosi/uddi/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/uddi/ErrorMessages.Designer.cs index 2eb68406..11564dd6 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 838287e7..6cf4e534 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 33a6c644..517758d1 100644 --- a/src/dk.gov.oiosi/uddi/LookupParameters.cs +++ b/src/dk.gov.oiosi/uddi/LookupParameters.cs @@ -65,7 +65,7 @@ namespace dk.gov.oiosi.uddi { string profileRoleIdentifier, string profileConformanceClaim) { - if (identifier == null) throw new ArgumentNullException("identifier"); + if (identifier == null) throw new PO("identifier"); if (serviceId == null) throw new ArgumentNullException("serviceId"); if (profileIds == null) throw new ArgumentNullException("profileIds"); if (acceptedTransportProtocols == null) throw new ArgumentNullException("acceptedTransportProtocols"); -- GitLab From 8f64b5274ea56f267011aa14e68af8958e357d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20S=C3=B8rensen-Boll?= Date: Mon, 22 Feb 2021 18:20:54 +0100 Subject: [PATCH 2/6] Added errorcodes to all exceptions thrown in dk.gov.oiosi --- src/dk.gov.oiosi.exception/MainException.cs | 51 +- .../NullArgumentException.cs | 3 +- .../NullOrEmptyArgumentException.cs | 3 +- .../UnexpectedNumberOfCharactersException.cs | 2 +- .../common/CouldNotLoadTypeException.cs | 3 +- .../common/ErrorMessages.Designer.cs | 2 +- src/dk.gov.oiosi/common/ErrorMessages.resx | 2 +- .../common/ExternalCodeFactory.cs | 10 +- src/dk.gov.oiosi/common/UtilityException.cs | 2 +- .../common/cache/QuantityCache.cs | 22 +- src/dk.gov.oiosi/common/cache/TimedCache.cs | 12 +- .../communication/ErrorMessages.Designer.cs | 38 +- .../communication/ErrorMessages.resx | 36 +- .../OiosiCommunicationException.cs | 2 +- src/dk.gov.oiosi/communication/Request.cs | 10 + src/dk.gov.oiosi/communication/TcpPort.cs | 2 + .../AmbiguousDocumentTypeResultException.cs | 2 +- .../DocumentTypeCollectionConfig.cs | 43 +- .../configuration/DocumentTypeConfig.cs | 34 +- .../configuration/KeyTypeMappingExpression.cs | 1 + .../NoDocumentTypeFoundException.cs | 2 +- .../ProfileMappingCollectionConfig.cs | 3 +- .../fault/ErrorMessages.Designer.cs | 4 +- .../communication/fault/ErrorMessages.resx | 2 +- .../communication/fault/OiosiMessageFault.cs | 1 + .../communication/listener/Listener.cs | 46 +- .../communication/listener/ListenerRequest.cs | 2 +- .../configuration/CacheFactory.cs | 7 +- .../BindingElementNotInStackException.cs | 5 +- .../Interceptor/BindingElementOrderChecker.cs | 4 +- .../BindingElementStackVerifier.cs | 3 +- .../Channels/InterceptorChannelBase.cs | 2 +- .../Channels/InterceptorChannelException.cs | 14 +- .../Channels/InterceptorChannelFactory.cs | 3 +- .../Channels/InterceptorChannelListener.cs | 3 +- .../InterceptorChannelWrapperException.cs | 8 +- .../Channels/InterceptorMessage.cs | 3 +- .../UnsupportedChannelTypeException.cs | 2 +- .../wcf/Interceptor/ErrorMessages.Designer.cs | 18 +- .../wcf/Interceptor/ErrorMessages.resx | 16 +- .../wcf/Interceptor/InterceptorException.cs | 22 +- .../FailedToGetCertificateSubjectException.cs | 4 +- .../wcf/Interceptor/Security/Header/Header.cs | 25 +- .../Header/NoElementsFoundException.cs | 2 +- .../Header/ToManyElementsFoundException.cs | 2 +- ...rSignatureValidationProofBindingElement.cs | 18 +- .../ServerAuthorisationBindingElement.cs | 3 + .../CertificateValidatorWithLookup.cs | 14 +- .../Schema/FailedToLoadSchemaException.cs | 2 +- .../SchemaValidateDocumentFailedException.cs | 4 +- .../Schema/SchemaValidatorWithLookup.cs | 17 +- ...hematronValidateDocumentFailedException.cs | 2 +- ...alidationInterceptionEmptyBodyException.cs | 2 +- .../SchematronValidatorWithLookup.cs | 16 +- .../ServerXsltTransformationBindingElement.cs | 2 +- .../XsltTransformFailedException.cs | 2 +- .../security/CertificateChecker.cs | 438 ++++++++++++------ .../security/CertificateHandlingException.cs | 8 +- .../security/CertificateSubject.cs | 6 +- ...CertificateActivatedUnexpectedException.cs | 2 +- ...heckCertificateChainUnexpectedException.cs | 4 +- ...CheckCertificateTypeUnexpectedException.cs | 2 +- ...heckCertificateValidUnexpectedException.cs | 2 +- ...CertificateActivatedUnexpectedException.cs | 2 +- ...RootCertificateValidUnexpectedException.cs | 2 +- .../security/ErrorMessages.Designer.cs | 2 +- .../security/SignatureValidationProof.cs | 14 +- ...lidationProofAllreadyCompletedException.cs | 2 +- .../ConnectingToLdapServerFailedException.cs | 2 +- ...earchResultToCertificateFailedException.cs | 2 +- .../security/ldap/ErrorMessages.Designer.cs | 2 +- .../ldap/FailedToLoadLookupTypeException.cs | 2 +- .../security/ldap/LdapCertificateLookup.cs | 14 +- ...cateLookupInitializationFailedException.cs | 2 +- .../ldap/LdapCertificateLookupTest.cs | 6 +- .../ldap/LdapCertificateNotFoundException.cs | 2 +- .../security/ldap/LdapException.cs | 9 +- .../security/ldap/LdapLookupFactory.cs | 8 +- .../LdapMultipleCertificatesFoundException.cs | 2 +- .../LdapNoImplementingAssemblyException.cs | 2 +- .../ldap/LdapNoImplementingClassException.cs | 2 +- .../ldap/PatternsDoesNotMatchException.cs | 2 +- .../ldap/StoringCertificateFailedException.cs | 2 +- .../security/lookup/CertificateLoader.cs | 4 +- ...icateLoaderCertificateNotFoundException.cs | 4 +- ...oaderMultipleCertificatesFoundException.cs | 4 +- .../lookup/CertificateLookupException.cs | 4 +- .../lookup/CertificateNotFoundException.cs | 2 +- .../lookup/CertificateStoreIdentification.cs | 4 +- .../MultipleCertificatesFoundException.cs | 2 +- .../security/lookup/SearchFailedException.cs | 4 +- .../oces/AmbigousSubjectCvrNumberException.cs | 2 +- .../oces/EmployeeOcesX509Certificate.cs | 8 +- .../FailedGetOcesCertificateTypeException.cs | 2 +- .../oces/InvalidOcesCertificateException.cs | 2 +- ...InvalidOcesEmployeeCertificateException.cs | 2 +- .../oces/NoSubjectCvrNumberException.cs | 2 +- .../security/oces/OcesCertificateException.cs | 2 +- .../oces/OcesCertificateSubjectKey.cs | 4 +- .../security/oces/OcesX509Certificate.cs | 10 +- .../oces/OcesX509CertificateConfig.cs | 16 +- ...ckCertificateRevokedUnexpectedException.cs | 4 +- .../FailedToLoadLookupTypeException.cs | 2 +- .../revocation/RevocationException.cs | 6 +- .../revocation/RevocationLookupFactory.cs | 6 +- ...vocationNoImplementingAssemblyException.cs | 2 +- .../RevocationNoImplementingClassException.cs | 2 +- .../security/revocation/crl/CrlInstance.cs | 10 +- .../crl/CrlUnavailableForDownloadException.cs | 4 +- .../CertificateRevokedTimeoutException.cs | 2 +- ...CheckCertificateOcspUnexpectedException.cs | 8 +- .../ocsp/InvalidOcspTimeoutValueException.cs | 2 +- .../security/revocation/ocsp/OcspConfig.cs | 6 +- .../security/revocation/ocsp/OcspLookup.cs | 46 +- .../validation/CertificateExpiredException.cs | 2 +- ...rtificateFailedChainValidationException.cs | 8 +- .../CertificateNotActiveException.cs | 2 +- .../CertificateNotInCorrectFormatException.cs | 2 +- .../CertificateRootNotTrustedException.cs | 2 +- .../CertificateValidationException.cs | 4 +- .../validation/CertificateValidator.cs | 14 +- .../MultipleRootX509CertificateValidator.cs | 10 +- src/dk.gov.oiosi/uddi/LookupParameters.cs | 61 +-- .../uddi/ProcessRoleDefinition.cs | 10 +- .../uddi/RegistryLookupClientFactory.cs | 6 +- src/dk.gov.oiosi/uddi/UddiBinding.cs | 6 +- src/dk.gov.oiosi/uddi/UddiCategoryBag.cs | 4 +- .../uddi/UddiEmptyGuidException.cs | 2 +- src/dk.gov.oiosi/uddi/UddiException.cs | 2 +- src/dk.gov.oiosi/uddi/UddiId.cs | 2 +- src/dk.gov.oiosi/uddi/UddiLookupClient.cs | 2 +- .../uddi/UddiLookupClientFactory.cs | 6 +- .../UddiNoImplementingAssemblyException.cs | 2 +- .../uddi/UddiNoImplementingClassException.cs | 2 +- src/dk.gov.oiosi/uddi/UddiService.cs | 4 +- src/dk.gov.oiosi/uddi/UddiStringId.cs | 6 +- src/dk.gov.oiosi/uddi/UddiTModel.cs | 2 +- src/dk.gov.oiosi/xml/XmlException.cs | 4 +- ...cumentTypeFoundFromXmlDocumentException.cs | 2 +- .../DocumentTypeConfigSearcher.cs | 14 +- ...cumentTypeFoundFromXmlDocumentException.cs | 2 +- ...umentTypeFromXmlDocumentFailedException.cs | 2 +- src/dk.gov.oiosi/xml/schema/SchemaStore.cs | 4 +- .../xml/schema/SchemaValidationException.cs | 4 +- .../schema/SchemaValidationFailedException.cs | 8 +- .../xml/schema/SchemaValidator.cs | 6 +- .../schema/UnexpectedNamespaceException.cs | 2 +- .../schematron/SchematronErrorException.cs | 2 +- .../xml/schematron/SchematronStore.cs | 2 +- .../schematron/SchematronValidationConfig.cs | 14 +- .../SchematronValidationException.cs | 2 +- .../SchematronValidationFailedException.cs | 4 +- .../xml/schematron/SchematronValidator.cs | 26 +- .../xml/xpath/DocumentXPathResolver.cs | 22 +- .../xml/xpath/NoXPathResultsException.cs | 2 +- .../xml/xpath/TooManyXpathResultsException.cs | 2 +- .../xml/xpath/XPathSizeTooSmallException.cs | 2 +- 157 files changed, 920 insertions(+), 653 deletions(-) diff --git a/src/dk.gov.oiosi.exception/MainException.cs b/src/dk.gov.oiosi.exception/MainException.cs index d02060f5..d03b6236 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 e184b0f8..9aa4a1b4 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 6b782970..dadea7b0 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 f3b78e74..1e82b31d 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/common/CouldNotLoadTypeException.cs b/src/dk.gov.oiosi/common/CouldNotLoadTypeException.cs index f463e0b4..d4403f35 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 1866e14b..99c7453c 100644 --- a/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/common/ErrorMessages.Designer.cs @@ -70,7 +70,7 @@ namespace dk.gov.oiosi.common { } /// - /// Looks up a localized string similar to E-RSP32015: 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 df7717a2..852a3bb7 100644 --- a/src/dk.gov.oiosi/common/ErrorMessages.resx +++ b/src/dk.gov.oiosi/common/ErrorMessages.resx @@ -121,7 +121,7 @@ Kunne ikke loade en instans af typen '[type]'. - E-RSP32015: 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 8c7b2319..a2d91f46 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("E-RSP32011: 'configuration' is null"); + if (configuration == null) throw new NullArgumentException("E-RSP32101: 'configuration' is null"); return this.CreateInstance(configuration.ImplementationNamespaceClass, configuration.ImplementationAssembly); } @@ -30,21 +30,21 @@ namespace dk.gov.oiosi.common /// public T CreateInstance(string implementationNamespaceClass, string implementationAssembly) { - if (implementationNamespaceClass == null) throw new NullArgumentException("E-RSP32012: 'implementationNamespaceClass' is null"); - if (implementationAssembly == null) throw new NullArgumentException("E-RSP32013: 'implementationAssembly' is null"); + 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(string.Format("E-RSP32014: '{0}' is null", 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-RSP32015 + //ErrorCode: E-RSP32105 throw new CreateInstanceFailedException(implementationNamespaceClass, implementationAssembly, ex); } } diff --git a/src/dk.gov.oiosi/common/UtilityException.cs b/src/dk.gov.oiosi/common/UtilityException.cs index 13510d14..38f3c56d 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 2fadf58d..641c1ba1 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("E-RSP32021: Argument 'maxSize' is out of range."); + 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("E-RSP32022: Argument 'maxSize' must not be less then zero."); + throw new Exception("E-RSP32202: Argument 'maxSize' must not be less then zero."); } } else { - throw new Exception("E-RSP32023: 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("E-RSP32024: Argument 'maxSize' is missing 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("E-RSP32025: 'key' is null"); + 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 ArgumentException("E-RSP32026: 'key' already exists in dictionary"); + 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("E-RSP32025: 'key' is null"); + throw new ArgumentNullException("E-RSP32205: 'key' is null"); } if (_maxSize == 0) @@ -189,7 +189,7 @@ namespace dk.gov.oiosi.common.cache { /// public void Set(TKey key, TValue value) { - if (key == null) throw new ArgumentNullException("E-RSP32025: 'key' is null"); + 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("E-RSP32025: 'key' is null"); + 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("E-RSP32025: 'key' is null"); + 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("E-RSP32025: 'key' is null"); + 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 2747dfee..b781b825 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("E-RSP32031: 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("E-RSP32031: 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("E-RSP32032: 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("E-RSP32032: 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("E-RSP32033: 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("E-RSP32034: 'key' is null"); + 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 499ac0c4..c504b489 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-RSP31011: 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 9dea8030..d51576d6 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-RSP31011: 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 6b8cbbce..864ccf55 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 94a9fb84..97e540d7 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 8d0f37a0..b679f68a 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-RSP31011 throw new InvalidTcpPortException(number); if (number > 65536) + //E-RSP31011 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 282f49a3..57a49775 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 efa80a4c..2d643513 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 5abe9494..3db29ab7 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 9f3c4dcb..0e247b1f 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 f036ff55..7c2b622f 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 5d0a5e09..c386dd1e 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 320d32e4..f819ba6a 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 0658eba6..cf1e78e2 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 746bb602..773831b1 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 d0361ec6..71119911 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 0247a260..1f69c105 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 d1d35182..cf415248 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(); @@ -149,7 +149,8 @@ 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); + //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 3fe68fbc..e9d3b4a6 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 09743f85..3a93a1a9 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 b240f858..e48cb640 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 1292d8c2..f9ba8fae 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 e24a5820..db14faa4 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 1c310578..ebe28178 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 60caa41d..34077b3a 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 226cd96c..f7ed90d0 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 cf54b5a0..e1885b50 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/UnsupportedChannelTypeException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Channels/UnsupportedChannelTypeException.cs index bd196e26..979acfe0 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 c79956c0..d845c3f0 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 cda9d1be..8e2b60d1 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 e373d75b..686a46fa 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); } /// @@ -110,7 +110,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor { /// /// 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 b2d6e5b3..522d9ba0 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 3fe1a639..ba0715f8 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 d205a93c..2bcdd1f5 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 e4ff23d5..8353ec3f 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 0e6ade14..4675b223 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"); } @@ -152,26 +153,32 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Security { // 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); } } @@ -191,12 +198,14 @@ 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)); + //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)); + //E-RSP21202 throw new CertificateRevokedValidationFailedException("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 d18d2cb5..7a96506b 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 fcba4b5c..6f15fc82 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) @@ -115,7 +115,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate this.logger.Warn("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) { @@ -128,7 +128,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate this.logger.Warn("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) { @@ -141,7 +141,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate this.logger.Warn("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) { @@ -154,7 +154,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate this.logger.Warn("Subject for unknown certificate was not found."); } - throw; + throw new FailedToGetCertificateSubjectException(interceptorMessage, "E-RSP21301"); } catch (Exception ex) { @@ -168,7 +168,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate } 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 79f93a0b..a3c1723c 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 167cb669..503b5e98 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 dc4a8dd5..44f8f60d 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); + throw new SchemaValidateDocumentFailedException(ex,"E-RSP21312"); } this.logger.Trace("Schema validate xml document - Finish."); 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 cd2f9d5f..3c2c0c06 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 40f2c722..8ff8174e 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 b32ad500..e7da0156 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); + 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); + 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 b9007694..f9940930 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 c1c2da0c..bd870ef5 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 f9785b1d..32a1a06f 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 b588dc64..21d4b761 100644 --- a/src/dk.gov.oiosi/security/CertificateHandlingException.cs +++ b/src/dk.gov.oiosi/security/CertificateHandlingException.cs @@ -53,15 +53,15 @@ 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 diff --git a/src/dk.gov.oiosi/security/CertificateSubject.cs b/src/dk.gov.oiosi/security/CertificateSubject.cs index 13304376..60a219f1 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 5cefbf9a..a94fa336 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 40cbff26..5fa921fd 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 e2f17cf5..122fc508 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 0cd9d878..5395ad73 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 e4342d51..4c9f3208 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 90cc85c6..e8ee7957 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 0efc5585..98bf3d16 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 1054dd55..a8542afe 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 eec9c355..3deea80f 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 02fefec7..204025e9 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 36bad44e..63e6889d 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 c2046118..02db93aa 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 45a8e351..265ba09d 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 26f95e8d..c739babb 100644 --- a/src/dk.gov.oiosi/security/ldap/LdapCertificateLookup.cs +++ b/src/dk.gov.oiosi/security/ldap/LdapCertificateLookup.cs @@ -98,7 +98,7 @@ namespace dk.gov.oiosi.security.ldap { { if (subject == null) { - throw new ArgumentNullException("subject"); + throw new ArgumentNullException("E-RSP19101: 'subject' is null"); } X509Certificate2 certificateToBeReturned; @@ -181,7 +181,7 @@ namespace dk.gov.oiosi.security.ldap { return ldapConnection; } catch (Exception e) { - throw new ConnectingToLdapServerFailedException(certificateInfrastructure, e); + throw new ConnectingToLdapServerFailedException(certificateInfrastructure, e, "E-RSP19102"); } } @@ -210,7 +210,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 f940ee11..0dfc799a 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 d3e13903..f60bc3bc 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("CN") ? 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 64ce95b8..2032d5bd 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 421cb812..bd9feaa2 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 0e39f926..888ed0db 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 696314ff..e84ab03b 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 07557c73..26e07c44 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 038b70b6..ffdd8998 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 a4774625..2198381f 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 772a600d..05a08cd7 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 67e98ff4..3e870d9a 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 11057aa7..84560114 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 97b40c41..e5f26c11 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 51cfcc36..eebd4d46 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs @@ -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 f9e37ee3..6d9ad7c4 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs @@ -48,6 +48,6 @@ namespace dk.gov.oiosi.security.lookup { /// /// /// - 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 80e3e318..4e9daf0a 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 2233e7f8..d292e35c 100644 --- a/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs @@ -48,6 +48,6 @@ namespace dk.gov.oiosi.security.lookup { /// /// /// - 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 a3be1d47..2bb32279 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 8b319046..6fdbb36f 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 9d8f3762..b50a74ab 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 f7279ce1..67f9ccb4 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 4f07888d..074af024 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 8969ceaf..c8e002b9 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 860e14ff..97ef8bae 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 13f17150..d2ee62e5 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 /// diff --git a/src/dk.gov.oiosi/security/oces/OcesCertificateSubjectKey.cs b/src/dk.gov.oiosi/security/oces/OcesCertificateSubjectKey.cs index 7f2ba708..fbba60ea 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 f56a4219..643f6edd 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 f7b56cb1..d96f0063 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 afb165a3..cdca2bc9 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 6df12a79..ce0c7ced 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 7aca2e85..c4b4c865 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 708248e8..be7842de 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 586e6f16..2c910543 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 bfde02ca..ad106881 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 73ad216d..ef4f78f6 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 { @@ -249,14 +249,14 @@ namespace dk.gov.oiosi.security.revocation.crl } 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)); + 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) { @@ -268,7 +268,7 @@ namespace dk.gov.oiosi.security.revocation.crl } this.logger.Error(string.Format("Error downloading/parsing the CRL from url: '{0}'.", urlString), e); - throw new CheckCertificateRevokedUnexpectedException(e); + throw new CheckCertificateRevokedUnexpectedException(e, "E-RSP19402"); } catch (Exception e) { diff --git a/src/dk.gov.oiosi/security/revocation/crl/CrlUnavailableForDownloadException.cs b/src/dk.gov.oiosi/security/revocation/crl/CrlUnavailableForDownloadException.cs index a23867c8..f7a8b779 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 ce98f927..6857b6fd 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 aff16e82..12775568 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 ba3ca047..098475f1 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 59ce1963..78d6f4d1 100644 --- a/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs +++ b/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs @@ -77,7 +77,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; } } @@ -130,13 +130,13 @@ namespace dk.gov.oiosi.security.revocation.ocsp { // 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/revocation/ocsp/OcspLookup.cs b/src/dk.gov.oiosi/security/revocation/ocsp/OcspLookup.cs index 8f46102b..f6e3ddda 100644 --- a/src/dk.gov.oiosi/security/revocation/ocsp/OcspLookup.cs +++ b/src/dk.gov.oiosi/security/revocation/ocsp/OcspLookup.cs @@ -234,14 +234,14 @@ namespace dk.gov.oiosi.security.revocation.ocsp { if (x509Certificate2 == null) { - throw new CheckCertificateOcspUnexpectedException(); + throw new CheckCertificateOcspUnexpectedException("'x509Certificate2' is null", "E-RSP19421"); } // http://bouncy-castle.1462172.n4.nabble.com/c-ocsp-verification-td3160243.html X509Certificate2 issuerX509Certificate2 = this.FindIssuerCertificate(x509Certificate2); if (issuerX509Certificate2 == null) { - throw new CheckCertificateOcspUnexpectedException("Issuer certificate '"+ x509Certificate2.Issuer +"' not found."); + throw new CheckCertificateOcspUnexpectedException("Issuer certificate '"+ x509Certificate2.Issuer +"' not found.", "E-RSP19422"); } if (issuerX509Certificate2.Thumbprint.Equals(x509Certificate2.Thumbprint, StringComparison.OrdinalIgnoreCase)) @@ -343,7 +343,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { { if (serverX509Certificate2 == null) { - throw new Exception("Server certificate is null"); + throw new CheckCertificateOcspUnexpectedException("'serverX509Certificate2' is null", "E-RSP19422"); } // create BouncyCastle certificates @@ -355,7 +355,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { if (urlList.Count == 0) { - throw new Exception("No OCSP url found in ee certificate."); + throw new Exception("E-RSP19423: No OCSP url found in ee certificate."); } // we always validate against the first defined url @@ -366,7 +366,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { } catch (Exception e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("OCSP valideringen fejlede.", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("OCSP valideringen fejlede.", e, "E-RSP19424"); } return revocationResponse; @@ -379,12 +379,12 @@ namespace dk.gov.oiosi.security.revocation.ocsp { { if (serverX509Certificate2 == null) { - throw new Exception("Server certificate is null"); + throw new CheckCertificateOcspUnexpectedException("'serverX509Certificate2' is null", "E-RSP19422"); } if (issuerX509Certificate2 == null) { - throw new Exception("Issuer certificate for server certificate not identified"); + throw new CheckCertificateOcspUnexpectedException("'issuerX509Certificate2' is null", "E-RSP19425"); } // create BouncyCastle certificates @@ -408,27 +408,27 @@ namespace dk.gov.oiosi.security.revocation.ocsp { } catch (ArgumentNullException e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("ArgumentNullException", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("ArgumentNullException", e, "E-RSP19426"); } catch (OverflowException e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("OverflowException", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("OverflowException", e, "E-RSP19427"); } catch (FormatException e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("FormatException", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("FormatException", e, "E-RSP19428"); } catch (CryptographicUnexpectedOperationException e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("CryptographicUnexpectedOperationException", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("CryptographicUnexpectedOperationException", e, "E-RSP19429"); } catch (CryptographicException e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("CryptographicException", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("CryptographicException", e, "E-RSP19430"); } catch (Exception e) { - revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("OCSP valideringen fejlede.", e); + revocationResponse.Exception = new CheckCertificateOcspUnexpectedException("OCSP valideringen fejlede.", e, "E-RSP19431"); } return revocationResponse; @@ -531,7 +531,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { } catch (Exception e) { - throw new Exception("Error parsing AIA.", e); + throw new Exception("E-RSP19432: Error parsing AIA.", e); } return ocspUrls; @@ -591,7 +591,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { var extensions = toBeSignedPart.Extensions; if (extensions == null) { - throw new CheckCertificateOcspUnexpectedException("No X509 extensions found"); + throw new CheckCertificateOcspUnexpectedException("No X509 extensions found", "E-RSP19433"); } return extensions; } @@ -601,7 +601,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { } catch (CertificateEncodingException e) { - throw new ArgumentException("Error while extracting Access Description", e); + throw new ArgumentException("E-RSP19434: Error while extracting Access Description", e); } } @@ -771,11 +771,11 @@ namespace dk.gov.oiosi.security.revocation.ocsp { } else if (certificateStatus is Org.BouncyCastle.Ocsp.UnknownStatus) { - throw new CheckCertificateOcspUnexpectedException("CertificateStatus is Unknown"); + throw new CheckCertificateOcspUnexpectedException("CertificateStatus is Unknown", "E-RSP19435"); } else { - throw new CheckCertificateOcspUnexpectedException("CertificateStatus is unknown '" + certificateStatus.ToString() + "'."); + throw new CheckCertificateOcspUnexpectedException("CertificateStatus is unknown '" + certificateStatus.ToString() + "'.", "E-RSP19436"); } // break foreach loop @@ -786,14 +786,14 @@ namespace dk.gov.oiosi.security.revocation.ocsp { if (!found) { // the returned result did not contain the desired certificate - throw new CheckCertificateOcspUnexpectedException("Revokation result did not contain the desired certificate serial number."); + throw new CheckCertificateOcspUnexpectedException("Revokation result did not contain the desired certificate serial number.", "E-RSP19437"); } break; } default: { - throw new CheckCertificateOcspUnexpectedException("Unknow status '" + r.Status + "'."); + throw new CheckCertificateOcspUnexpectedException("Unknown status '" + r.Status + "'.", "E-RSP19438"); } } @@ -808,12 +808,12 @@ namespace dk.gov.oiosi.security.revocation.ocsp { if (!expectedId.SerialNumber.Equals(certificateId.SerialNumber)) { - throw new CheckCertificateOcspUnexpectedException("Invalid certificate ID in response"); + throw new CheckCertificateOcspUnexpectedException("Invalid certificate ID in response", "E-RSP19439"); } if (!Org.BouncyCastle.Utilities.Arrays.AreEqual(expectedId.GetIssuerNameHash(), certificateId.GetIssuerNameHash())) { - throw new CheckCertificateOcspUnexpectedException("Invalid certificate Issuer in response"); + throw new CheckCertificateOcspUnexpectedException("Invalid certificate Issuer in response", "E-RSP19440"); } } @@ -873,7 +873,7 @@ namespace dk.gov.oiosi.security.revocation.ocsp { // Note - The validation is still running, and is not closed // operation timeout - throw new CertificateRevokedTimeoutException(TimeSpan.FromMilliseconds(_configuration.DefaultTimeoutMsec)); + throw new CertificateRevokedTimeoutException(TimeSpan.FromMilliseconds(_configuration.DefaultTimeoutMsec), "E-RSP19441"); } return response; diff --git a/src/dk.gov.oiosi/security/validation/CertificateExpiredException.cs b/src/dk.gov.oiosi/security/validation/CertificateExpiredException.cs index bd511fdb..c9de0108 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 8acf4e09..809cbab2 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 d7683d67..81a03a13 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 338ef694..583745da 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 bb3b1893..08035e22 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 2b1cd9f1..e641b66f 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/CertificateValidator.cs b/src/dk.gov.oiosi/security/validation/CertificateValidator.cs index 7f2c99d8..ad127bcb 100644 --- a/src/dk.gov.oiosi/security/validation/CertificateValidator.cs +++ b/src/dk.gov.oiosi/security/validation/CertificateValidator.cs @@ -77,7 +77,7 @@ namespace dk.gov.oiosi.security.validation case X509ChainStatusFlags.OfflineRevocation: break; default: - throw new CertificateFailedChainValidationException(status, certificate.Subject); + throw new CertificateFailedChainValidationException(status, certificate.Subject, "E-RSP19501"); } } } @@ -117,7 +117,7 @@ namespace dk.gov.oiosi.security.validation case X509ChainStatusFlags.OfflineRevocation: break; default: - throw new CertificateFailedChainValidationException(status, certificate.Subject); + throw new CertificateFailedChainValidationException(status, certificate.Subject, "E-RSP19501"); } } @@ -138,12 +138,12 @@ namespace dk.gov.oiosi.security.validation } else { - throw new CertificateFailedChainValidationException("The root certificate and certificate must be different", certificate.Subject); + throw new CertificateFailedChainValidationException("The root certificate and certificate must be different", certificate.Subject, "E-RSP19502"); } if (rootIsInChain == false) { - throw new CertificateFailedChainValidationException("The specified root certificate was not part of the certificate chain", certificate.Subject); + throw new CertificateFailedChainValidationException("The specified root certificate was not part of the certificate chain", certificate.Subject, "E-RSP19503"); } @@ -169,7 +169,7 @@ namespace dk.gov.oiosi.security.validation } catch (Exception e) { - throw new CertificateNotInCorrectFormatException(e); + throw new CertificateNotInCorrectFormatException(e, "E-RSP19504"); } } @@ -182,7 +182,7 @@ namespace dk.gov.oiosi.security.validation { if (certificate.NotBefore > DateTime.Now) { - throw new CertificateNotActiveException(certificate.NotBefore, certificate.Subject); + throw new CertificateNotActiveException(certificate.NotBefore, certificate.Subject, "E-RSP19505"); } } @@ -194,7 +194,7 @@ 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-RSP19506"); } } } diff --git a/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs b/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs index 6fce44e3..d5158787 100644 --- a/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs +++ b/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs @@ -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"); } } @@ -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/LookupParameters.cs b/src/dk.gov.oiosi/uddi/LookupParameters.cs index 517758d1..6ff0930c 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 PO("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 6100cba4..c1b9e4f8 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 8e9df6fa..af172826 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 6dc6051f..5a014e0f 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 83f2e1ac..35956620 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 1a5fcb3d..f2184055 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 967fe070..df3a64d8 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 cfdd918b..e635a9cc 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 8d2b6806..e0ba94fc 100644 --- a/src/dk.gov.oiosi/uddi/UddiLookupClient.cs +++ b/src/dk.gov.oiosi/uddi/UddiLookupClient.cs @@ -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 3419abc6..d25fa0f0 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 e10996f3..aa60b01f 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 e641cfe2..842ea3db 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() { } } } diff --git a/src/dk.gov.oiosi/uddi/UddiService.cs b/src/dk.gov.oiosi/uddi/UddiService.cs index 3c7dd1f4..809546b5 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 e8b2aef6..6c078b3a 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 469ff436..0723a604 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/XmlException.cs b/src/dk.gov.oiosi/xml/XmlException.cs index 035971fe..ac9eea50 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 9df1a8ce..32fd29bb 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 dc785a24..7f31356c 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 8f37bc34..90350a2c 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 0e6bc0d3..ba30f9a1 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 13a75f14..cebb39d8 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 fe9eba50..53f28f83 100644 --- a/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs +++ b/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs @@ -56,13 +56,13 @@ namespace dk.gov.oiosi.xml.schema /// 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 b80d83d6..b3b06c46 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 a3db83d6..b338ca20 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 46a3326d..863d8a18 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 0f93df9c..67a75928 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 252b7650..3a6168e6 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 015c39f2..c93b93c5 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 28af8dc2..0d639ca6 100644 --- a/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs +++ b/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs @@ -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 e134836a..1f9fafb2 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 9c92ce00..6c7f2c6e 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 28783681..b96ea910 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 aa148433..64ff2fbb 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 a20812a1..582d304c 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 3222e10a..178acce1 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(); -- GitLab From ad000e2772530b2ca3d574e85183912b915e352c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20S=C3=B8rensen-Boll?= Date: Mon, 22 Feb 2021 18:21:15 +0100 Subject: [PATCH 3/6] (same as previous) --- src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs b/src/dk.gov.oiosi/uddi/UddiNoImplementingClassException.cs index 842ea3db..4e8c0c6b 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(string errorCode = "") : base() { } + public UddiNoImplementingClassException(string errorCode = "") : base(errorCode) { } } } -- GitLab From 0430fdfc9db35e6ec5b0ae1ae38fb8327cf3aad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20S=C3=B8rensen-Boll?= Date: Mon, 22 Feb 2021 21:44:00 +0100 Subject: [PATCH 4/6] Fixed build errors --- .../extension/wcf/Interceptor/InterceptorException.cs | 4 ++-- src/dk.gov.oiosi/security/CertificateHandlingException.cs | 2 +- .../security/lookup/CertificateLookupException.cs | 2 +- .../security/lookup/CertificateNotFoundException.cs | 2 +- .../security/lookup/MultipleCertificatesFoundException.cs | 2 +- src/dk.gov.oiosi/security/oces/OcesCertificateException.cs | 2 +- src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs | 2 +- .../xml/schematron/SchematronValidationException.cs | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs index 686a46fa..9c864686 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/InterceptorException.cs @@ -101,10 +101,10 @@ 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); } /// diff --git a/src/dk.gov.oiosi/security/CertificateHandlingException.cs b/src/dk.gov.oiosi/security/CertificateHandlingException.cs index 21d4b761..b49bdde6 100644 --- a/src/dk.gov.oiosi/security/CertificateHandlingException.cs +++ b/src/dk.gov.oiosi/security/CertificateHandlingException.cs @@ -68,6 +68,6 @@ namespace dk.gov.oiosi.security { /// /// 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/lookup/CertificateLookupException.cs b/src/dk.gov.oiosi/security/lookup/CertificateLookupException.cs index eebd4d46..e93d544e 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 diff --git a/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs b/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs index 6d9ad7c4..463eeb3a 100644 --- a/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/CertificateNotFoundException.cs @@ -42,7 +42,7 @@ 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. /// diff --git a/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs b/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs index d292e35c..e69d9e8f 100644 --- a/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs +++ b/src/dk.gov.oiosi/security/lookup/MultipleCertificatesFoundException.cs @@ -42,7 +42,7 @@ 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. /// diff --git a/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs b/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs index d2ee62e5..086b963d 100644 --- a/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs +++ b/src/dk.gov.oiosi/security/oces/OcesCertificateException.cs @@ -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/xml/schema/SchemaValidationException.cs b/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs index 53f28f83..43a1ee8f 100644 --- a/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs +++ b/src/dk.gov.oiosi/xml/schema/SchemaValidationException.cs @@ -50,7 +50,7 @@ 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 diff --git a/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs b/src/dk.gov.oiosi/xml/schematron/SchematronValidationException.cs index 0d639ca6..05a16b70 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 -- GitLab From 5eff49e96c5468eccf0a99127282980805c2407c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20S=C3=B8rensen-Boll?= Date: Wed, 24 Feb 2021 09:00:32 +0100 Subject: [PATCH 5/6] First version of implmented ErrorCodes --- src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs | 2 +- src/dk.gov.oiosi/communication/ErrorMessages.resx | 2 +- src/dk.gov.oiosi/communication/TcpPort.cs | 4 ++-- src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs b/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs index c504b489..1d4586fb 100644 --- a/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs +++ b/src/dk.gov.oiosi/communication/ErrorMessages.Designer.cs @@ -172,7 +172,7 @@ namespace dk.gov.oiosi.communication { } /// - /// Looks up a localized string similar to E-RSP31011: 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 { diff --git a/src/dk.gov.oiosi/communication/ErrorMessages.resx b/src/dk.gov.oiosi/communication/ErrorMessages.resx index d51576d6..6024b972 100644 --- a/src/dk.gov.oiosi/communication/ErrorMessages.resx +++ b/src/dk.gov.oiosi/communication/ErrorMessages.resx @@ -154,7 +154,7 @@ E-RSP31007: En SOAP fault meddelelse blev returneret af det kaldte endpoint. Beskeden er: '[fault]'. Fejlen skyldes: '[source]'. - E-RSP31011: 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. E-RSP31308: Den type endpoint applikationen har valgt at lytte på er ikke supporteret. '[type]' endpoints kan ikke bruge som serivce endpoints. diff --git a/src/dk.gov.oiosi/communication/TcpPort.cs b/src/dk.gov.oiosi/communication/TcpPort.cs index b679f68a..fc08d800 100644 --- a/src/dk.gov.oiosi/communication/TcpPort.cs +++ b/src/dk.gov.oiosi/communication/TcpPort.cs @@ -58,10 +58,10 @@ namespace dk.gov.oiosi.communication { private void SetValue(int number) { if (number < 0) - //E-RSP31011 + //E-RSP31021 throw new InvalidTcpPortException(number); if (number > 65536) - //E-RSP31011 + //E-RSP31021 throw new InvalidTcpPortException(number); _number = number; } diff --git a/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs b/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs index ef4f78f6..396719d1 100644 --- a/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs +++ b/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs @@ -282,7 +282,7 @@ namespace dk.gov.oiosi.security.revocation.crl this.logger.Error(string.Format("Error downolading/parsing the CRL from url: '{0}'.", urlString), e); // Re-throw original exception - throw; + throw new Exception("E-RSP19405", e); } return; -- GitLab From b2a7c3fae0fa3e6e16fe14c5ec8ff8b57466b3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20S=C3=B8rensen-Boll?= Date: Thu, 25 Mar 2021 19:49:23 +0100 Subject: [PATCH 6/6] Added error codes to logger. (Only Error, Warning and Fatal) --- .../configuration/CacheFactory.cs | 2 +- .../Channels/InterceptorReplyChannel.cs | 4 ++-- .../Channels/InterceptorRequestChannel.cs | 2 +- ...rSignatureValidationProofBindingElement.cs | 10 +++++----- .../CertificateValidatorWithLookup.cs | 20 +++++++++---------- .../Schema/SchemaValidatorWithLookup.cs | 4 ++-- .../SchematronValidatorWithLookup.cs | 4 ++-- .../security/revocation/crl/CrlInstance.cs | 8 ++++---- .../security/revocation/ocsp/OcspConfig.cs | 4 +++- .../MultipleRootX509CertificateValidator.cs | 12 +++++------ src/dk.gov.oiosi/uddi/UddiLookupClient.cs | 2 +- .../xml/UrlToLocalFilelResolver.cs | 2 +- 12 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/dk.gov.oiosi/configuration/CacheFactory.cs b/src/dk.gov.oiosi/configuration/CacheFactory.cs index cf415248..10df39d4 100644 --- a/src/dk.gov.oiosi/configuration/CacheFactory.cs +++ b/src/dk.gov.oiosi/configuration/CacheFactory.cs @@ -148,7 +148,7 @@ namespace dk.gov.oiosi.configuration if (cacheType == null) { - this.logger.Warn("Cache type not valid. The cache type with qualifiedTypename '" + qualifiedTypename + "' is null."); + 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"); } 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 96e34dd1..8ef9253d 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 747e1d45..0cd46441 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/Security/ServerSignatureValidationProofBindingElement.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs index 4675b223..24f946a3 100644 --- a/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs +++ b/src/dk.gov.oiosi/extension/wcf/Interceptor/Security/ServerSignatureValidationProofBindingElement.cs @@ -146,7 +146,7 @@ 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 @@ -197,16 +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)); - //E-RSP21202 - 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; } } 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 6f15fc82..43bb8fb7 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 @@ -108,11 +108,11 @@ 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, "E-RSP21302"); @@ -121,11 +121,11 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate { 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, "E-RSP21302"); @@ -134,11 +134,11 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate { 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, "E-RSP21302"); @@ -147,11 +147,11 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate { 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 new FailedToGetCertificateSubjectException(interceptorMessage, "E-RSP21301"); @@ -160,11 +160,11 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Certificate { 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); 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 44f8f60d..a237b397 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 @@ -168,7 +168,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schema { } catch (Exception ex) { - this.logger.Error("Schema validate xml document.", ex); + this.logger.Error("E-RSP21314: Schema validate xml document.", ex); throw new SchemaValidateDocumentFailedException(ex,"E-RSP21312"); } @@ -184,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/SchematronValidatorWithLookup.cs b/src/dk.gov.oiosi/extension/wcf/Interceptor/Validation/Schematron/SchematronValidatorWithLookup.cs index e7da0156..a5aa8ff6 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 @@ -92,7 +92,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron } catch (Exception ex) { - this.logger.Error("Schematron validation failed", ex); + this.logger.Error("E-RSP15318: Schematron validation failed", ex); throw new SchematronValidateDocumentFailedException(ex, "E-RSP21322"); } } @@ -132,7 +132,7 @@ namespace dk.gov.oiosi.extension.wcf.Interceptor.Validation.Schematron } catch (Exception ex) { - this.logger.Error("Schematron validation failed", ex); + this.logger.Error("E-RSP15319: Schematron validation failed", ex); throw new SchematronValidateDocumentFailedException(ex, "E-RSP21322"); } } diff --git a/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs b/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs index 396719d1..bfd29c75 100644 --- a/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs +++ b/src/dk.gov.oiosi/security/revocation/crl/CrlInstance.cs @@ -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,7 +248,7 @@ 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)); + 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"); } } @@ -267,7 +267,7 @@ 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); + 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,7 +279,7 @@ 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 new Exception("E-RSP19405", e); diff --git a/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs b/src/dk.gov.oiosi/security/revocation/ocsp/OcspConfig.cs index 78d6f4d1..2e9a55b8 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 { @@ -124,7 +125,8 @@ 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 diff --git a/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs b/src/dk.gov.oiosi/security/validation/MultipleRootX509CertificateValidator.cs index d5158787..3168c96d 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) { @@ -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) diff --git a/src/dk.gov.oiosi/uddi/UddiLookupClient.cs b/src/dk.gov.oiosi/uddi/UddiLookupClient.cs index e0ba94fc..4189b4ea 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; } } diff --git a/src/dk.gov.oiosi/xml/UrlToLocalFilelResolver.cs b/src/dk.gov.oiosi/xml/UrlToLocalFilelResolver.cs index cad13b3d..52f3ded7 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."); } } -- GitLab