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 operation execution //Get data block 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 used for connection { verifier = new VerifierCodeLogonData() { //User, under whom log in to repository The user can be absent in DBMS server user = new UserId() { id = repoUser }, //The user used to connect to repository database on DBMS server. Password is stored in a protected form in BI server registry mbUser = new UserId() { id = dbLoginUser }, //Earlier obtained value used to set correspondence between digital signature and data block cookie = verifierCode.cookie, //Digital signature that must be checked by server signature = sign, //Certificate that will be used to check digital signature Must be saved in repository database certificate = "SPCERT" }, pass = string.Empty }, tDef = new MbDef() //Description of the repository, to which connection is established { id = mbDefinitionId } }; //Repository connection MbId mb = somClient.OpenMetabase(tOpen); return mb; }
See also: