summaryrefslogtreecommitdiffstats
path: root/packages/StatementService/src/com/android/statementservice/retriever/AbstractAsset.java
blob: bb6bdbb7a6d1c615a4321f0c20cc3733e4ca0c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.statementservice.retriever;

/**
 * A handle representing the identity and address of some digital asset. An asset is an online
 * entity that typically provides some service or content. Examples of assets are websites, Android
 * apps, Twitter feeds, and Plus Pages.
 *
 * <p> Asset can be represented by a JSON string. For example, the web site https://www.google.com
 * can be represented by
 * <pre>
 * {"namespace": "web", "site": "https://www.google.com"}
 * </pre>
 *
 * <p> The Android app with package name com.google.test that is signed by a certificate with sha256
 * fingerprint 11:22:33 can be represented by
 * <pre>
 * {"namespace": "android_app",
 *  "package_name": "com.google.test",
 *  "sha256_cert_fingerprints": ["11:22:33"]}
 * </pre>
 *
 * <p>Given a signed APK, Java 7's commandline keytool can compute the fingerprint using:
 * {@code keytool -list -printcert -jarfile signed_app.apk}
 */
public abstract class AbstractAsset {

    /**
     * Returns a JSON string representation of this asset. The strings returned by this function are
     * normalized -- they can be used for equality testing.
     */
    public abstract String toJson();

    /**
     * Returns a key that can be used by {@link AbstractAssetMatcher} to lookup the asset.
     *
     * <p> An asset will match an {@code AssetMatcher} only if the value of this method is equal to
     * {@code AssetMatcher.getMatchedLookupKey()}.
     */
    public abstract int lookupKey();

    /**
     * Creates a new Asset from its JSON string representation.
     *
     * @throws AssociationServiceException if the assetJson is not well formatted.
     */
    public static AbstractAsset create(String assetJson)
            throws AssociationServiceException {
        return AssetFactory.create(assetJson);
    }

    /**
     * If this is the source asset of a statement file, should the retriever follow
     * any insecure (non-HTTPS) include statements made by the asset.
     */
    public abstract boolean followInsecureInclude();
}