CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
x509_certificate.h
1
2#pragma once
3
4#include <defines.h>
5#include <system/object.h>
6#include <system/array.h>
7#include <system/idisposable.h>
8#include <system/date_time.h>
9#include <system/security/secure_string.h>
10#include <security/cryptography/x509_certificates/x509_content_type.h>
11#include <security/cryptography/x509_certificates/x509_key_storage_flags.h>
12#include <security/cryptography/hash_algorithm_name.h>
13
14namespace System { namespace Security { namespace Cryptography { namespace X509Certificates {
15
16class X500DistinguishedName;
17namespace Details { struct X509CertificateImpl; }
18
25class ASPOSECPP_SHARED_CLASS X509Certificate
26 : public virtual Object
27 , public IDisposable
28 // public IDeserializationCallback, public ISerializable
29{
30 RTTI_INFO(System::Security::Cryptography::X509Certificates::X509Certificate, ::System::BaseTypesInfo<System::Object>)
31
32public:
35
38
40 ASPOSECPP_SHARED_API X509Certificate();
43 ASPOSECPP_SHARED_API X509Certificate(const ByteArrayPtr& data);
46 ASPOSECPP_SHARED_API X509Certificate(const String& filename);
47
50 ASPOSECPP_SHARED_API X509Certificate(const SharedPtr<X509Certificate>& cert);
54 ASPOSECPP_SHARED_API X509Certificate(const ByteArrayPtr& raw_data, const String& password);
58 ASPOSECPP_SHARED_API X509Certificate(const ByteArrayPtr& raw_data, const SecureStringPtr& password);
62 ASPOSECPP_SHARED_API X509Certificate(const String& filename, const String& password);
66 ASPOSECPP_SHARED_API X509Certificate(const String& filename, const SecureStringPtr& password);
71 ASPOSECPP_SHARED_API X509Certificate(const ByteArrayPtr& raw_data, const String& password, X509KeyStorageFlags key_storage_flags);
76 ASPOSECPP_SHARED_API X509Certificate(const ByteArrayPtr& raw_data, const SecureStringPtr& password, X509KeyStorageFlags key_storage_flags);
81 ASPOSECPP_SHARED_API X509Certificate(const String& filename, const String& password, X509KeyStorageFlags key_storage_flags);
86 ASPOSECPP_SHARED_API X509Certificate(const String& filename, const SecureStringPtr& password, X509KeyStorageFlags key_storage_flags);
91 ASPOSECPP_SHARED_API X509Certificate(const ByteArrayPtr& raw_data, const ByteArrayPtr& private_key, X509KeyStorageFlags key_storage_flags);
92
93 ASPOSECPP_SHARED_API void Dispose() override;
94
97 ASPOSECPP_SHARED_API IntPtr get_Handle() const;
100 ASPOSECPP_SHARED_API String get_Subject() const;
103 ASPOSECPP_SHARED_API String get_Issuer() const;
104
107 virtual ASPOSECPP_SHARED_API ByteArrayPtr GetCertHash() const;
111 virtual ASPOSECPP_SHARED_API ByteArrayPtr GetCertHash(const HashAlgorithmName& hash_algorithm) const;
114 virtual ASPOSECPP_SHARED_API String GetCertHashString() const;
118 virtual ASPOSECPP_SHARED_API String GetCertHashString(const HashAlgorithmName& hash_algorithm) const;
121 virtual ASPOSECPP_SHARED_API String GetEffectiveDateString() const;
124 virtual ASPOSECPP_SHARED_API String GetExpirationDateString() const;
127 virtual ASPOSECPP_SHARED_API String GetFormat() const;
130 virtual ASPOSECPP_SHARED_API String GetIssuerName() const;
133 virtual ASPOSECPP_SHARED_API String GetKeyAlgorithm() const;
136 virtual ASPOSECPP_SHARED_API ByteArrayPtr GetKeyAlgorithmParameters() const;
139 virtual ASPOSECPP_SHARED_API String GetKeyAlgorithmParametersString() const;
142 virtual ASPOSECPP_SHARED_API String GetName() const;
145 virtual ASPOSECPP_SHARED_API ByteArrayPtr GetPublicKey() const;
148 virtual ASPOSECPP_SHARED_API String GetPublicKeyString() const;
151 virtual ASPOSECPP_SHARED_API ByteArrayPtr GetRawCertData() const;
154 virtual ASPOSECPP_SHARED_API String GetRawCertDataString() const;
157 virtual ASPOSECPP_SHARED_API ByteArrayPtr GetSerialNumber() const;
160 virtual ASPOSECPP_SHARED_API String GetSerialNumberString() const;
161
165 virtual ASPOSECPP_SHARED_API ByteArrayPtr Export(X509ContentType content_type) const;
170 virtual ASPOSECPP_SHARED_API ByteArrayPtr Export(X509ContentType content_type, const SecureStringPtr& password) const;
175 virtual ASPOSECPP_SHARED_API ByteArrayPtr Export(X509ContentType content_type, const String& password) const;
176
181 virtual ASPOSECPP_SHARED_API void Import(const String& filename, const SecureStringPtr& password, X509KeyStorageFlags key_storage_flags);
186 virtual ASPOSECPP_SHARED_API void Import(const String& filename, const String& password, X509KeyStorageFlags key_storage_flags);
191 virtual ASPOSECPP_SHARED_API void Import(const ByteArrayPtr& data, const SecureStringPtr& password, X509KeyStorageFlags key_storage_flags);
196 virtual ASPOSECPP_SHARED_API void Import(const ByteArrayPtr& data, const String& password, X509KeyStorageFlags key_storage_flags);
199 virtual ASPOSECPP_SHARED_API void Import(const String& filename);
202 virtual ASPOSECPP_SHARED_API void Import(const ByteArrayPtr& data);
203
205 virtual ASPOSECPP_SHARED_API void Reset();
206
210 ASPOSECPP_SHARED_API bool Equals(SharedPtr<Object> obj) override;
211
215 virtual ASPOSECPP_SHARED_API String ToString(bool verbose) const;
218 ASPOSECPP_SHARED_API String ToString() const override;
219
222 ASPOSECPP_SHARED_API int32_t GetHashCode() const override;
223
227 static ASPOSECPP_SHARED_API SharedPtr<X509Certificate> CreateFromCertFile(const String& filename);
231 static ASPOSECPP_SHARED_API SharedPtr<X509Certificate> CreateFromSignedFile(const String& filename);
232
233protected:
235 const std::unique_ptr<Details::X509CertificateImpl> m_pimpl;
236
237 ASPOSECPP_SHARED_API ~X509Certificate();
238
248
250};
251
252}}}} // namespace System::Security::Cryptography::X509Certificates
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
X.509 v.3 certificate. Encrypted certificates are not supported. Only X509KeyStorageFlags::DefaultKey...
Definition: x509_certificate.h:29
virtual String GetKeyAlgorithmParametersString() const
Gets key information for the current certificate as a hexadecimal string.
virtual void Import(const ByteArrayPtr &data, const String &password, X509KeyStorageFlags key_storage_flags)
Imports information from the specified certificate data. NOT IMPLEMENTED.
SharedPtr< X500DistinguishedName > GetIssuerNameInternal() const
X509Certificate(const ByteArrayPtr &raw_data, const ByteArrayPtr &private_key, X509KeyStorageFlags key_storage_flags)
Constructor.
virtual ByteArrayPtr Export(X509ContentType content_type, const String &password) const
Exports the current object to a byte array using the specified format. NOT IMPLEMENTED.
virtual void Import(const ByteArrayPtr &data)
Imports information from the specified certificate data. NOT IMPLEMENTED.
virtual void Reset()
Resets the certificate state.
virtual void Import(const String &filename, const SecureStringPtr &password, X509KeyStorageFlags key_storage_flags)
Imports information from the specified certificate file. NOT IMPLEMENTED.
virtual String GetEffectiveDateString() const
Gets effective date of the current sertificate.
X509Certificate(const SharedPtr< X509Certificate > &cert)
Constructor.
int32_t GetHashCode() const override
Gets certificate hash code.
bool Equals(SharedPtr< Object > obj) override
Compares two certificates.
virtual String GetPublicKeyString() const
Gets public key from certificate as a hexadecimal string.
virtual String ToString(bool verbose) const
Returns the certificate information in text format.
String get_Issuer() const
Gets name of the certificate authority that issued the X.509v3 certificate.
String ToString() const override
Returns the certificate information in text format.
virtual String GetKeyAlgorithm() const
Gets key information for the current certificate as a string.
virtual ByteArrayPtr GetCertHash() const
Gets hash for the current object as an array of bytes.
virtual ByteArrayPtr GetSerialNumber() const
Gets serial number from certificate as array of bytes.
virtual String GetCertHashString() const
Gets SHA1 hash for the current object as a hexadecimal string.
virtual void Import(const ByteArrayPtr &data, const SecureStringPtr &password, X509KeyStorageFlags key_storage_flags)
Imports information from the specified certificate data. NOT IMPLEMENTED.
IntPtr get_Handle() const
Gets a handle to Microsoft Cryptographic API certificate context.
virtual String GetFormat() const
Gets name of the certificate format.
String get_Subject() const
Gets subject distinguished name from certificate.
X509Certificate & operator=(const X509Certificate &)=delete
virtual ByteArrayPtr Export(X509ContentType content_type) const
Exports the current object to a byte array using the specified format. NOT IMPLEMENTED.
virtual String GetCertHashString(const HashAlgorithmName &hash_algorithm) const
Gets SHA1 hash for the current object as a hexadecimal string.
virtual ByteArrayPtr GetPublicKey() const
Gets public key from certificate as array of bytes.
X509Certificate(const String &filename, const String &password)
Constructor.
virtual void Import(const String &filename, const String &password, X509KeyStorageFlags key_storage_flags)
Imports information from the specified certificate file. NOT IMPLEMENTED.
virtual ByteArrayPtr GetCertHash(const HashAlgorithmName &hash_algorithm) const
Gets hash for the current object as an array of bytes.
virtual String GetIssuerName() const
Gets name of the certification authority that issued the current certificate.
virtual ByteArrayPtr Export(X509ContentType content_type, const SecureStringPtr &password) const
Exports the current object to a byte array using the specified format. NOT IMPLEMENTED.
virtual String GetExpirationDateString() const
Gets expiration date of the current sertificate.
SharedPtr< X509Certificate > Ptr
Pointer type.
Definition: x509_certificate.h:34
X509Certificate(const ByteArrayPtr &raw_data, const String &password, X509KeyStorageFlags key_storage_flags)
Constructor.
X509Certificate(const ByteArrayPtr &raw_data, const SecureStringPtr &password, X509KeyStorageFlags key_storage_flags)
Constructor.
virtual String GetName() const
Gets name of the principal to witch the current sertificate was issued.
SharedPtr< X500DistinguishedName > GetSubjectNameInternal() const
virtual void Import(const String &filename)
Imports information from the specified certificate file. NOT IMPLEMENTED.
const std::unique_ptr< Details::X509CertificateImpl > m_pimpl
Certificate implementation.
Definition: x509_certificate.h:235
X509Certificate(const ByteArrayPtr &raw_data, const String &password)
Constructor.
X509Certificate(const ByteArrayPtr &raw_data, const SecureStringPtr &password)
Constructor.
static SharedPtr< X509Certificate > CreateFromSignedFile(const String &filename)
Creates sertificate from the specified signed file.
static SharedPtr< X509Certificate > CreateFromCertFile(const String &filename)
Creates sertificate from the specified PKCS7 file.
X509Certificate(const String &filename, const SecureStringPtr &password)
Constructor.
virtual ByteArrayPtr GetRawCertData() const
Gets raw data from certificate as array of bytes.
X509Certificate(const String &filename, const String &password, X509KeyStorageFlags key_storage_flags)
Constructor.
X509Certificate(const String &filename, const SecureStringPtr &password, X509KeyStorageFlags key_storage_flags)
Constructor.
virtual String GetRawCertDataString() const
Gets raw data from certificate as a hexadecimal string.
virtual String GetSerialNumberString() const
Gets serial number from certificate as a hexadecimal string.
virtual ByteArrayPtr GetKeyAlgorithmParameters() const
Gets key information for the current certificate as an array of bytes.
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
X509ContentType
Format of X.509 certificate.
Definition: x509_content_type.h:10
X509KeyStorageFlags
Defines how to store key.
Definition: x509_key_storage_flags.h:12
Definition: db_command.h:9
String representing the name of a hash algorithm. This type should be allocated on stack and passed t...
Definition: hash_algorithm_name.h:13