Below is the example of using the OpenMetabase operation to connect to a repository using digital signature. The certificate with the SPCERT identifier must be saved in the repository. The requested block is signed using the PFX certificate named sp.pfx.
{
"OpenMetabase" :
{
"tDef" :
{
"id" : "PPREPOSITORY"
},
"tCreds" :
{
"pass" : "",
"verifier" :
{
"mbUser" :
{
"id" : "pprepository"
},
"user" :
{
"id" : "user@test.ru"
},
"certificate" : "SPCERT",
"cookie" : "1437524055",
"signature" : "AjTHCXJx6hs28GFsUNqrQlHoRSM6Zrj6Ax40n1nO+uE5zhVL9c8e5WFq4FUalSLWGIVWU0ymkEfVu62gzSn35yAen1kbtjOeQagbX0kG5MQhjVYMk8IVV8bLRIAUbuDah4vxlqTBjvPRsTFy5QU1pr0cYZdmHwdQSPKu7kZ9jS\/b1TOkPyRm8QrywVAU5MdqqR5oCN9qzAvDktTJXPU2a4BL0lRCAJuy0aYTXRU07J0Z5Jek2rUTQpJ1Qn7+zxew23SG\/M1Ma8w6k9+YQn5pokh43xbkpKPScbQOeho+NNpHFP\/yGN6PmeCCvltjOiuiGyn2XeSkMvSpmGVP+Z4NCQ=="
}
},
"tArg" : ""
}
}
{
"OpenMetabaseResult" :
{
"id" : "S1!M"
}
}
The parameters required for connection are sent as input parameters of the function. The result of the operation is the result of the function.
public static MbId MetabaseConnectWithDigitalSign(string mbDefinitionId, string repoUser, string dbLoginUser)
{
var somClient = new SomPortTypeClient(); //Proxy object for executing operations
//Get data block that will be signed with digital signature
var verifierCode = somClient.GetVerifierCode(new GetVerifierCode() { });
//Open pfx certificate and get signature key from it
var x509 = new X509Certificate2(@"../../sp.pfx");
RSACryptoServiceProvider rsa = x509.PrivateKey as RSACryptoServiceProvider;
//Calculate MD5 hash from previously obtained data and sign this hash with RSA digital signature
var sign = rsa.SignData(verifierCode.verifierCode, new MD5CryptoServiceProvider());
//Operation execution parameters
var tOpen = new OpenMetabase()
{
tArg = new OpenMetabaseArg() { },
tCreds = new UserCreds() //Credentials that are used for connection
{
verifier = new VerifierCodeLogonData()
{
//User that is used to enter the repository. This used can be not present in DBMS
user = new UserId() { id = repoUser },
//User that is used for repository database connection. Password is stored in protected registry on BI server
mbUser = new UserId() { id = dbLoginUser },
//Previously obtained value that is used to get correspondence between digital signature and data block
cookie = verifierCode.cookie,
//Digital signature that is to be verified by server
signature = sign,
//Certificate that will be used for digital signature verification. It must be saved in repository base
certificate = "SPCERT"
},
pass = string.Empty
},
tDef = new MbDef() //Description of repository be connected to
{
id = mbDefinitionId
}
};
//Repository connection
MbId mb = somClient.OpenMetabase(tOpen);
return mb;
See also:
SOAP