Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.gecko;
7 import org.mozilla.gecko.mozglue.GeckoLoader;
9 import android.content.Context;
10 import org.mozilla.gecko.mozglue.RobocopTarget;
12 public class NSSBridge {
13 private static final String LOGTAG = "NSSBridge";
15 private static native String nativeEncrypt(String aDb, String aValue);
16 private static native String nativeDecrypt(String aDb, String aValue);
18 @RobocopTarget
19 static public String encrypt(Context context, String aValue)
20 throws Exception {
21 String resourcePath = context.getPackageResourcePath();
22 GeckoLoader.loadNSSLibs(context, resourcePath);
24 String path = GeckoProfile.get(context).getDir().toString();
25 return nativeEncrypt(path, aValue);
26 }
28 @RobocopTarget
29 static public String encrypt(Context context, String profilePath, String aValue)
30 throws Exception {
31 String resourcePath = context.getPackageResourcePath();
32 GeckoLoader.loadNSSLibs(context, resourcePath);
34 return nativeEncrypt(profilePath, aValue);
35 }
37 @RobocopTarget
38 static public String decrypt(Context context, String aValue)
39 throws Exception {
40 String resourcePath = context.getPackageResourcePath();
41 GeckoLoader.loadNSSLibs(context, resourcePath);
43 String path = GeckoProfile.get(context).getDir().toString();
44 return nativeDecrypt(path, aValue);
45 }
47 @RobocopTarget
48 static public String decrypt(Context context, String profilePath, String aValue)
49 throws Exception {
50 String resourcePath = context.getPackageResourcePath();
51 GeckoLoader.loadNSSLibs(context, resourcePath);
53 return nativeDecrypt(profilePath, aValue);
54 }
55 }