Add(Id: String): ICertificate;
Add(System.String): Prognoz.Platform.Interop.Metabase.ICertificate;
Id. Identifier which will be assigned to the certificate.
The Add method adds certificate to the collection and returns its parameters.
To execute the example, add a security certificate to the file named sp.pem.
Add links to the Metabase, IO, ForeSystem (for Fore.NET example) system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MS: IMetabaseSecurity;
Certs: ICertificates;
Cert: ICertificate;
FStream: IFileStream;
Lic: Object;
Begin
MB := MetabaseClass.Active;
// Check out license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
MS := MB.Security;
Certs := MS.Policy.Certificates;
// Add a certificate
Cert := Certs.Add("sp");
// Load certificate from file
FStream := New FileStream.Create("C:\Certificates\sp.pem", FileOpenMode.Read, FileShare.DenyNone);
Cert.SetData(FStream);
// Save changes
MS.Apply;
// Check in license
Lic := Null;
End Sub UserProc;
Imports System.IO;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MS: IMetabaseSecurity;
Certs: ICertificates;
Cert: ICertificate;
FStream: FileStream = New FileStream("C:\Certificates\sp.pem", FileMode.Open, FileAccess.Read);
Lic: Object;
Begin
MB := Params.Metabase;
// Check out license to work with security manager
Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
MS := MB.Security;
Certs := MS.Policy.Certificates;
// Add a certificate
Cert := Certs.Add("sp");
// Load certificate from file
Cert.SetData(FStream);
// Save changes
MS.Apply();
// Release license
Lic := Null;
End Sub;
After executing the example, security certificate will be added to the repository base. Certificate contents will be loaded from the specified file.
See also: