mobile/android/base/NSSBridge.java

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:f3ae954256e2
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/. */
4
5 package org.mozilla.gecko;
6
7 import org.mozilla.gecko.mozglue.GeckoLoader;
8
9 import android.content.Context;
10 import org.mozilla.gecko.mozglue.RobocopTarget;
11
12 public class NSSBridge {
13 private static final String LOGTAG = "NSSBridge";
14
15 private static native String nativeEncrypt(String aDb, String aValue);
16 private static native String nativeDecrypt(String aDb, String aValue);
17
18 @RobocopTarget
19 static public String encrypt(Context context, String aValue)
20 throws Exception {
21 String resourcePath = context.getPackageResourcePath();
22 GeckoLoader.loadNSSLibs(context, resourcePath);
23
24 String path = GeckoProfile.get(context).getDir().toString();
25 return nativeEncrypt(path, aValue);
26 }
27
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);
33
34 return nativeEncrypt(profilePath, aValue);
35 }
36
37 @RobocopTarget
38 static public String decrypt(Context context, String aValue)
39 throws Exception {
40 String resourcePath = context.getPackageResourcePath();
41 GeckoLoader.loadNSSLibs(context, resourcePath);
42
43 String path = GeckoProfile.get(context).getDir().toString();
44 return nativeDecrypt(path, aValue);
45 }
46
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);
52
53 return nativeDecrypt(profilePath, aValue);
54 }
55 }

mercurial