| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.os.AsyncTask; | 9 import android.os.AsyncTask; |
| 10 import android.os.StrictMode; | 10 import android.os.StrictMode; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 * installed web apps and arbitrary other URLs. | 40 * installed web apps and arbitrary other URLs. |
| 41 */ | 41 */ |
| 42 public class WebappAuthenticator { | 42 public class WebappAuthenticator { |
| 43 private static final String TAG = "WebappAuthenticator"; | 43 private static final String TAG = "WebappAuthenticator"; |
| 44 private static final String MAC_ALGORITHM_NAME = "HmacSHA256"; | 44 private static final String MAC_ALGORITHM_NAME = "HmacSHA256"; |
| 45 private static final String MAC_KEY_BASENAME = "webapp-authenticator"; | 45 private static final String MAC_KEY_BASENAME = "webapp-authenticator"; |
| 46 private static final int MAC_KEY_BYTE_COUNT = 32; | 46 private static final int MAC_KEY_BYTE_COUNT = 32; |
| 47 private static final Object sLock = new Object(); | 47 private static final Object sLock = new Object(); |
| 48 | 48 |
| 49 private static FutureTask<SecretKey> sMacKeyGenerator; | 49 private static FutureTask<SecretKey> sMacKeyGenerator; |
| 50 private static SecretKey sKey = null; | 50 private static SecretKey sKey; |
| 51 | 51 |
| 52 private static final TimesHistogramSample sWebappValidationTimes = new Times
HistogramSample( | 52 private static final TimesHistogramSample sWebappValidationTimes = new Times
HistogramSample( |
| 53 "Android.StrictMode.WebappAuthenticatorMac", TimeUnit.MILLISECONDS); | 53 "Android.StrictMode.WebappAuthenticatorMac", TimeUnit.MILLISECONDS); |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * @see #getMacForUrl | 56 * @see #getMacForUrl |
| 57 * | 57 * |
| 58 * @param url The URL to validate. | 58 * @param url The URL to validate. |
| 59 * @param mac The bytes of a previously-calculated MAC. | 59 * @param mac The bytes of a previously-calculated MAC. |
| 60 * | 60 * |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 Mac mac = Mac.getInstance(MAC_ALGORITHM_NAME); | 237 Mac mac = Mac.getInstance(MAC_ALGORITHM_NAME); |
| 238 mac.init(key); | 238 mac.init(key); |
| 239 return mac; | 239 return mac; |
| 240 } catch (GeneralSecurityException e) { | 240 } catch (GeneralSecurityException e) { |
| 241 Log.w(TAG, "Error in creating MAC instance", e); | 241 Log.w(TAG, "Error in creating MAC instance", e); |
| 242 return null; | 242 return null; |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 } | 245 } |
| OLD | NEW |