Эх сурвалжийг харах

2020/09/24 Jessica
Actions:
1. ocpp1.6 新增Security Messages

Jessica Tseng 4 жил өмнө
parent
commit
67b37f22c1
58 өөрчлөгдсөн 1734 нэмэгдсэн , 11 устгасан
  1. 42 1
      EVCB_OCPP.Packet/EVCB_OCPP.Packet.csproj
  2. 15 1
      EVCB_OCPP.Packet/Features/Profile.cs
  3. 11 2
      EVCB_OCPP.Packet/Features/StandardConfiguration.cs
  4. 35 0
      EVCB_OCPP.Packet/Messages/Security/CertificateSignedConfirmation.cs
  5. 42 0
      EVCB_OCPP.Packet/Messages/Security/CertificateSignedRequest.cs
  6. 35 0
      EVCB_OCPP.Packet/Messages/Security/DeleteCertificateConfirmation.cs
  7. 41 0
      EVCB_OCPP.Packet/Messages/Security/DeleteCertificateRequest.cs
  8. 35 0
      EVCB_OCPP.Packet/Messages/Security/ExtendedTriggerMessageConfirmation.cs
  9. 46 0
      EVCB_OCPP.Packet/Messages/Security/ExtendedTriggerMessageRequest.cs
  10. 44 0
      EVCB_OCPP.Packet/Messages/Security/GetInstalledCertificateIdsConfirmation.cs
  11. 39 0
      EVCB_OCPP.Packet/Messages/Security/GetInstalledCertificateIdsRequest.cs
  12. 46 0
      EVCB_OCPP.Packet/Messages/Security/GetLogConfirmation.cs
  13. 68 0
      EVCB_OCPP.Packet/Messages/Security/GetLogRequest.cs
  14. 39 0
      EVCB_OCPP.Packet/Messages/Security/InstallCertificateConfirmation.cs
  15. 49 0
      EVCB_OCPP.Packet/Messages/Security/InstallCertificateRequest.cs
  16. 29 0
      EVCB_OCPP.Packet/Messages/Security/LogStatusNotificationConfirmation.cs
  17. 48 0
      EVCB_OCPP.Packet/Messages/Security/LogStatusNotificationRequest.cs
  18. 31 0
      EVCB_OCPP.Packet/Messages/Security/SecurityEventNotificationConfirmation.cs
  19. 54 0
      EVCB_OCPP.Packet/Messages/Security/SecurityEventNotificationRequest.cs
  20. 38 0
      EVCB_OCPP.Packet/Messages/Security/SignCertificateConfirmation.cs
  21. 41 0
      EVCB_OCPP.Packet/Messages/Security/SignCertificateRequest.cs
  22. 28 0
      EVCB_OCPP.Packet/Messages/Security/SignedFirmwareStatusNotificationConfirmation.cs
  23. 49 0
      EVCB_OCPP.Packet/Messages/Security/SignedFirmwareStatusNotificationRequest.cs
  24. 37 0
      EVCB_OCPP.Packet/Messages/Security/SignedUpdateFirmwareConfirmation.cs
  25. 59 0
      EVCB_OCPP.Packet/Messages/Security/SignedUpdateFirmwareRequest.cs
  26. 6 0
      EVCB_OCPP.Packet/Messages/Security/UpdateFirmwareStatusEnumType.cs
  27. 42 0
      EVCB_OCPP.Packet/Messages/SubTypes/CertificateHashDataType.cs
  28. 15 0
      EVCB_OCPP.Packet/Messages/SubTypes/CertificateSignedStatusEnumType.cs
  29. 15 0
      EVCB_OCPP.Packet/Messages/SubTypes/CertificateStatusEnumType.cs
  30. 14 0
      EVCB_OCPP.Packet/Messages/SubTypes/CertificateUseEnumType.cs
  31. 15 0
      EVCB_OCPP.Packet/Messages/SubTypes/DeleteCertificateStatusEnumType.cs
  32. 27 0
      EVCB_OCPP.Packet/Messages/SubTypes/FirmwareStatusEnumType.cs
  33. 52 0
      EVCB_OCPP.Packet/Messages/SubTypes/FirmwareType.cs
  34. 14 0
      EVCB_OCPP.Packet/Messages/SubTypes/GenericStatusEnumType.cs
  35. 14 0
      EVCB_OCPP.Packet/Messages/SubTypes/GetInstalledCertificateStatusEnumType.cs
  36. 15 0
      EVCB_OCPP.Packet/Messages/SubTypes/HashAlgorithmEnumType.cs
  37. 14 0
      EVCB_OCPP.Packet/Messages/SubTypes/LogEnumType.cs
  38. 37 0
      EVCB_OCPP.Packet/Messages/SubTypes/LogParametersType.cs
  39. 15 0
      EVCB_OCPP.Packet/Messages/SubTypes/LogStatusEnumType.cs
  40. 19 0
      EVCB_OCPP.Packet/Messages/SubTypes/MessageTriggerEnum.cs
  41. 15 0
      EVCB_OCPP.Packet/Messages/SubTypes/TriggerMessageStatusEnumType.cs
  42. 20 0
      EVCB_OCPP.Packet/Messages/SubTypes/UploadLogStatusEnumType.cs
  43. 1 1
      EVCB_OCPP.Packet20/DataTypes/ChargingScheduleType.cs
  44. 8 0
      EVCB_OCPP.Packet20/EVCB_OCPP.Packet20.csproj
  45. 27 0
      EVCB_OCPP.Packet20/Features/Core/BootNotificationFeature.cs
  46. 27 0
      EVCB_OCPP.Packet20/Features/Core/HeartbeatFeature.cs
  47. 56 0
      EVCB_OCPP.Packet20/Features/CoreProfile.cs
  48. 25 0
      EVCB_OCPP.Packet20/Features/Feature.cs
  49. 101 0
      EVCB_OCPP.Packet20/Features/Profile.cs
  50. 18 1
      EVCB_OCPP.Packet20/Messages/BootNotificationRequest.cs
  51. 18 1
      EVCB_OCPP.Packet20/Messages/BootNotificationResponse.cs
  52. 33 2
      EVCB_OCPP.Packet20/Messages/HeartbeatRequest.cs
  53. 16 1
      EVCB_OCPP.Packet20/Messages/HeartbeatResponse.cs
  54. 15 0
      EVCB_OCPP.Packet20/Messages/IConfirmation.cs
  55. 19 0
      EVCB_OCPP.Packet20/Messages/IRequest.cs
  56. 17 0
      EVCB_OCPP.Packet20/Messages/IValidatable.cs
  57. 2 1
      EVCB_OCPP.Packet20/Messages/InstallCertificateResponse.cs
  58. 1 0
      EVCB_OCPP.Packet20/Messages/StatusNotificationRequest.cs

+ 42 - 1
EVCB_OCPP.Packet/EVCB_OCPP.Packet.csproj

@@ -143,6 +143,29 @@
     <Compile Include="Messages\Reservation\CancelReservationRequest.cs" />
     <Compile Include="Messages\Reservation\ReserveNowConfirmation.cs" />
     <Compile Include="Messages\Reservation\ReserveNowRequest.cs" />
+    <Compile Include="Messages\Security\CertificateSignedConfirmation.cs" />
+    <Compile Include="Messages\Security\CertificateSignedRequest.cs" />
+    <Compile Include="Messages\Security\DeleteCertificateConfirmation.cs" />
+    <Compile Include="Messages\Security\DeleteCertificateRequest.cs" />
+    <Compile Include="Messages\Security\ExtendedTriggerMessageConfirmation.cs" />
+    <Compile Include="Messages\Security\ExtendedTriggerMessageRequest.cs" />
+    <Compile Include="Messages\Security\GetInstalledCertificateIdsConfirmation.cs" />
+    <Compile Include="Messages\Security\GetInstalledCertificateIdsRequest.cs" />
+    <Compile Include="Messages\Security\GetLogConfirmation.cs" />
+    <Compile Include="Messages\Security\GetLogRequest.cs" />
+    <Compile Include="Messages\Security\InstallCertificateConfirmation.cs" />
+    <Compile Include="Messages\Security\InstallCertificateRequest.cs" />
+    <Compile Include="Messages\Security\LogStatusNotificationConfirmation.cs" />
+    <Compile Include="Messages\Security\LogStatusNotificationRequest.cs" />
+    <Compile Include="Messages\Security\SecurityEventNotificationConfirmation.cs" />
+    <Compile Include="Messages\Security\SecurityEventNotificationRequest.cs" />
+    <Compile Include="Messages\Security\SignCertificateConfirmation.cs" />
+    <Compile Include="Messages\Security\SignCertificateRequest.cs" />
+    <Compile Include="Messages\Security\SignedFirmwareStatusNotificationConfirmation.cs" />
+    <Compile Include="Messages\Security\SignedFirmwareStatusNotificationRequest.cs" />
+    <Compile Include="Messages\Security\SignedUpdateFirmwareConfirmation.cs" />
+    <Compile Include="Messages\Security\SignedUpdateFirmwareRequest.cs" />
+    <Compile Include="Messages\Security\UpdateFirmwareStatusEnumType.cs" />
     <Compile Include="Messages\SmartCharging\ClearChargingProfileConfirmation.cs" />
     <Compile Include="Messages\SmartCharging\ClearChargingProfileRequest.cs" />
     <Compile Include="Messages\SmartCharging\GetCompositeScheduleConfirmation.cs" />
@@ -163,6 +186,10 @@
     <Compile Include="Messages\SubTypes\BMSStatusEType.cs" />
     <Compile Include="Messages\SubTypes\CancelReservationStatus.cs" />
     <Compile Include="Messages\SubTypes\CarConnectionStatus.cs" />
+    <Compile Include="Messages\SubTypes\CertificateHashDataType.cs" />
+    <Compile Include="Messages\SubTypes\CertificateSignedStatusEnumType.cs" />
+    <Compile Include="Messages\SubTypes\CertificateStatusEnumType.cs" />
+    <Compile Include="Messages\SubTypes\CertificateUseEnumType.cs" />
     <Compile Include="Messages\SubTypes\ChargeMode.cs" />
     <Compile Include="Messages\SubTypes\ChargePointErrorCode.cs" />
     <Compile Include="Messages\SubTypes\ChargePointStatus.cs" />
@@ -181,14 +208,24 @@
     <Compile Include="Messages\SubTypes\ConfigurationStatus.cs" />
     <Compile Include="Messages\SubTypes\csChargingProfiles.cs" />
     <Compile Include="Messages\SubTypes\DataTransferStatus.cs" />
+    <Compile Include="Messages\SubTypes\DeleteCertificateStatusEnumType.cs" />
     <Compile Include="Messages\SubTypes\DiagnosticsStatus.cs" />
     <Compile Include="Messages\SubTypes\FirmwareStatus.cs" />
+    <Compile Include="Messages\SubTypes\FirmwareStatusEnumType.cs" />
+    <Compile Include="Messages\SubTypes\FirmwareType.cs" />
+    <Compile Include="Messages\SubTypes\GenericStatusEnumType.cs" />
     <Compile Include="Messages\SubTypes\GetCompositeScheduleStatus.cs" />
+    <Compile Include="Messages\SubTypes\GetInstalledCertificateStatusEnumType.cs" />
+    <Compile Include="Messages\SubTypes\HashAlgorithmEnumType.cs" />
     <Compile Include="Messages\SubTypes\IdTagInfo.cs" />
     <Compile Include="Messages\SubTypes\KeyValue.cs" />
     <Compile Include="Messages\SubTypes\Location.cs" />
+    <Compile Include="Messages\SubTypes\LogEnumType.cs" />
+    <Compile Include="Messages\SubTypes\LogParametersType.cs" />
+    <Compile Include="Messages\SubTypes\LogStatusEnumType.cs" />
     <Compile Include="Messages\SubTypes\Measurand.cs" />
     <Compile Include="Messages\SubTypes\MessageTrigger.cs" />
