public final class

HostValidator.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.validation.HostValidator.Builder

Overview

Builder of HostValidator.

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

Summary

Constructors
publicBuilder(Context context)

Returns an empty HostValidator.Builder instance.

Methods
public HostValidator.BuilderaddAllowedHost(java.lang.String packageName, java.lang.String digest)

Adds a host to the allow list.

public HostValidator.BuilderaddAllowedHosts(int allowListedHostsRes)

Adds a hosts to the allow list.

public HostValidatorbuild()

Returns a new HostValidator

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context)

Returns an empty HostValidator.Builder instance.

Methods

public HostValidator.Builder addAllowedHost(java.lang.String packageName, java.lang.String digest)

Adds a host to the allow list.

Parameters:

packageName: host package name (as reported by PackageManager)
digest: 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

public HostValidator.Builder addAllowedHosts(int allowListedHostsRes)

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 HostValidator.Builder.addAllowedHost(String, String) for details on signature digest and package-name formatting.

Parameters:

allowListedHostsRes: string-array resource identifier

public HostValidator build()

Returns a new HostValidator