ICertProvider.OpenVerifier

Fore Syntax

OpenVerifier(Name: String; Data: IIOStream): ICertVerifier;

Fore.NET Syntax

OpenVerifier(Name: String; Data: System.IO.Stream): Prognoz.Platform.Interop.Metabase.ICertVerifier;

Parameters

Name. Controller name.

Data. Stream linked to certificated.

Description

The OpenVerifier method returns controller which verifies digital signature using certificate sent in the specified stream.

Fore Example

Executing the example requires that repository base contains security certificate with the sp identifier.

Function SampleVerifier(Code: String; Signature: String): Boolean;
Var
    MB: IMetabase;
    Cert: ICertificate;
    Package: ISecurityPackage;
    Provider: ICertProvider;
    MStream: IMemoryStream;
    Verifier: ICertVerifier;
    Result: Boolean;
Begin
    MB := MetabaseClass.Active;
    //Get certificate
    Cert := MB.Security.Policy.Certificates.FindById("sp");
    MStream := New MemoryStream.Create;
    //Load certificate data to stream
    Cert.GetData(MStream);
    MStream.Position := 0;
    //Get controller
    Package := New StandardSecurityPackage.Create;
    Provider := Package.CertProvider;
    Verifier := Provider.OpenVerifier("sp", MStream);
    //Check digital signature
    Result := Verifier.Verify(Code, Signature);
    Return Result;
End Function SampleVerifier;

The specified function is used to check digital signature of data block. Random block and block digitally signed are sent as initial parameters. Certificate to be checked will be obtained from repository base and sent via the stream. Function result is a logical value indicating whether digital signature matches with sent random block of data.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Metabase;

Function SampleVerifier(MB: IMetabase; Code: String; Signature: String): Boolean;
Var
    Cert: ICertificate;
    Package: ISecurityPackage = New StandardSecurityPackageClass();
    Provider: ICertProvider;
    MStream: MemoryStream = New MemoryStream();
    Verifier: ICertVerifier;
    Result: Boolean;
Begin
    //Get certificate
    Cert := MB.Security.Policy.Certificates.FindById("sp");
    //Load certificate data to stream
    Cert.GetData(MStream);
    MStream.Position := 0;
    //Get controller
    Provider := Package.CertProvider;
    Verifier := Provider.OpenVerifier("sp", MStream);
    //Check digital signature
    Result := Verifier.Verify(Code, Signature);
    Return Result;
End Function;

See also:

ICertProvider