PLCnext API Documentation  22.9.0.33
Asn1Time.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Core/AppDomainSingleton.hxx"
9 #include "Arp/System/Commons/Logging.h"
10 #include "Arp/System/Commons/Security/Internal/OpenSslBio.hpp"
11 #include <map>
12 #include <vector>
13 
14 #include <openssl/x509.h>
15 
16 using namespace Arp::System::Commons::Security::Internal;
17 
18 namespace Arp { namespace System { namespace Commons { namespace Security
19 {
20 
22 class Asn1Time : private Loggable<Asn1Time>
23 {
24 public: // typedefs
25 
26 public: // construction/destruction
28  Asn1Time(void);
30  Asn1Time(const Asn1Time& arg);
32  Asn1Time(const ASN1_TIME* arg);
34  ~Asn1Time(void);
35 
36 public: // operators
38  Asn1Time& operator=(const Asn1Time& arg);
39  Asn1Time& operator=(const ASN1_TIME* arg);
40  operator ASN1_TIME*() const;
41  operator DateTime() const;
42 
43 public: // static operations
51  static DateTime Asn1TimeToDateTime(const ASN1_TIME* pTime);
52 
60  static String Asn1TimeToIso8601String(const ASN1_TIME* pTime);
61 
62 public: // setter/getter operations
68  String GetTypeAsString(void) const;
69 
74  bool Set(const DateTime& time);
75 
76 public: // operations
81  DateTime ToDateTime(void) const;
82 
87  String ToString(void) const;
88 
93  String ToIso8601String(void) const;
94 
95 protected: // operations
96 
97 private: // static methods
98  static String DateTimeToTrimmedGeneralizedTime(const DateTime time);
99  bool GeneralizedTimeFitsForUtcTime(String timeStr);
100 
101 private: // methods
102 
103 protected: // fields
104  ASN1_TIME* internalAsn1Time;
105 
106 private: // fields
107 
108 private: // static fields
109 
110 };
111 
113 // inline methods of class Asn1Time
114 
115 inline Asn1Time::Asn1Time(const Asn1Time& arg)
116  : internalAsn1Time(nullptr)
117 {
118  *this = arg.internalAsn1Time;
119 }
120 
121 inline Asn1Time::Asn1Time(const ASN1_TIME* arg)
122  : internalAsn1Time(nullptr)
123 {
124  *this = arg;
125 }
126 
128 {
129  *this = arg.internalAsn1Time;
130  return *this;
131 }
132 
133 inline Asn1Time::operator ASN1_TIME*() const
134 {
135  return this->internalAsn1Time;
136 }
137 
138 inline Asn1Time::operator DateTime() const
139 {
140  return Asn1TimeToDateTime(this->internalAsn1Time);
141 }
142 
143 inline DateTime Asn1Time::ToDateTime(void) const
144 {
145  return Asn1TimeToDateTime(this->internalAsn1Time);
146 }
147 
149 {
150  return Asn1TimeToIso8601String(this->internalAsn1Time);
151 }
152 
153 }}}} // end of namespace Arp::System::Commons::Security
The class contains date and time informations.
Definition: DateTime.hpp:45
Helper class to handle ASN1Time objects in x.509 Certificates
Definition: Asn1Time.hpp:23
static String Asn1TimeToIso8601String(const ASN1_TIME *pTime)
Converst an OpenSSL ASN1_TIME object to an ISO8601 formated String DateTime
DateTime ToDateTime(void) const
Converts this object to DataTime DateTime
Definition: Asn1Time.hpp:143
Asn1Time(void)
Constructs an empty Asn1Time instance.
String GetTypeAsString(void) const
Return the type of the Internal ASN1_TIME object as String
String ToIso8601String(void) const
Converts this object to an ISO8601 formated String DateTime
Definition: Asn1Time.hpp:148
String ToString(void) const
Converts this object to String DateTime
static DateTime Asn1TimeToDateTime(const ASN1_TIME *pTime)
Converst an OpenSSL ASN1_TIME object to DataTime DateTime
bool Set(const DateTime &time)
Sets this Ans1Time from a DateTime
~Asn1Time(void)
Destructs this instance and frees all resources.
Asn1Time & operator=(const Asn1Time &arg)
Assignment operator.
Definition: Asn1Time.hpp:127
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API