OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file contains utility functions related to working with "facets". |
| 6 // |
| 7 // A "facet" is defined as the manifestation of a logical application on a given |
| 8 // platform. For example, "My Bank" may have released an Android application, |
| 9 // and a Web application accessible from a browser. These are all facets of the |
| 10 // "My Bank" logical application. |
| 11 // |
| 12 // Facets that belong to the same logical application are said to be affiliated |
| 13 // with each other. Conceptually, "affiliations" can be seen as an equivalence |
| 14 // relation defined over the set of all facets. Each equivalence class contains |
| 15 // facets that belong to the same logical application, and therefore should be |
| 16 // treated as synonymous for certain purposes, e.g., sharing credentials. |
| 17 // |
| 18 // A valid facet identifier will be of the form: |
| 19 // |
| 20 // * https://<host>[:<port>]/ |
| 21 // For web sites. Only HTTPS sites are supported, and URI must not contain |
| 22 // components other than the scheme, host, and a port (which is optional). |
| 23 // |
| 24 // * android://<cert_hash>@<package_name>/ |
| 25 // For Android applications. The <cert_hash> is the hash of the certificate |
| 26 // used to sign the APK, normally calculated as: |
| 27 // echo -n -e "$PEM_KEY" | \ |
| 28 // openssl x509 -outform DER | \ |
| 29 // openssl sha -sha512 -binary | base64 | tr '+/' '-_' |
| 30 |
| 31 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
| 32 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
| 33 |
| 34 #include <string> |
| 35 #include <vector> |
| 36 |
| 37 namespace password_manager { |
| 38 |
| 39 // A collection of facets affiliated with each other, i.e. an equivalence class. |
| 40 typedef std::vector<std::string> AffiliatedFacets; |
| 41 |
| 42 // The scheme used for identifying Android applications. |
| 43 extern const char kAndroidAppScheme[]; |
| 44 |
| 45 // Returns whether or not the supplied |uri| is a valid facet identifier. |
| 46 bool IsValidFacetURI(const std::string& uri); |
| 47 |
| 48 // Returns whether or not the supplied |uri| is a valid facet identifier that |
| 49 // refers to a web site. |
| 50 bool IsValidWebFacetURI(const std::string& uri); |
| 51 |
| 52 // Returns whether or not the supplied |uri| is a valid facet identifier that |
| 53 // refers to an Android app. Note that Chrome currently does not need to parse |
| 54 // these URIs, so this function only checks that the expected components are |
| 55 // present and will not actually verify their inner format. |
| 56 bool IsValidAndroidFacetURI(const std::string& uri); |
| 57 |
| 58 // Returns whether or not equivalence classes |a| and |b| are equal. |
| 59 bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, |
| 60 const AffiliatedFacets& b); |
| 61 |
| 62 } // namespace password_manager |
| 63 |
| 64 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
OLD | NEW |