+    <Compile Include="Messages\SubTypes\MessageTriggerEnum.cs" />
     <Compile Include="Messages\SubTypes\MeterValue.cs" />
     <Compile Include="Messages\SubTypes\Phase.cs" />
     <Compile Include="Messages\SubTypes\ReadingContext.cs" />
@@ -201,16 +238,20 @@
     <Compile Include="Messages\SubTypes\ResetType.cs" />
     <Compile Include="Messages\SubTypes\SampledValue.cs" />
     <Compile Include="Messages\SubTypes\TriggerMessageStatus.cs" />
+    <Compile Include="Messages\SubTypes\TriggerMessageStatusEnumType.cs" />
     <Compile Include="Messages\SubTypes\UnitOfMeasure.cs" />
     <Compile Include="Messages\SubTypes\UnlockStatus.cs" />
     <Compile Include="Messages\SubTypes\UpdateStatus.cs" />
     <Compile Include="Messages\SubTypes\UpdateType.cs" />
+    <Compile Include="Messages\SubTypes\UploadLogStatusEnumType.cs" />
     <Compile Include="Messages\SubTypes\ValueFormat.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Utilities\FormatHelper.cs" />
     <Compile Include="Utilities\UTCDateTimeConverter.cs" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <Folder Include="Features\Security\" />
+  </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
   </ItemGroup>

+ 15 - 1
EVCB_OCPP.Packet/Features/Profile.cs

@@ -42,7 +42,21 @@ namespace EVCB_OCPP.Packet.Features
         //SmartCharging
         ClearChargingProfile,
         GetCompositeSchedule,
-        SetChargingProfile
+        SetChargingProfile,
+        //Security
+        CertificateSigned,
+        DeleteCertificate,
+        ExtendedTriggerMessage,
+        GetInstalledCertificateIds,
+        GetLog,
+        InstallCertificate,
+        LogStatusNotification,
+        SecurityEventNotification,
+        SignCertificate,
+        SignedFirmwareStatusNotification,
+        SignedUpdateFirmware
+
+
     }
     public class Profile
     {

+ 11 - 2
EVCB_OCPP.Packet/Features/StandardConfiguration.cs

@@ -104,10 +104,19 @@ namespace OCPPPackage.Profiles
         public const string MaxChargingProfilesInstalled = "MaxChargingProfilesInstalled";
         #endregion
 
-   
+
+        #region Security
+        public const string AdditionalRootCertificateCheck = "AdditionalRootCertificateCheck";
+        public const string AuthorizationKey = "AuthorizationKey";
+        public const string CertificateSignedMaxChainSize = "CertificateSignedMaxChainSize";
+        public const string CertificateStoreMaxLength = "CertificateStoreMaxLength";
+        public const string CpoName = "CpoName";
+        public const string SecurityProfile = "SecurityProfile";
+ 
+
+        #endregion
 
 
-       
 
         public static readonly List<string> AllConfigs = new List<string>()
         {

+ 35 - 0
EVCB_OCPP.Packet/Messages/Security/CertificateSignedConfirmation.cs

@@ -0,0 +1,35 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class CertificateSignedConfirmation:IConfirmation
+    {
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public CertificateSignedStatusEnumType status { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 42 - 0
EVCB_OCPP.Packet/Messages/Security/CertificateSignedRequest.cs

@@ -0,0 +1,42 @@
+using EVCB_OCPP.Packet.Features;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class CertificateSignedRequest:IRequest
+    {
+        public CertificateSignedRequest()
+        {
+            Action = Actions.CertificateSigned.ToString();
+        }
+
+        /// <summary>
+        /// Required. The signed PEM encoded X.509 certificates. This can also contain the
+        /// necessary sub CA certificates.The maximum size of this field is be limited by the
+        /// configuration key: CertificateSignedMaxSize.
+        /// </summary>
+        [Required]
+        [StringLength(10000, MinimumLength = 0)]
+        public string certificateChain { set; get; }
+
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 35 - 0
EVCB_OCPP.Packet/Messages/Security/DeleteCertificateConfirmation.cs

@@ -0,0 +1,35 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class DeleteCertificateConfirmation:IConfirmation
+    {
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public DeleteCertificateStatusEnumType status { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 41 - 0
EVCB_OCPP.Packet/Messages/Security/DeleteCertificateRequest.cs

@@ -0,0 +1,41 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class DeleteCertificateRequest:IRequest
+    {
+        public DeleteCertificateRequest()
+        {
+            Action = Actions.DeleteCertificate.ToString();
+        }
+
+        /// <summary>
+        /// Required. Indicates the certificate of which deletion is requested
+        /// </summary>
+        [Required]       
+        public CertificateHashDataType certificateHashData { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+
+    }
+}

+ 35 - 0
EVCB_OCPP.Packet/Messages/Security/ExtendedTriggerMessageConfirmation.cs

@@ -0,0 +1,35 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class ExtendedTriggerMessageConfirmation:IConfirmation
+    {
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public TriggerMessageStatusEnumType status { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 46 - 0
EVCB_OCPP.Packet/Messages/Security/ExtendedTriggerMessageRequest.cs

@@ -0,0 +1,46 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class ExtendedTriggerMessageRequest:IRequest
+    {
+        public ExtendedTriggerMessageRequest()
+        {
+            Action = Actions.ExtendedTriggerMessage.ToString();
+        }
+
+        /// <summary>
+        /// Required. Type of the message to be triggered
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public MessageTriggerEnumType requestedMessage { set; get; }
+
+        /// <summary>
+        /// Only filled in when request applies to a specific connector.
+        /// </summary>
+        public int connectorId { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 44 - 0
EVCB_OCPP.Packet/Messages/Security/GetInstalledCertificateIdsConfirmation.cs

@@ -0,0 +1,44 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class GetInstalledCertificateIdsConfirmation:IConfirmation
+    {
+        /// <summary>
+        /// Charge Point indicates if it can process the request
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public GetInstalledCertificateStatusEnumType status { set; get; }
+
+        /// <summary>
+        /// The Charge Point includes the Certificate information for each
+        ///available certificate.
+        /// </summary>
+        public List<CertificateHashDataType> certificateHashData { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 39 - 0
EVCB_OCPP.Packet/Messages/Security/GetInstalledCertificateIdsRequest.cs

@@ -0,0 +1,39 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+   
+    public class GetInstalledCertificateIdsRequest:IRequest
+    {
+        public GetInstalledCertificateIdsRequest()
+        {
+            Action = Actions.GetInstalledCertificateIds.ToString();
+        }
+
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public CertificateUseEnumType certificateType { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 46 - 0
EVCB_OCPP.Packet/Messages/Security/GetLogConfirmation.cs

@@ -0,0 +1,46 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class GetLogConfirmation:IConfirmation
+    {
+        /// <summary>
+        /// This field indicates whether the Charge Point was able to accept the
+        ///request.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public LogStatusEnumType status { set; get; }
+
+        /// <summary>
+        /// This contains the name of the log file that will be uploaded. This field is
+        ///not present when no logging information is available
+        /// </summary>
+        [StringLength(255, MinimumLength = 0)]
+        public string filename { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 68 - 0
EVCB_OCPP.Packet/Messages/Security/GetLogRequest.cs

@@ -0,0 +1,68 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class GetLogRequest:IRequest
+    {
+        public GetLogRequest()
+        {
+            Action = Actions.GetLog.ToString();
+        }
+
+        /// <summary>
+        /// This contains the type of log file that the Charge Point should send.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public LogEnumType logType { set; get; }
+
+        /// <summary>
+        /// The Id of this request
+        /// </summary>
+        [Required]
+        public int requestId { set; get; }
+
+        /// <summary>
+        /// This specifies how many times the Charge Point must try to upload the
+        /// log before giving up.If this field is not present, it is left to Charge Point to decide
+        /// how many times it wants to retry
+        /// </summary>
+        public int retries { set; get; }
+
+        /// <summary>
+        /// The interval in seconds after which a retry may be attempted. If this
+        ///field is not present, it is left to Charge Point to decide how long to wait between
+        ///attempts.
+        /// </summary>
+        public int retryInterval { set; get; }
+
+        /// <summary>
+        /// This field specifies the requested log and the location to which the log
+        ///should be sent.
+        /// </summary>
+        [Required]
+        public LogParametersType log { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 39 - 0
EVCB_OCPP.Packet/Messages/Security/InstallCertificateConfirmation.cs

@@ -0,0 +1,39 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+   public class InstallCertificateConfirmation:IConfirmation
+    {
+        /// <summary>
+        /// Charge Point indicates if installation was successful
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public CertificateStatusEnumType status { set; get; }
+
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 49 - 0
EVCB_OCPP.Packet/Messages/Security/InstallCertificateRequest.cs

@@ -0,0 +1,49 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+   public class InstallCertificateRequest:IRequest
+    {
+        public InstallCertificateRequest()
+        {
+            Action = Actions.InstallCertificate.ToString();
+        }
+
+
+        /// <summary>
+        /// Indicates the certificate type that is sent.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public CertificateUseEnumType certificateType { set; get; }
+
+        /// <summary>
+        /// An PEM encoded X.509 certificate.
+        /// </summary>
+        [Required]
+        [StringLength(5500,MinimumLength =0)]
+        public string certificate { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 29 - 0
EVCB_OCPP.Packet/Messages/Security/LogStatusNotificationConfirmation.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class LogStatusNotificationConfirmation:IConfirmation
+    {
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 48 - 0
EVCB_OCPP.Packet/Messages/Security/LogStatusNotificationRequest.cs

@@ -0,0 +1,48 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class LogStatusNotificationRequest
+    {
+        public LogStatusNotificationRequest()
+        {
+            Action = Actions.LogStatusNotification.ToString();
+        }
+
+        /// <summary>
+        /// This contains the status of the log upload
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public UploadLogStatusEnumType status { set; get; }
+
+        /// <summary>
+        /// The request id that was provided in the GetLog.req that started this log
+        ///upload.
+        /// </summary>
+        public int requestId { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+
+    }
+}

+ 31 - 0
EVCB_OCPP.Packet/Messages/Security/SecurityEventNotificationConfirmation.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SecurityEventNotificationConfirmation : IConfirmation
+    {
+
+
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 54 - 0
EVCB_OCPP.Packet/Messages/Security/SecurityEventNotificationRequest.cs

@@ -0,0 +1,54 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Utilities;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SecurityEventNotificationRequest:IRequest
+    {
+        public SecurityEventNotificationRequest()
+        {
+            Action = Actions.SecurityEventNotification.ToString();
+        }
+
+        /// <summary>
+        /// Type of the security event (See list of currently known security events)
+        /// </summary>
+        [Required]
+        [StringLength(50,MinimumLength =0)]
+        public string type { set; get; }
+
+        /// <summary>
+        /// Date and time at which the event occurred.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(UTCDateTimeConverter))]
+        public DateTime timestamp { set; get; }
+
+        /// <summary>
+        /// Additional information about the occurred security event.
+        /// </summary>
+        [Required]
+        [StringLength(255, MinimumLength = 0)]
+        public string techInfo { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 38 - 0
EVCB_OCPP.Packet/Messages/Security/SignCertificateConfirmation.cs

@@ -0,0 +1,38 @@
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+   public class SignCertificateConfirmation: IConfirmation
+    {
+        /// <summary>
+        /// Specifies whether the Central System can process the request.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public GenericStatusEnumType status { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 41 - 0
EVCB_OCPP.Packet/Messages/Security/SignCertificateRequest.cs

@@ -0,0 +1,41 @@
+using EVCB_OCPP.Packet.Features;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SignCertificateRequest : IRequest
+    {
+        public SignCertificateRequest()
+        {
+            Action = Actions.SignCertificate.ToString();
+        }
+
+        /// <summary>
+        /// The Charge Point SHALL send the public key in form of a Certificate
+        /// Signing Request(CSR) as described in RFC 2986 [14] and then PEM encoded,
+        ////using the SignCertificate.req message.
+        /// </summary>
+        [Required]
+        [StringLength(5500, MinimumLength = 0)]
+        public string csr { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 28 - 0
EVCB_OCPP.Packet/Messages/Security/SignedFirmwareStatusNotificationConfirmation.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SignedFirmwareStatusNotificationConfirmation : IConfirmation
+    {
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 49 - 0
EVCB_OCPP.Packet/Messages/Security/SignedFirmwareStatusNotificationRequest.cs

@@ -0,0 +1,49 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SignedFirmwareStatusNotificationRequest: IRequest
+    {
+
+        public SignedFirmwareStatusNotificationRequest()
+        {
+            Action = Actions.SignedFirmwareStatusNotification.ToString();
+        }
+        /// <summary>
+        /// This contains the progress status of the firmware installation.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public FirmwareStatusEnumType status { set; get; }
+
+        /// <summary>
+        /// The request id that was provided in the SignedUpdateFirmware.req
+       /// that started this firmware update.This field is mandatory, unless the message
+       /// was triggered by a TriggerMessage.req or the ExtendedTriggerMessage.req AND
+        ///there is no firmware update ongoing
+        /// </summary>
+        public int requestId { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 37 - 0
EVCB_OCPP.Packet/Messages/Security/SignedUpdateFirmwareConfirmation.cs

@@ -0,0 +1,37 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SignedUpdateFirmwareConfirmation : IConfirmation
+    {
+        /// <summary>
+        /// This field indicates whether the Charge Point was able to accept the
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public UpdateFirmwareStatusEnumType status { set; get; }
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 59 - 0
EVCB_OCPP.Packet/Messages/Security/SignedUpdateFirmwareRequest.cs

@@ -0,0 +1,59 @@
+using EVCB_OCPP.Packet.Features;
+using EVCB_OCPP.Packet.Messages.SubTypes;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class SignedUpdateFirmwareRequest : IRequest
+    {
+        public SignedUpdateFirmwareRequest()
+        {
+            Action = Actions.SignedUpdateFirmware.ToString();
+        }
+
+        /// <summary>
+        /// This specifies how many times Charge Point must try to download the
+        ///firmware before giving up.If this field is not present, it is left to Charge Point to
+        ///decide how many times it wants to retry.
+        /// </summary>
+        public int retries { set; get; }
+
+        /// <summary>
+        /// The interval in seconds after which a retry may be attempted. If this
+        /// field is not present, it is left to Charge Point to decide how long to wait between
+        ///attempts.
+        /// </summary>
+        public int retryInterval { set; get; }
+
+        /// <summary>
+        /// The Id of this request
+        /// </summary>
+        [Required]
+        public int requestId { set; get; }
+
+        /// <summary>
+        /// Specifies the firmware to be updated on the Charge Point.
+        /// </summary>
+        [Required]
+        public FirmwareType firmware { set; get; }
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
+    }
+}

+ 6 - 0
EVCB_OCPP.Packet/Messages/Security/UpdateFirmwareStatusEnumType.cs

@@ -0,0 +1,6 @@
+namespace EVCB_OCPP.Packet.Messages.Security
+{
+    public class UpdateFirmwareStatusEnumType
+    {
+    }
+}

+ 42 - 0
EVCB_OCPP.Packet/Messages/SubTypes/CertificateHashDataType.cs

@@ -0,0 +1,42 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+   public class CertificateHashDataType
+    {
+        /// <summary>
+        /// Used algorithms for the hashes provided.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(StringEnumConverter))]
+        public HashAlgorithmEnumType hashAlgorithm { set; get; }
+
+        /// <summary>
+        /// hashed value of the IssuerName.
+        /// </summary>
+        [Required]
+        [StringLength(128,MinimumLength =0)]
+        public string issuerNameHash { set; get; }
+
+        /// <summary>
+        /// hashed value of the issuers public key
+        /// </summary>
+        [Required]
+        [StringLength(128, MinimumLength = 0)]
+        public string issuerKeyHash { set; get; }
+
+        /// <summary>
+        /// hashed value of The serial number of the certificate.
+        /// </summary>
+        [Required]
+        [StringLength(40, MinimumLength = 0)]
+        public string serialNumber { set; get; }
+    }
+}

+ 15 - 0
EVCB_OCPP.Packet/Messages/SubTypes/CertificateSignedStatusEnumType.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum CertificateSignedStatusEnumType
+    {
+        Accepted=1,
+        Failed,
+        Rejected
+    }
+}

+ 15 - 0
EVCB_OCPP.Packet/Messages/SubTypes/CertificateStatusEnumType.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum CertificateStatusEnumType
+    {
+        Accepted=1,
+        Failed,
+        Rejected
+    }
+}

+ 14 - 0
EVCB_OCPP.Packet/Messages/SubTypes/CertificateUseEnumType.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+   public enum CertificateUseEnumType
+    {
+        CentralSystemRootCertificate=1,
+        ManufacturerRootCertificate
+    }
+}

+ 15 - 0
EVCB_OCPP.Packet/Messages/SubTypes/DeleteCertificateStatusEnumType.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum DeleteCertificateStatusEnumType
+    {
+        Accepted=1,
+        Failed,
+        NotFound
+    }
+}

+ 27 - 0
EVCB_OCPP.Packet/Messages/SubTypes/FirmwareStatusEnumType.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum FirmwareStatusEnumType
+    {
+        Downloaded = 1,
+        DownloadFailed,
+        Downloading,
+        DownloadScheduled,
+        DownloadPaused,
+        Idle,
+        InstallationFailed,
+        Installing,
+        Installed,
+        InstallRebooting,
+        InstallScheduled,
+        InstallVerificationFailed,
+        InvalidSignature,
+        SignatureVerified
+
+    }
+}

+ 52 - 0
EVCB_OCPP.Packet/Messages/SubTypes/FirmwareType.cs

@@ -0,0 +1,52 @@
+using EVCB_OCPP.Packet.Utilities;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public class FirmwareType
+    {
+        /// <summary>
+        /// URI defining the origin of the firmware.
+        /// </summary>
+        [StringLength(512, MinimumLength = 0)]
+        [Required]
+        public string location { set; get; }
+
+        /// <summary>
+        /// Date and time at which the firmware shall be retrieved.
+        /// </summary>
+        [Required]
+        [JsonConverter(typeof(UTCDateTimeConverter))]
+        public DateTime retrieveDateTime { set; get; }
+
+        /// <summary>
+        /// Date and time at which the firmware shall be installed
+        /// </summary>      
+        [JsonConverter(typeof(UTCDateTimeConverter))]
+        public DateTime installDateTime { set; get; }
+
+        /// <summary>
+        ///Certificate with which the firmware was signed. PEM encoded X.509
+        ///  certificate.
+        /// </summary>
+        [StringLength(5500, MinimumLength = 0)]
+        [Required]
+        public string signingCertificate { set; get; }
+
+        /// <summary>
+        // Base64 encoded firmware signature.
+        /// </summary>
+        [StringLength(800, MinimumLength = 0)]
+        [Required]
+        public string signature { set; get; }
+
+
+
+    }
+}

+ 14 - 0
EVCB_OCPP.Packet/Messages/SubTypes/GenericStatusEnumType.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum GenericStatusEnumType
+    {
+        Accepted=1,
+        Rejected
+    }
+}

+ 14 - 0
EVCB_OCPP.Packet/Messages/SubTypes/GetInstalledCertificateStatusEnumType.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum GetInstalledCertificateStatusEnumType
+    {
+        Accepted=1,
+        NotFound
+    }
+}

+ 15 - 0
EVCB_OCPP.Packet/Messages/SubTypes/HashAlgorithmEnumType.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum HashAlgorithmEnumType
+    {
+        SHA256=1,
+        SHA384,
+        SHA512
+    }
+}

+ 14 - 0
EVCB_OCPP.Packet/Messages/SubTypes/LogEnumType.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum LogEnumType
+    {
+        DiagnosticsLog=1,
+        SecurityLog
+    }
+}

+ 37 - 0
EVCB_OCPP.Packet/Messages/SubTypes/LogParametersType.cs

@@ -0,0 +1,37 @@
+using EVCB_OCPP.Packet.Utilities;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public class LogParametersType
+    {
+        /// <summary>
+        /// The URL of the location at the remote system where the log should be
+        /// stored.
+        /// </summary>
+        [Required]
+        [StringLength(512, MinimumLength = 0)]
+        public string remoteLocation { set; get; }
+
+        /// <summary>
+        /// This contains the date and time of the oldest logging information to
+        ///include in the diagnostics.
+        /// </summary>       
+        [JsonConverter(typeof(UTCDateTimeConverter))]
+        public DateTime oldestTimestamp { set; get; }
+
+        /// <summary>
+        ///This contains the date and time of the latest logging information to
+        ///include in the diagnostics.
+        /// </summary>       
+        [JsonConverter(typeof(UTCDateTimeConverter))]
+        public DateTime latestTimestamp { set; get; }
+
+    }
+}

+ 15 - 0
EVCB_OCPP.Packet/Messages/SubTypes/LogStatusEnumType.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum LogStatusEnumType
+    {
+        Accepted=1,
+        Rejected,
+        AcceptedCanceled
+    }
+}

+ 19 - 0
EVCB_OCPP.Packet/Messages/SubTypes/MessageTriggerEnum.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum MessageTriggerEnumType
+    {
+        BootNotification=1,
+        LogStatusNotification,
+        FirmwareStatusNotification,
+        Heartbeat,
+        MeterValues,
+        SignChargePointCertificate,
+        StatusNotification
+    }
+}

+ 15 - 0
EVCB_OCPP.Packet/Messages/SubTypes/TriggerMessageStatusEnumType.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum TriggerMessageStatusEnumType
+    {
+        Accepted=1,
+        Rejected,
+        NotImplemented
+    }
+}

+ 20 - 0
EVCB_OCPP.Packet/Messages/SubTypes/UploadLogStatusEnumType.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet.Messages.SubTypes
+{
+    public enum UploadLogStatusEnumType
+    {
+        BadMessage=1,
+        Idle,
+        NotSupportedOperation,
+        PermissionDenied,
+        Uploaded,
+        UploadFailure,
+        Uploading
+
+    }
+}

+ 1 - 1
EVCB_OCPP.Packet20/DataTypes/ChargingScheduleType.cs

@@ -63,7 +63,7 @@ namespace EVCB_OCPP.Packet20.DataTypes
         /// Sales tariff associated with this charging
         /// schedule.
         /// </summary>
-        public SalesTariffType? SalesTariff { set; get; }
+        public SalesTariffType SalesTariff { set; get; }
 
 
 

+ 8 - 0
EVCB_OCPP.Packet20/EVCB_OCPP.Packet20.csproj

@@ -201,6 +201,11 @@
     <Compile Include="DataTypes\VariableMonitoringType.cs" />
     <Compile Include="DataTypes\VariableType.cs" />
     <Compile Include="DataTypes\VPNType.cs" />
+    <Compile Include="Features\CoreProfile.cs" />
+    <Compile Include="Features\Core\BootNotificationFeature.cs" />
+    <Compile Include="Features\Core\HeartbeatFeature.cs" />
+    <Compile Include="Features\Feature.cs" />
+    <Compile Include="Features\Profile.cs" />
     <Compile Include="Messages\AuthorizeRequest.cs" />
     <Compile Include="Messages\AuthorizeResponse.cs" />
     <Compile Include="Messages\BootNotificationRequest.cs" />
@@ -211,6 +216,9 @@
     <Compile Include="Messages\CertificateSignedResponse.cs" />
     <Compile Include="Messages\ChangeAvailabilityRequest.cs" />
     <Compile Include="Messages\ChangeAvailabilityResponse.cs" />
+    <Compile Include="Messages\IConfirmation.cs" />
+    <Compile Include="Messages\IRequest.cs" />
+    <Compile Include="Messages\IValidatable.cs" />
     <Compile Include="Messages\RequestStartTransactionRequest.cs" />
     <Compile Include="Messages\ClearCacheRequest.cs" />
     <Compile Include="Messages\ClearCacheResponse.cs" />

+ 27 - 0
EVCB_OCPP.Packet20/Features/Core/BootNotificationFeature.cs

@@ -0,0 +1,27 @@
+using EVCB_OCPP.Packet20.Messages;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Features.Core
+{
+    public class BootNotificationFeature : Feature
+    {
+        public override string GetAction()
+        {
+            return Actions.BootNotification.ToString();
+        }
+
+        public override Type GetConfirmationType()
+        {
+            return typeof(BootNotificationResponse);
+        }
+
+        public override Type GetRequestType()
+        {
+            return typeof(BootNotificationRequest);
+        }
+    }
+}

+ 27 - 0
EVCB_OCPP.Packet20/Features/Core/HeartbeatFeature.cs

@@ -0,0 +1,27 @@
+using EVCB_OCPP.Packet20.Messages;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Features.Core
+{
+    public class HeartbeatFeature : Feature
+    {
+        public override string GetAction()
+        {
+            return Actions.Heartbeat.ToString();
+        }
+
+        public override Type GetConfirmationType()
+        {
+            return typeof(HeartbeatResponse);
+        }
+
+        public override Type GetRequestType()
+        {
+            return typeof(HeartbeatRequest);
+        }
+    }
+}

+ 56 - 0
EVCB_OCPP.Packet20/Features/CoreProfile.cs

@@ -0,0 +1,56 @@
+using EVCB_OCPP.Packet20.Features.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Features
+{
+    public class CoreProfile : Profile
+    {
+        public CoreProfile()
+        {
+            Name = "Core";
+            //加入支援的Features
+            features.Add(new BootNotificationFeature());
+          //  features.Add(new GetConfigurationFeature());
+            features.Add(new HeartbeatFeature());
+            //features.Add(new StartTransactionFeature());
+            //features.Add(new ChangeConfigurationFeature());
+            //features.Add(new StatusNotificationFeature());
+            //features.Add(new StopTransactionFeature());
+            //features.Add(new MeterValuesFeature());
+            //features.Add(new RemoteStartTransactionFeature());
+            //features.Add(new RemoteStopTransactionFeature());
+            //features.Add(new ChangeAvailabilityFeature());
+            //features.Add(new AuthorizeFeature());
+            //features.Add(new ResetFeature());
+            //features.Add(new UnlockConnectorFeature());
+            //features.Add(new ClearCacheFeature());
+            //features.Add(new DataTransferFeature());
+
+            actions.Add(Actions.BootNotification.ToString());
+            actions.Add(Actions.GetConfiguration.ToString());
+            actions.Add(Actions.Heartbeat.ToString());
+            actions.Add(Actions.StartTransaction.ToString());
+            actions.Add(Actions.ChangeConfiguration.ToString());
+            actions.Add(Actions.StatusNotification.ToString());
+            actions.Add(Actions.Authorize.ToString());
+            actions.Add(Actions.StopTransaction.ToString());
+            actions.Add(Actions.MeterValues.ToString());
+            actions.Add(Actions.RemoteStartTransaction.ToString());
+            actions.Add(Actions.RemoteStopTransaction.ToString());
+            actions.Add(Actions.ChangeAvailability.ToString());
+            actions.Add(Actions.ClearCache.ToString());
+            actions.Add(Actions.DataTransfer.ToString());
+            actions.Add(Actions.Reset.ToString());
+            actions.Add(Actions.UnlockConnector.ToString());
+
+        }
+
+     
+
+
+    }
+}

+ 25 - 0
EVCB_OCPP.Packet20/Features/Feature.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Features
+{
+    /// <summary>
+    /// Abstract class. Feature ties {Request} and {Confirmation} types together with an action name.
+    /// Can handle a incoming request by forwarding it to the feature {Profile}.
+    /// </summary>
+    public abstract class Feature
+    {
+        /// <summary>
+        /// Get the {Request} for the feature.
+        /// return the {Request}
+        /// </summary>
+        public abstract Type GetRequestType();
+
+        public abstract Type GetConfirmationType();
+
+        public abstract string GetAction();
+    }
+}

+ 101 - 0
EVCB_OCPP.Packet20/Features/Profile.cs

@@ -0,0 +1,101 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Features
+{
+    public enum Actions
+    {
+        //Core
+        None,
+        BootNotification,
+        GetConfiguration,
+        Heartbeat,
+        StartTransaction,
+        ChangeConfiguration,
+        StatusNotification,
+        Authorize,
+        StopTransaction,
+        MeterValues,
+        RemoteStartTransaction,
+        RemoteStopTransaction,
+        ChangeAvailability,
+        ClearCache,
+        DataTransfer,
+        Reset,
+        UnlockConnector,
+        //FirmwareManagement
+        GetDiagnostics,
+        UpdateFirmware,
+        FirmwareStatusNotification,
+        DiagnosticsStatusNotification,
+        //LocalAuthListManagement
+        SendLocalList,
+        GetLocalListVersion,
+        //Reservation
+        CancelReservation,
+        ReserveNow,
+        //Remote Trigger
+        TriggerMessage,
+        //SmartCharging
+        ClearChargingProfile,
+        GetCompositeSchedule,
+        SetChargingProfile
+    }
+
+    public class Profile
+    {
+        public string Name { protected set; get; }
+
+        protected List<Feature> features = new List<Feature>();
+
+        protected List<string> actions = new List<string>();
+
+        public List<Feature> GetAllFeatures()
+        {
+            return features;
+        }
+
+        public string GetActionFromConfirmation(Type seekType)
+        {
+
+            var _feature = features.Where(x => x.GetConfirmationType() == seekType).FirstOrDefault();
+
+            return _feature == null ? string.Empty : _feature.GetAction();
+        }
+
+        public string GetActionFromRequest(Type seekType)
+        {
+            var feature = GetFeaturebyType(seekType);
+
+            return feature == null ? string.Empty : feature.GetAction();
+        }
+
+        public virtual Feature GetFeaturebyAction(string action)
+        {
+            return features.Where(x => x.GetAction() == action).FirstOrDefault(); ; ;
+        }
+
+        public virtual Feature GetFeaturebyType(Type seekType)
+        {
+
+            return features.Where(x => x.GetRequestType() == seekType).FirstOrDefault(); ;
+        }
+
+        public bool IsExisted(string action)
+        {
+            return actions.Contains(action);
+        }
+
+
+        public bool IsExisted(Actions action)
+        {
+            string _action = action.ToString();
+            return actions.Contains(_action);
+        }
+
+
+    }
+}

+ 18 - 1
EVCB_OCPP.Packet20/Messages/BootNotificationRequest.cs

@@ -1,5 +1,6 @@
 using EVCB_OCPP.Packet20.DataTypes;
 using EVCB_OCPP.Packet20.DataTypes.EnumTypes;
+using EVCB_OCPP.Packet20.Features;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Converters;
 using System;
@@ -11,7 +12,7 @@ using System.Threading.Tasks;
 
 namespace EVCB_OCPP.Packet20.Messages
 {
-    public class BootNotificationRequest
+    public class BootNotificationRequest : IRequest
     {
         [Required]
         [JsonConverter(typeof(StringEnumConverter))]
@@ -23,6 +24,22 @@ namespace EVCB_OCPP.Packet20.Messages
         [Required]
         public ChargingStationType ChargingStation { set; get; }
 
+        [JsonIgnore]
+        public string Action { set; get; }    
 
+        public BootNotificationRequest()
+        {
+            Action = Actions.BootNotification.ToString();
+        }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
     }
 }

+ 18 - 1
EVCB_OCPP.Packet20/Messages/BootNotificationResponse.cs

@@ -11,7 +11,7 @@ using System.Threading.Tasks;
 
 namespace EVCB_OCPP.Packet20.Messages
 {
-    public class BootNotificationResponse
+    public class BootNotificationResponse:IConfirmation
     {
         /// <summary>
         /// This contains the CSMS’s current time.
@@ -37,5 +37,22 @@ namespace EVCB_OCPP.Packet20.Messages
         [Required]
         [JsonConverter(typeof(StringEnumConverter))]
         public RegistrationStatusEnumType Status { set; get; }
+
+
+        private IRequest _request = null;
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
     }
 }

+ 33 - 2
EVCB_OCPP.Packet20/Messages/HeartbeatRequest.cs

@@ -1,13 +1,44 @@
-using System;
+using EVCB_OCPP.Packet20.Features;
+using Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
 namespace EVCB_OCPP.Packet20.Messages
 {
-    public class HeartbeatRequest
+    public class HeartbeatRequest:IRequest
     {
+        public HeartbeatRequest()
+        {
+            Action = Actions.Heartbeat.ToString();
+        }
 
+        private IRequest _request = null;
+
+        [JsonIgnore]
+        public string Action { set; get; }
+
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool TransactionRelated()
+        {
+            return false;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
     }
 }

+ 16 - 1
EVCB_OCPP.Packet20/Messages/HeartbeatResponse.cs

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 
 namespace EVCB_OCPP.Packet20.Messages
 {
-    public class HeartbeatResponse
+    public class HeartbeatResponse : IConfirmation
     {
         /// <summary>
         /// Contains the current time of the CSMS.
@@ -18,6 +18,21 @@ namespace EVCB_OCPP.Packet20.Messages
         [JsonConverter(typeof(UTCDateTimeConverter))]
         public DateTime CurrentTime { set; get; }
 
+        private IRequest _request = null;
 
+        public IRequest GetRequest()
+        {
+            return _request;
+        }
+
+        public void SetRequest(IRequest request)
+        {
+            _request = request;
+        }
+
+        public bool Validate()
+        {
+            return Validator.TryValidateObject(this, new ValidationContext(this), null, true);
+        }
     }
 }

+ 15 - 0
EVCB_OCPP.Packet20/Messages/IConfirmation.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Messages
+{
+    public interface IConfirmation : IValidatable
+    {
+        void SetRequest(IRequest request);
+
+        IRequest GetRequest();
+    }
+}

+ 19 - 0
EVCB_OCPP.Packet20/Messages/IRequest.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Messages
+{
+    public interface IRequest : IValidatable
+    {
+        string Action { get; set; }
+
+        /// <summary>
+        /// 是否是交易相關的Request
+        /// </summary>
+        /// <returns></returns>
+        bool TransactionRelated();
+    }
+}

+ 17 - 0
EVCB_OCPP.Packet20/Messages/IValidatable.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EVCB_OCPP.Packet20.Messages
+{
+    public interface IValidatable
+    {
+        /// <summary>
+        /// 驗證
+        /// </summary>
+        /// <returns></returns>
+        bool Validate();
+    }
+}

+ 2 - 1
EVCB_OCPP.Packet20/Messages/InstallCertificateResponse.cs

@@ -1,4 +1,5 @@
-using Newtonsoft.Json;
+using EVCB_OCPP.Packet20.DataTypes.EnumTypes;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Converters;
 using System;
 using System.Collections.Generic;

+ 1 - 0
EVCB_OCPP.Packet20/Messages/StatusNotificationRequest.cs

@@ -1,4 +1,5 @@
 using EVCB_OCPP.Packet20.DataTypes.EnumTypes;
+using EVCB_OCPP.Packet20.Utilites;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Converters;
 using System;