mobile/android/base/NSSBridge.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/NSSBridge.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +package org.mozilla.gecko;
     1.9 +
    1.10 +import org.mozilla.gecko.mozglue.GeckoLoader;
    1.11 +
    1.12 +import android.content.Context;
    1.13 +import org.mozilla.gecko.mozglue.RobocopTarget;
    1.14 +
    1.15 +public class NSSBridge {
    1.16 +    private static final String LOGTAG = "NSSBridge";
    1.17 +
    1.18 +    private static native String nativeEncrypt(String aDb, String aValue);
    1.19 +    private static native String nativeDecrypt(String aDb, String aValue);
    1.20 +
    1.21 +    @RobocopTarget
    1.22 +    static public String encrypt(Context context, String aValue)
    1.23 +      throws Exception {
    1.24 +        String resourcePath = context.getPackageResourcePath();
    1.25 +        GeckoLoader.loadNSSLibs(context, resourcePath);
    1.26 +
    1.27 +        String path = GeckoProfile.get(context).getDir().toString();
    1.28 +        return nativeEncrypt(path, aValue);
    1.29 +    }
    1.30 +
    1.31 +    @RobocopTarget
    1.32 +    static public String encrypt(Context context, String profilePath, String aValue)
    1.33 +      throws Exception {
    1.34 +        String resourcePath = context.getPackageResourcePath();
    1.35 +        GeckoLoader.loadNSSLibs(context, resourcePath);
    1.36 +
    1.37 +        return nativeEncrypt(profilePath, aValue);
    1.38 +    }
    1.39 +
    1.40 +    @RobocopTarget
    1.41 +    static public String decrypt(Context context, String aValue)
    1.42 +      throws Exception {
    1.43 +        String resourcePath = context.getPackageResourcePath();
    1.44 +        GeckoLoader.loadNSSLibs(context, resourcePath);
    1.45 +
    1.46 +        String path = GeckoProfile.get(context).getDir().toString();
    1.47 +        return nativeDecrypt(path, aValue);
    1.48 +    }
    1.49 +
    1.50 +    @RobocopTarget
    1.51 +    static public String decrypt(Context context, String profilePath, String aValue)
    1.52 +      throws Exception {
    1.53 +        String resourcePath = context.getPackageResourcePath();
    1.54 +        GeckoLoader.loadNSSLibs(context, resourcePath);
    1.55 +
    1.56 +        return nativeDecrypt(profilePath, aValue);
    1.57 +    }
    1.58 +}

mercurial