1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.adservices.data.adselection.datahandlers;
18 
19 import android.annotation.NonNull;
20 
21 import com.android.adservices.ohttp.ObliviousHttpRequestContext;
22 import com.android.adservices.service.adselection.encryption.AdSelectionEncryptionKey;
23 
24 import com.google.auto.value.AutoValue;
25 
26 /**
27  * Data class representing the context used for encrypting the ad selection run payload generated
28  * for server auction.
29  */
30 @AutoValue
31 public abstract class EncryptionContext {
32 
33     /** Encryption key type used for encryption. */
34     @AdSelectionEncryptionKey.AdSelectionEncryptionKeyType
getAdSelectionEncryptionKeyType()35     public abstract int getAdSelectionEncryptionKeyType();
36 
37     /** ObliviousHttpRequestContext used for encryption. */
38     @NonNull
getOhttpRequestContext()39     public abstract ObliviousHttpRequestContext getOhttpRequestContext();
40 
41     /**
42      * @return generic builder
43      */
44     @NonNull
builder()45     public static Builder builder() {
46         return new AutoValue_EncryptionContext.Builder();
47     }
48 
49     /** Builder for EncryptionContext. */
50     @AutoValue.Builder
51     public abstract static class Builder {
52 
53         /** Sets the encryption key type used for encryption. */
setAdSelectionEncryptionKeyType( @dSelectionEncryptionKey.AdSelectionEncryptionKeyType int encryptionKeyType)54         public abstract Builder setAdSelectionEncryptionKeyType(
55                 @AdSelectionEncryptionKey.AdSelectionEncryptionKeyType int encryptionKeyType);
56 
57         /** Sets the obliviousHttpRequestContext used for encryption. */
setOhttpRequestContext( @onNull ObliviousHttpRequestContext requestContext)58         public abstract Builder setOhttpRequestContext(
59                 @NonNull ObliviousHttpRequestContext requestContext);
60 
61         /** Builds a {@link EncryptionContext} object. */
62         @NonNull
build()63         public abstract EncryptionContext build();
64     }
65 }
66