HostValidator.Builder

class HostValidator.Builder


Builder of HostValidator.

Allows applications to customize the HostValidator that will be used to verify whether a caller is a valid templates host.

Summary

Public constructors

Builder(context: Context)

Returns an empty Builder instance.

Public functions

HostValidator.Builder
addAllowedHost(packageName: String, digest: String)

Adds a host to the allow list.

HostValidator.Builder
addAllowedHosts(allowListedHostsRes: @ArrayRes Int)

Adds a hosts to the allow list.

HostValidator

Returns a new HostValidator

Public constructors

Builder

Added in 1.0.0
Builder(context: Context)

Returns an empty Builder instance.

Public functions

addAllowedHost

Added in 1.0.0
fun addAllowedHost(packageName: String, digest: String): HostValidator.Builder

Adds a host to the allow list.

Parameters
packageName: String

host package name (as reported by PackageManager)

digest: String

SHA256 digest of the DER encoding of the allow-listed host certificate, formatted as 32 lowercase 2 digits hexadecimal values separated by colon (e.g.:"000102030405060708090a0b0c0d0e0f101112131415 161718191a1b1c1d1e1f"). When using signature rotation, this digest should correspond to the initial signing certificate

addAllowedHosts

Added in 1.0.0
fun addAllowedHosts(allowListedHostsRes: @ArrayRes Int): HostValidator.Builder

Adds a hosts to the allow list.

Allow-listed hosts are retrieved from a string-array resource, encoded as [digest,package-name] pairs separated by comma. See addAllowedHost for details on signature digest and package-name formatting.

Parameters
allowListedHostsRes: @ArrayRes Int

string-array resource identifier

Throws
java.lang.IllegalArgumentException

if the provided resource doesn't exist or if the entries in the given resource are not formatted as expected

build

Added in 1.0.0
fun build(): HostValidator

Returns a new HostValidator