summaryrefslogtreecommitdiff
path: root/adservices/service-core/java/com/android/adservices/service/enrollment/EnrollmentData.java
blob: 6d0d0e49fabbd30004eae4504d5f17da7ca58a33 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
 * Copyright (C) 2022 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.adservices.service.enrollment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/** POJO for Adtech EnrollmentData, store the data download using MDD. */
public class EnrollmentData {

    private String mEnrollmentId;
    private String mCompanyId;
    private List<String> mSdkNames;
    private List<String> mAttributionSourceRegistrationUrl;
    private List<String> mAttributionTriggerRegistrationUrl;
    private List<String> mAttributionReportingUrl;
    private List<String> mRemarketingResponseBasedRegistrationUrl;
    private List<String> mEncryptionKeyUrl;

    private EnrollmentData() {
        mEnrollmentId = null;
        mCompanyId = null;
        mSdkNames = new ArrayList<>();
        mAttributionSourceRegistrationUrl = new ArrayList<>();
        mAttributionTriggerRegistrationUrl = new ArrayList<>();
        mAttributionReportingUrl = new ArrayList<>();
        mRemarketingResponseBasedRegistrationUrl = new ArrayList<>();
        mEncryptionKeyUrl = new ArrayList<>();
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof EnrollmentData)) {
            return false;
        }
        EnrollmentData enrollmentData = (EnrollmentData) obj;
        return Objects.equals(mEnrollmentId, enrollmentData.mEnrollmentId)
                && Objects.equals(mCompanyId, enrollmentData.mCompanyId)
                && Objects.equals(mSdkNames, enrollmentData.mSdkNames)
                && Objects.equals(
                        mAttributionSourceRegistrationUrl,
                        enrollmentData.mAttributionSourceRegistrationUrl)
                && Objects.equals(
                        mAttributionTriggerRegistrationUrl,
                        enrollmentData.mAttributionTriggerRegistrationUrl)
                && Objects.equals(mAttributionReportingUrl, enrollmentData.mAttributionReportingUrl)
                && Objects.equals(
                        mRemarketingResponseBasedRegistrationUrl,
                        enrollmentData.mRemarketingResponseBasedRegistrationUrl)
                && Objects.equals(mEncryptionKeyUrl, enrollmentData.mEncryptionKeyUrl);
    }

    @Override
    public int hashCode() {
        return Objects.hash(
                mEnrollmentId,
                mCompanyId,
                mSdkNames,
                mAttributionSourceRegistrationUrl,
                mAttributionTriggerRegistrationUrl,
                mAttributionReportingUrl,
                mRemarketingResponseBasedRegistrationUrl,
                mEncryptionKeyUrl);
    }

    /** Returns ID provided to the Adtech at the end of the enrollment process. */
    public String getEnrollmentId() {
        return mEnrollmentId;
    }

    /** Returns ID assigned to the Parent Company. */
    public String getCompanyId() {
        return mCompanyId;
    }

    /** List of SDKs belonging to the same enrollment. */
    public List<String> getSdkNames() {
        return mSdkNames;
    }

    /** Returns URLs used to register attribution sources for measurement. */
    public List<String> getAttributionSourceRegistrationUrl() {
        return mAttributionSourceRegistrationUrl;
    }

    /** Returns URLs used to register triggers for measurement. */
    public List<String> getAttributionTriggerRegistrationUrl() {
        return mAttributionTriggerRegistrationUrl;
    }

    /** Returns URLs that the Measurement module will send Attribution reports to. */
    public List<String> getAttributionReportingUrl() {
        return mAttributionReportingUrl;
    }

    /** Returns URLs used for response-based-registration for joinCustomAudience. */
    public List<String> getRemarketingResponseBasedRegistrationUrl() {
        return mRemarketingResponseBasedRegistrationUrl;
    }

    /** Returns URLs used to fetch public/private keys for encrypting API requests. */
    public List<String> getEncryptionKeyUrl() {
        return mEncryptionKeyUrl;
    }

    /** Builder for {@link EnrollmentData}. */
    public static final class Builder {
        private final EnrollmentData mBuilding;

        public Builder() {
            mBuilding = new EnrollmentData();
        }

        /** See {@link EnrollmentData#getEnrollmentId()}. */
        public Builder setEnrollmentId(String enrollmentId) {
            mBuilding.mEnrollmentId = enrollmentId;
            return this;
        }

        /** See {@link EnrollmentData#getCompanyId()}. */
        public Builder setCompanyId(String companyId) {
            mBuilding.mCompanyId = companyId;
            return this;
        }

        /** See {@link EnrollmentData#getSdkNames()} */
        public Builder setSdkNames(List<String> sdkNames) {
            mBuilding.mSdkNames = sdkNames;
            return this;
        }

        /** See {@link EnrollmentData#getSdkNames()} */
        public Builder setSdkNames(String sdkNames) {
            mBuilding.mSdkNames = Arrays.asList(sdkNames.split(" "));
            return this;
        }

        /** See {@link EnrollmentData#getAttributionSourceRegistrationUrl()}. */
        public Builder setAttributionSourceRegistrationUrl(
                List<String> attributionSourceRegistrationUrl) {
            mBuilding.mAttributionSourceRegistrationUrl = attributionSourceRegistrationUrl;
            return this;
        }

        /** See {@link EnrollmentData#getAttributionSourceRegistrationUrl()}. */
        public Builder setAttributionSourceRegistrationUrl(
                String attributionSourceRegistrationUrl) {
            mBuilding.mAttributionSourceRegistrationUrl =
                    Arrays.asList(attributionSourceRegistrationUrl.split(" "));
            return this;
        }

        /** See {@link EnrollmentData#getAttributionTriggerRegistrationUrl()}. */
        public Builder setAttributionTriggerRegistrationUrl(
                List<String> attributionTriggerRegistrationUrl) {
            mBuilding.mAttributionTriggerRegistrationUrl = attributionTriggerRegistrationUrl;
            return this;
        }

        /** See {@link EnrollmentData#getAttributionTriggerRegistrationUrl()}. */
        public Builder setAttributionTriggerRegistrationUrl(
                String attributionTriggerRegistrationUrl) {
            mBuilding.mAttributionTriggerRegistrationUrl =
                    Arrays.asList(attributionTriggerRegistrationUrl.split(" "));
            return this;
        }

        /** See {@link EnrollmentData#getAttributionReportingUrl()}. */
        public Builder setAttributionReportingUrl(List<String> attributionReportingUrl) {
            mBuilding.mAttributionReportingUrl = attributionReportingUrl;
            return this;
        }

        /** See {@link EnrollmentData#getAttributionReportingUrl()}. */
        public Builder setAttributionReportingUrl(String attributionReportingUrl) {
            mBuilding.mAttributionReportingUrl = Arrays.asList(attributionReportingUrl.split(" "));
            return this;
        }

        /** See {@link EnrollmentData#getRemarketingResponseBasedRegistrationUrl()}. */
        public Builder setRemarketingResponseBasedRegistrationUrl(
                List<String> remarketingResponseBasedRegistrationUrl) {
            mBuilding.mRemarketingResponseBasedRegistrationUrl =
                    remarketingResponseBasedRegistrationUrl;
            return this;
        }

        /** See {@link EnrollmentData#getRemarketingResponseBasedRegistrationUrl()}. */
        public Builder setRemarketingResponseBasedRegistrationUrl(
                String remarketingResponseBasedRegistrationUrl) {
            mBuilding.mRemarketingResponseBasedRegistrationUrl =
                    Arrays.asList(remarketingResponseBasedRegistrationUrl.split(" "));
            return this;
        }

        /** See {@link EnrollmentData#getEncryptionKeyUrl()}. */
        public Builder setEncryptionKeyUrl(List<String> encryptionKeyUrl) {
            mBuilding.mEncryptionKeyUrl = encryptionKeyUrl;
            return this;
        }

        /** See {@link EnrollmentData#getEncryptionKeyUrl()}. */
        public Builder setEncryptionKeyUrl(String encryptionKeyUrl) {
            mBuilding.mEncryptionKeyUrl = Arrays.asList(encryptionKeyUrl.split(" "));
            return this;
        }

        /** Builder the {@link EnrollmentData}. */
        public EnrollmentData build() {
            return mBuilding;
        }
    }
}