| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.webapk.lib.client; | 5 package org.chromium.webapk.lib.client; |
| 6 | 6 |
| 7 import static org.chromium.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREF
IX; | 7 import static org.chromium.webapk.lib.common.WebApkConstants.WEBAPK_PACKAGE_PREF
IX; |
| 8 | 8 |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 return null; | 77 return null; |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Returns whether the provided WebAPK is installed and passes signature che
cks. | 81 * Returns whether the provided WebAPK is installed and passes signature che
cks. |
| 82 * @param context A context | 82 * @param context A context |
| 83 * @param webappPackageName The package name to check | 83 * @param webappPackageName The package name to check |
| 84 * @return true iff the WebAPK is installed and passes security checks | 84 * @return true iff the WebAPK is installed and passes security checks |
| 85 */ | 85 */ |
| 86 private static boolean isValidWebApk(Context context, String webappPackageNa
me) { | 86 public static boolean isValidWebApk(Context context, String webappPackageNam
e) { |
| 87 if (sExpectedSignature == null) { | 87 if (sExpectedSignature == null) { |
| 88 Log.wtf(TAG, "WebApk validation failure - expected signature not set
." | 88 Log.wtf(TAG, "WebApk validation failure - expected signature not set
." |
| 89 + "missing call to WebApkValidator.initWithBrowserHostSignat
ure"); | 89 + "missing call to WebApkValidator.initWithBrowserHostSignat
ure"); |
| 90 } | 90 } |
| 91 // check signature | 91 // check signature |
| 92 PackageInfo packageInfo = null; | 92 PackageInfo packageInfo = null; |
| 93 try { | 93 try { |
| 94 packageInfo = context.getPackageManager().getPackageInfo(webappPacka
geName, | 94 packageInfo = context.getPackageManager().getPackageInfo(webappPacka
geName, |
| 95 PackageManager.GET_SIGNATURES); | 95 PackageManager.GET_SIGNATURES); |
| 96 } catch (NameNotFoundException e) { | 96 } catch (NameNotFoundException e) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 117 * with for the current host. | 117 * with for the current host. |
| 118 * @param expectedSignature | 118 * @param expectedSignature |
| 119 */ | 119 */ |
| 120 public static void initWithBrowserHostSignature(byte[] expectedSignature) { | 120 public static void initWithBrowserHostSignature(byte[] expectedSignature) { |
| 121 if (sExpectedSignature != null) { | 121 if (sExpectedSignature != null) { |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 sExpectedSignature = Arrays.copyOf(expectedSignature, expectedSignature.
length); | 124 sExpectedSignature = Arrays.copyOf(expectedSignature, expectedSignature.
length); |
| 125 } | 125 } |
| 126 } | 126 } |
| OLD | NEW |