java - How to load Google Cloud Datastore private key in Google PlayN -


we developing game using playn framework , we'll have global leaderboard stored in google cloud datastore. acquired private key needed accessing database, it's in .p12 file, assume it's in pkcs#12 format. right added file our game project's assets. (the structure of our projects standard hierarchy generated maven archetype). seems have 2 choices:

1: somehow create privatekey object , supply that:

// code copied datastorehelper source // note; 1 of setaccountprivatekeymethods must used. public credential getdatastorecredentials(string accountid) throws generalsecurityexception, ioexception {     nethttptransport transport = googlenethttptransport.newtrustedtransport();     jacksonfactory jsonfactory = new jacksonfactory();     return new googlecredential.builder()         .settransport(transport)         .setjsonfactory(jsonfactory)         .setserviceaccountid(accountid)         .setserviceaccountscopes(datastoreoptions.scopes)         .setserviceaccountprivatekey(new privatekey ???)  // <- cannot construct privatekey         .build(); } 

but seems cumbersome: creating privatekey object pkcs12 haven't found solution yet.

2: better way somehow hold of full path of pkcs#12 file in assets in platform independent way:

// code copied datastorehelper source // note; 1 of setaccountprivatekeymethods must used. public credential getdatastorecredentials(string accountid) throws generalsecurityexception, ioexception {     nethttptransport transport = googlenethttptransport.newtrustedtransport();     jacksonfactory jsonfactory = new jacksonfactory();     return new googlecredential.builder()         .settransport(transport)         .setjsonfactory(jsonfactory)         .setserviceaccountid(accountid)         .setserviceaccountscopes(datastoreoptions.scopes)         .setserviceaccountprivatekeyfromp12file(new file(???))  // <- acquire file path         .build(); } 

we exception in case, variations file path did not work. access files in assets importing playn.core.playn.assets, , calling assets(). example loading image image bgimage = assets().getimage("images/bg.png"); while loading json data little longer:

assets().gettext(jsonpath, new callback<string>() {   @override   public void onsuccess(string json) {     try {       parsejson(images, sprite, json);       .... 

but in our case we'd need full path (?) of file. target html5/css/js , android platform first, plan cover more platforms. looks android specific: how path android assets folder in application package


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -