ICertCredentials.Signature

Syntax

Signature: String;

Description

The Signature property determines block of data digitally signed.

Comments

The certificate that is used to check digital signature should be saved with the repository description, to which the connection is made. To save the certificate, use the PP.Util application in Foresight Analytics Platform.

Example

Executing the example requires file with private certificate key which will be used to set digital signature. The certificate should be saved to the repository to which it is connected.

Function Connect(Repository: String; PrivateKeyPath: String): IMetabase;
Var
    MbDef: IMetabaseDefinition;
    Package: ISecurityPackage;
    Provider: ICertProvider;
    Cookie, Code, Signature: String;
    FStream: IFileStream;
    Signer: ICertSigner;
    CertCreds: ICertCredentials;
    Mb: IMetabase;
    MbManager: IMetabaseManager;
Begin
    MbManager := MetabaseManagerFactory.Active;
    MbDef := MbManager.Definitions.FindById(Repository);
    If MbDef <> Null Then
        Package := MbManager.Packs.FindById(MbDef.SecurityPackage).Package;
        //Certificate provider
        Provider := Package.CertProvider;
        Provider.NewCode(Cookie, Code);
        //Private key
        FStream := New FileStream.Create(PrivateKeyPath, FileOpenMode.Read, FileShare.DenyNone);
        Signer := Provider.OpenSigner("sp", FStream);
        //Digital signature of data block
        Signature := Signer.Sign(Code);
        //Credentials to connect using certificate
        CertCreds := Package.CreateCredentials(AuthenticationMode.Certificate) As ICertCredentials;
        CertCreds.UserName := "test";
        CertCreds.RolesStr := "ADMINISTRATOTRS";
        CertCreds.Cookie := Cookie;
        CertCreds.Signature := Signature;
        CertCreds.Certificate := "sp";
        //Connection
        Mb := MbDef.Open(CertCreds);
        If Mb <> Null Then
            Return Mb;
        Else
            Return Null;
        End If;
    Else
        Return Null;
    End If;
End Function Connect;

On executing the specified function, the check of the repository description specified in the first parameter is done. If repository exists, the connection to it is performed using digital signature. For digital signature, it is necessary to have private key, path to which is sent in the second parameter of the function. If connection is successful, the function returns open connection with repository, otherwise - Null.

See also:

ICertCredentials