PLCnext API Documentation 23.0.2.9
Asn1Time.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
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
16using namespace Arp::System::Commons::Security::Internal;
17
18namespace Arp { namespace System { namespace Commons { namespace Security
19{
20
22class Asn1Time : private Loggable<Asn1Time>
23{
24public: // typedefs
25
26public: // construction/destruction
28 Asn1Time(void);
30 Asn1Time(const Asn1Time& arg);
32 Asn1Time(const ASN1_TIME* arg);
34 ~Asn1Time(void);
35
36public: // operators
38 Asn1Time& operator=(const Asn1Time& arg);
39 Asn1Time& operator=(const ASN1_TIME* arg);
40 operator ASN1_TIME*() const;
41 operator DateTime() const;
42
43public: // static operations
51 static DateTime Asn1TimeToDateTime(const ASN1_TIME* pTime);
52
60 static String Asn1TimeToIso8601String(const ASN1_TIME* pTime);
61
62public: // setter/getter operations
69
74 bool Set(const DateTime& time);
75
76public: // operations
81 DateTime ToDateTime(void) const;
82
87 String ToString(void) const;
88
93 String ToIso8601String(void) const;
94
95protected: // operations
96
97private: // static methods
98 static String DateTimeToTrimmedGeneralizedTime(const DateTime time);
99 bool GeneralizedTimeFitsForUtcTime(String timeStr);
100
101private: // methods
102
103protected: // fields
104 ASN1_TIME* internalAsn1Time;
105
106private: // fields
107
108private: // static fields
109
110};
111
113// inline methods of class Asn1Time
114
115inline Asn1Time::Asn1Time(const Asn1Time& arg)
116 : internalAsn1Time(nullptr)
117{
118 *this = arg.internalAsn1Time;
119}
120
121inline 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
133inline Asn1Time::operator ASN1_TIME*() const
134{
135 return this->internalAsn1Time;
136}
137
138inline Asn1Time::operator DateTime() const
139{
140 return Asn1TimeToDateTime(this->internalAsn1Time);
141}
142
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