/
RegistryConfig.java
1289 lines (1173 loc) · 44.8 KB
/
RegistryConfig.java
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// 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 google.registry.config;
import static com.google.common.base.Suppliers.memoize;
import static google.registry.config.ConfigUtils.makeUrl;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.HostAndPort;
import dagger.Module;
import dagger.Provides;
import google.registry.config.RegistryConfigSettings.AppEngine.ToolsServiceUrl;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.net.URI;
import java.net.URL;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import javax.annotation.Nullable;
import javax.inject.Named;
import javax.inject.Qualifier;
import javax.inject.Singleton;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTimeConstants;
import org.joda.time.Duration;
/**
* Central clearing-house for all configuration.
*
* <p>This class does not represent the total configuration of the Nomulus service. It's <b>only
* meant for settings that need to be configured <i>once</i></b>. Settings which may be subject to
* change in the future, should instead be retrieved from Datastore. The {@link
* google.registry.model.registry.Registry Registry} class is one such example of this.
*/
public final class RegistryConfig {
/** Dagger qualifier for configuration settings. */
@Qualifier
@Retention(RUNTIME)
@Documented
public static @interface Config {
String value() default "";
}
/** Dagger module for providing configuration settings. */
@Module
public static final class ConfigModule {
private static final RegistryEnvironment REGISTRY_ENVIRONMENT = RegistryEnvironment.get();
@Provides
public static RegistryEnvironment provideRegistryEnvironment() {
return REGISTRY_ENVIRONMENT;
}
@Provides
@Config("projectId")
public static String provideProjectId(RegistryConfigSettings config) {
return config.appEngine.projectId;
}
/**
* The filename of the logo to be displayed in the header of the registrar console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("logoFilename")
public static String provideLogoFilename(RegistryConfigSettings config) {
return config.registrarConsole.logoFilename;
}
/**
* The product name of this specific registry. Used throughout the registrar console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("productName")
public static String provideProductName(RegistryConfigSettings config) {
return config.registryPolicy.productName;
}
/**
* Returns the roid suffix to be used for the roids of all contacts and hosts. E.g. a value of
* "ROID" would end up creating roids that look like "ABC123-ROID".
*
* @see <a href="http://www.iana.org/assignments/epp-repository-ids/epp-repository-ids.xhtml">
* Extensible Provisioning Protocol (EPP) Repository Identifiers</a>
*/
@Provides
@Config("contactAndHostRoidSuffix")
public static String provideContactAndHostRoidSuffix(RegistryConfigSettings config) {
return config.registryPolicy.contactAndHostRoidSuffix;
}
/**
* The e-mail address for questions about integrating with the registry. Used in the
* "contact-us" section of the registrar console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("integrationEmail")
public static String provideIntegrationEmail(RegistryConfigSettings config) {
return config.registrarConsole.integrationEmailAddress;
}
/**
* The e-mail address for general support. Used in the "contact-us" section of the registrar
* console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("supportEmail")
public static String provideSupportEmail(RegistryConfigSettings config) {
return config.registrarConsole.supportEmailAddress;
}
/**
* The "From" e-mail address for announcements. Used in the "contact-us" section of the
* registrar console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("announcementsEmail")
public static String provideAnnouncementsEmail(RegistryConfigSettings config) {
return config.registrarConsole.announcementsEmailAddress;
}
/**
* The contact phone number. Used in the "contact-us" section of the registrar console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("supportPhoneNumber")
public static String provideSupportPhoneNumber(RegistryConfigSettings config) {
return config.registrarConsole.supportPhoneNumber;
}
/**
* The URL for technical support docs. Used in the "contact-us" section of the registrar
* console.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("technicalDocsUrl")
public static String provideTechnicalDocsUrl(RegistryConfigSettings config) {
return config.registrarConsole.technicalDocsUrl;
}
/**
* Returns the Google Cloud Storage bucket for storing zone files.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
@Provides
@Config("zoneFilesBucket")
public static String provideZoneFilesBucket(@Config("projectId") String projectId) {
return projectId + "-zonefiles";
}
/**
* Returns the Google Cloud Storage bucket for storing commit logs.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
@Provides
@Config("commitLogGcsBucket")
public static String provideCommitLogGcsBucket(@Config("projectId") String projectId) {
return projectId + "-commits";
}
/** @see RegistryConfig#getCommitLogDatastoreRetention() */
@Provides
@Config("commitLogDatastoreRetention")
public static Duration provideCommitLogDatastoreRetention() {
return RegistryConfig.getCommitLogDatastoreRetention();
}
/**
* The GCS bucket for exporting domain lists.
*
* @see google.registry.export.ExportDomainListsAction
*/
@Provides
@Config("domainListsGcsBucket")
public static String provideDomainListsGcsBucket(@Config("projectId") String projectId) {
return projectId + "-domain-lists";
}
/**
* Batch size for the number of transactions' worth of commit log data to process at once when
* exporting a commit log diff.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
@Provides
@Config("commitLogDiffExportBatchSize")
public static int provideCommitLogDiffExportBatchSize() {
return 100;
}
/**
* Returns the Google Cloud Storage bucket for staging BRDA escrow deposits.
*
* @see google.registry.rde.PendingDepositChecker
*/
@Provides
@Config("brdaBucket")
public static String provideBrdaBucket(@Config("projectId") String projectId) {
return projectId + "-icann-brda";
}
/** @see google.registry.rde.BrdaCopyAction */
@Provides
@Config("brdaDayOfWeek")
public static int provideBrdaDayOfWeek() {
return DateTimeConstants.TUESDAY;
}
/**
* Amount of time between BRDA deposits.
*
* @see google.registry.rde.PendingDepositChecker
*/
@Provides
@Config("brdaInterval")
public static Duration provideBrdaInterval() {
return Duration.standardDays(7);
}
/**
* The maximum number of domain and host updates to batch together to send to
* PublishDnsUpdatesAction, to avoid exceeding AppEngine's limits.
*
* @see google.registry.dns.ReadDnsQueueAction
*/
@Provides
@Config("dnsTldUpdateBatchSize")
public static int provideDnsTldUpdateBatchSize() {
return 100;
}
/**
* The maximum interval (seconds) to lease tasks from the dns-pull queue.
*
* @see google.registry.dns.ReadDnsQueueAction
* @see google.registry.dns.PublishDnsUpdatesAction
*/
@Provides
@Config("dnsWriteLockTimeout")
public static Duration provideDnsWriteLockTimeout() {
/*
* Optimally, we would set this to a little less than the length of the DNS refresh cycle,
* since otherwise, a new PublishDnsUpdatesAction could get kicked off before the current one
* has finished, which will try and fail to acquire the lock. However, it is more important
* that it be greater than the DNS write timeout, so that if that timeout occurs, it will be
* cleaned up gracefully, rather than having the lock time out. So we have to live with the
* possible lock failures.
*/
return Duration.standardSeconds(75);
}
/**
* Returns the default time to live for DNS A and AAAA records.
*
* @see google.registry.dns.writer.clouddns.CloudDnsWriter
*/
@Provides
@Config("dnsDefaultATtl")
public static Duration provideDnsDefaultATtl() {
return Duration.standardMinutes(3);
}
/**
* Returns the default time to live for DNS NS records.
*
* @see google.registry.dns.writer.clouddns.CloudDnsWriter
*/
@Provides
@Config("dnsDefaultNsTtl")
public static Duration provideDnsDefaultNsTtl() {
return Duration.standardMinutes(3);
}
/**
* Returns the default time to live for DNS DS records.
*
* @see google.registry.dns.writer.clouddns.CloudDnsWriter
*/
@Provides
@Config("dnsDefaultDsTtl")
public static Duration provideDnsDefaultDsTtl() {
return Duration.standardMinutes(3);
}
/**
* Number of sharded entity group roots used for performing strongly consistent scans.
*
* <p><b>Warning:</b> This number may increase but never decrease.
*
* @see google.registry.model.index.EppResourceIndex
*/
@Provides
@Config("eppResourceIndexBucketCount")
public static int provideEppResourceIndexBucketCount(RegistryConfigSettings config) {
return config.datastore.eppResourceIndexBucketsNum;
}
@Provides
@Config("cloudDnsRootUrl")
public static Optional<String> getCloudDnsRootUrl(RegistryConfigSettings config) {
return Optional.ofNullable(config.cloudDns.rootUrl);
}
@Provides
@Config("cloudDnsServicePath")
public static Optional<String> getCloudDnsServicePath(RegistryConfigSettings config) {
return Optional.ofNullable(config.cloudDns.servicePath);
}
/**
* Returns size of Google Cloud Storage client connection buffer in bytes.
*
* @see google.registry.gcs.GcsUtils
*/
@Provides
@Config("gcsBufferSize")
public static int provideGcsBufferSize() {
return 1024 * 1024;
}
/**
* Returns the email address of the admin account on the G Suite app used to perform
* administrative actions.
*
* @see google.registry.groups.DirectoryGroupsConnection
*/
@Provides
@Config("gSuiteAdminAccountEmailAddress")
public static String provideGSuiteAdminAccountEmailAddress(RegistryConfigSettings config) {
return config.gSuite.adminAccountEmailAddress;
}
/**
* Returns the email address(es) that notifications of registrar and/or registrar contact
* updates should be sent to, or the empty list if updates should not be sent.
*
* @see google.registry.ui.server.registrar.RegistrarSettingsAction
*/
@Provides
@Config("registrarChangesNotificationEmailAddresses")
public static ImmutableList<String> provideRegistrarChangesNotificationEmailAddresses(
RegistryConfigSettings config) {
return ImmutableList.copyOf(config.registryPolicy.registrarChangesNotificationEmailAddresses);
}
/**
* Returns the publicly accessible domain name for the running G Suite instance.
*
* @see google.registry.export.SyncGroupMembersAction
* @see google.registry.tools.server.CreateGroupsAction
*/
@Provides
@Config("gSuiteDomainName")
public static String provideGSuiteDomainName(RegistryConfigSettings config) {
return config.gSuite.domainName;
}
/**
* Returns the mode that TMCH certificate authority should run in.
*
* @see google.registry.tmch.TmchCertificateAuthority
*/
@Provides
@Config("tmchCaMode")
public static TmchCaMode provideTmchCaMode(RegistryConfigSettings config) {
return TmchCaMode.valueOf(config.registryPolicy.tmchCaMode);
}
/** The mode that the {@code TmchCertificateAuthority} operates in. */
public enum TmchCaMode {
/** Production mode, suitable for live environments hosting TLDs. */
PRODUCTION,
/** Pilot mode, for everything else (e.g. sandbox). */
PILOT;
}
/**
* ICANN TMCH Certificate Revocation List URL.
*
* <p>This file needs to be downloaded at least once a day and verified to make sure it was
* signed by {@code icann-tmch.crt} or {@code icann-tmch-pilot.crt} depending on TMCH CA mode.
*
* @see google.registry.tmch.TmchCrlAction
* @see <a href="http://tools.ietf.org/html/draft-lozano-tmch-func-spec-08#section-5.2.3.2">TMCH
* RFC</a>
*/
@Provides
@Config("tmchCrlUrl")
public static URL provideTmchCrlUrl(RegistryConfigSettings config) {
return makeUrl(config.registryPolicy.tmchCrlUrl);
}
/**
* URL prefix for communicating with MarksDB ry interface.
*
* <p>This URL is used for DNL, SMDRL, and LORDN.
*
* @see google.registry.tmch.Marksdb
* @see google.registry.tmch.NordnUploadAction
*/
@Provides
@Config("tmchMarksdbUrl")
public static String provideTmchMarksdbUrl(RegistryConfigSettings config) {
return config.registryPolicy.tmchMarksDbUrl;
}
/**
* The email address that outgoing emails from the app are sent from.
*
* @see google.registry.ui.server.registrar.SendEmailUtils
*/
@Provides
@Config("gSuiteOutgoingEmailAddress")
public static String provideGSuiteOutgoingEmailAddress(RegistryConfigSettings config) {
return config.gSuite.outgoingEmailAddress;
}
/**
* The display name that is used on outgoing emails sent by Nomulus.
*
* @see google.registry.ui.server.registrar.SendEmailUtils
*/
@Provides
@Config("gSuiteOutoingEmailDisplayName")
public static String provideGSuiteOutgoingEmailDisplayName(RegistryConfigSettings config) {
return config.gSuite.outgoingEmailDisplayName;
}
/**
* Returns the Google Cloud Storage bucket for ICANN transaction and activity reports to
* be uploaded.
*
* @see google.registry.reporting.IcannReportingUploadAction
*/
@Provides
@Config("icannReportingBucket")
public static String provideIcannReportingBucket(@Config("projectId") String projectId) {
return projectId + "-reporting";
}
/**
* Returns the URL we send HTTP PUT requests for ICANN monthly transactions reports.
*
* @see google.registry.reporting.IcannHttpReporter
*/
@Provides
@Config("icannTransactionsReportingUploadUrl")
public static String provideIcannTransactionsReportingUploadUrl(RegistryConfigSettings config) {
return config.icannReporting.icannTransactionsReportingUploadUrl;
}
/**
* Returns the URL we send HTTP PUT requests for ICANN monthly activity reports.
*
* @see google.registry.reporting.IcannHttpReporter
*/
@Provides
@Config("icannActivityReportingUploadUrl")
public static String provideIcannActivityReportingUploadUrl(RegistryConfigSettings config) {
return config.icannReporting.icannActivityReportingUploadUrl;
}
/**
* Returns the email address from which we send ICANN reporting email summaries from.
*
* @see google.registry.reporting.ReportingEmailUtils
*/
@Provides
@Config("icannReportingSenderEmailAddress")
public static String provideIcannReportingEmailSenderAddress(
@Config("projectId") String projectId, RegistryConfigSettings config) {
return String.format(
"%s@%s", projectId, config.icannReporting.icannReportingEmailSenderDomain);
}
/**
* Returns the email address from which we send ICANN reporting email summaries to.
*
* @see google.registry.reporting.ReportingEmailUtils
*/
@Provides
@Config("icannReportingRecipientEmailAddress")
public static String provideIcannReportingEmailRecipientAddress(RegistryConfigSettings config) {
return config.icannReporting.icannReportingEmailRecipient;
}
/**
* Returns the Google Cloud Storage bucket for staging escrow deposits pending upload.
*
* @see google.registry.rde.RdeStagingAction
*/
@Provides
@Config("rdeBucket")
public static String provideRdeBucket(@Config("projectId") String projectId) {
return projectId + "-rde";
}
/**
* Returns the Google Cloud Storage bucket for importing escrow files.
*
* @see google.registry.rde.imports.RdeContactImportAction
* @see google.registry.rde.imports.RdeHostImportAction
*/
@Provides
@Config("rdeImportBucket")
public static String provideRdeImportBucket(@Config("projectId") String projectId) {
return projectId + "-rde-import";
}
/**
* Size of Ghostryde buffer in bytes for each layer in the pipeline.
*
* @see google.registry.rde.Ghostryde
*/
@Provides
@Config("rdeGhostrydeBufferSize")
public static Integer provideRdeGhostrydeBufferSize() {
return 64 * 1024;
}
/**
* Amount of time between RDE deposits.
*
* @see google.registry.rde.PendingDepositChecker
* @see google.registry.rde.RdeReportAction
* @see google.registry.rde.RdeUploadAction
*/
@Provides
@Config("rdeInterval")
public static Duration provideRdeInterval() {
return Duration.standardDays(1);
}
/**
* Maximum amount of time for sending a small XML file to ICANN via HTTP, before killing.
*
* @see google.registry.rde.RdeReportAction
*/
@Provides
@Config("rdeReportLockTimeout")
public static Duration provideRdeReportLockTimeout() {
return Duration.standardMinutes(1);
}
/**
* URL of ICANN's HTTPS server to which the RDE report should be {@code PUT}.
*
* <p>You must append {@code "/TLD/ID"} to this URL.
*
* @see google.registry.rde.RdeReportAction
*/
@Provides
@Config("rdeReportUrlPrefix")
public static String provideRdeReportUrlPrefix(RegistryConfigSettings config) {
return config.rde.reportUrlPrefix;
}
/**
* Size of RYDE generator buffer in bytes for each of the five layers.
*
* @see google.registry.rde.RydePgpCompressionOutputStream
* @see google.registry.rde.RydePgpFileOutputStream
* @see google.registry.rde.RydePgpSigningOutputStream
* @see google.registry.rde.RydeTarOutputStream
*/
@Provides
@Config("rdeRydeBufferSize")
public static Integer provideRdeRydeBufferSize() {
return 64 * 1024;
}
/**
* Maximum amount of time generating an escrow deposit for a TLD could take, before killing.
*
* @see google.registry.rde.RdeStagingReducer
*/
@Provides
@Config("rdeStagingLockTimeout")
public static Duration provideRdeStagingLockTimeout() {
return Duration.standardHours(2);
}
/**
* Maximum amount of time it should ever take to upload an escrow deposit, before killing.
*
* @see google.registry.rde.RdeUploadAction
*/
@Provides
@Config("rdeUploadLockTimeout")
public static Duration provideRdeUploadLockTimeout() {
return Duration.standardMinutes(30);
}
/**
* Minimum amount of time to wait between consecutive SFTP uploads on a single TLD.
*
* <p>This value was communicated to us by the escrow provider.
*
* @see google.registry.rde.RdeStagingReducer
*/
@Provides
@Config("rdeUploadSftpCooldown")
public static Duration provideRdeUploadSftpCooldown() {
return Duration.standardHours(2);
}
/**
* Returns the identity (an email address) used for the SSH keys used in RDE SFTP uploads.
*
* @see google.registry.keyring.api.Keyring#getRdeSshClientPublicKey()
* @see google.registry.keyring.api.Keyring#getRdeSshClientPrivateKey()
*/
@Provides
@Config("rdeSshIdentity")
public static String provideSshIdentity(RegistryConfigSettings config) {
return config.rde.sshIdentityEmailAddress;
}
/**
* Returns SFTP URL containing a username, hostname, port (optional), and directory (optional)
* to which cloud storage files are uploaded. The password should not be included, as it's
* better to use public key authentication.
*
* @see google.registry.rde.RdeUploadAction
*/
@Provides
@Config("rdeUploadUrl")
public static URI provideRdeUploadUrl(RegistryConfigSettings config) {
return URI.create(config.rde.uploadUrl);
}
/**
* Whether or not the registrar console is enabled.
*
* @see google.registry.ui.server.registrar.ConsoleUiAction
*/
@Provides
@Config("registrarConsoleEnabled")
public static boolean provideRegistrarConsoleEnabled() {
return true;
}
/**
* Maximum amount of time for syncing a spreadsheet, before killing.
*
* @see google.registry.export.sheet.SyncRegistrarsSheetAction
*/
@Provides
@Config("sheetLockTimeout")
public static Duration provideSheetLockTimeout() {
return Duration.standardHours(1);
}
/**
* Returns ID of Google Spreadsheet to which Registrar entities should be synced.
*
* <p>This ID, as you'd expect, comes from the URL of the spreadsheet.
*
* @see google.registry.export.sheet.SyncRegistrarsSheetAction
*/
@Provides
@Config("sheetRegistrarId")
public static Optional<String> provideSheetRegistrarId(RegistryConfigSettings config) {
return Optional.ofNullable(config.misc.sheetExportId);
}
/**
* Returns SSH client connection and read timeout.
*
* @see google.registry.rde.RdeUploadAction
*/
@Provides
@Config("sshTimeout")
public static Duration provideSshTimeout() {
return Duration.standardSeconds(30);
}
/**
* Duration after watermark where we shouldn't deposit, because transactions might be pending.
*
* @see google.registry.rde.RdeStagingAction
*/
@Provides
@Config("transactionCooldown")
public static Duration provideTransactionCooldown() {
return Duration.standardMinutes(5);
}
/**
* Number of times to retry a GAE operation when {@code TransientFailureException} is thrown.
*
* <p>The number of milliseconds it'll sleep before giving up is {@code 2^n - 2}.
*
* <p>Note that this uses {@code @Named} instead of {@code @Config} so that it can be used from
* the low-level util package, which cannot have a dependency on the config package.
*
* @see google.registry.util.TaskEnqueuer
*/
@Provides
@Named("transientFailureRetries")
public static int provideTransientFailureRetries() {
return 12; // Four seconds.
}
/**
* Amount of time public HTTP proxies are permitted to cache our WHOIS responses.
*
* @see google.registry.whois.WhoisHttpServer
*/
@Provides
@Config("whoisHttpExpires")
public static Duration provideWhoisHttpExpires() {
return Duration.standardDays(1);
}
/**
* Maximum number of results to return for an RDAP search query
*
* @see google.registry.rdap.RdapActionBase
*/
@Provides
@Config("rdapResultSetMaxSize")
public static int provideRdapResultSetMaxSize() {
return 100;
}
/**
* WHOIS server displayed in RDAP query responses. As per Gustavo Lozano of ICANN, this should
* be omitted, but the ICANN operational profile doesn't actually say that, so it's good to have
* the ability to reinstate this field if necessary.
*
* @see google.registry.rdap.RdapActionBase
*/
@Nullable
@Provides
@Config("rdapWhoisServer")
public static String provideRdapWhoisServer() {
return null;
}
/**
* Returns Braintree Merchant Account IDs for each supported currency.
*
* @see google.registry.ui.server.registrar.RegistrarPaymentAction
* @see google.registry.ui.server.registrar.RegistrarPaymentSetupAction
*/
@Provides
@Config("braintreeMerchantAccountIds")
public static ImmutableMap<CurrencyUnit, String> provideBraintreeMerchantAccountId(
RegistryConfigSettings config) {
Map<String, String> merchantAccountIds = config.braintree.merchantAccountIdsMap;
ImmutableMap.Builder<CurrencyUnit, String> builder = new ImmutableMap.Builder<>();
for (Entry<String, String> entry : merchantAccountIds.entrySet()) {
builder.put(CurrencyUnit.of(entry.getKey()), entry.getValue());
}
return builder.build();
}
/**
* Returns Braintree Merchant ID of Registry, used for accessing Braintree API.
*
* <p>This is a base32 value copied from the Braintree website.
*
* @see google.registry.braintree.BraintreeModule
*/
@Provides
@Config("braintreeMerchantId")
public static String provideBraintreeMerchantId(RegistryConfigSettings config) {
return config.braintree.merchantId;
}
/**
* Returns Braintree Public Key of Registry, used for accessing Braintree API.
*
* <p>This is a base32 value copied from the Braintree website.
*
* @see google.registry.braintree.BraintreeModule
* @see google.registry.keyring.api.Keyring#getBraintreePrivateKey()
*/
@Provides
@Config("braintreePublicKey")
public static String provideBraintreePublicKey(RegistryConfigSettings config) {
return config.braintree.publicKey;
}
/**
* Disclaimer displayed at the end of WHOIS query results.
*
* @see google.registry.whois.WhoisResponse
*/
@Provides
@Config("whoisDisclaimer")
public static String provideWhoisDisclaimer(RegistryConfigSettings config) {
return config.registryPolicy.whoisDisclaimer;
}
/**
* Maximum QPS for the Google Cloud Monitoring V3 (aka Stackdriver) API. The QPS limit can be
* adjusted by contacting Cloud Support.
*
* @see google.registry.monitoring.metrics.stackdriver.StackdriverWriter
*/
@Provides
@Config("stackdriverMaxQps")
public static int provideStackdriverMaxQps(RegistryConfigSettings config) {
return config.monitoring.stackdriverMaxQps;
}
/**
* Maximum number of points that can be sent to Stackdriver in a single {@code
* TimeSeries.Create} API call.
*
* @see google.registry.monitoring.metrics.stackdriver.StackdriverWriter
*/
@Provides
@Config("stackdriverMaxPointsPerRequest")
public static int provideStackdriverMaxPointsPerRequest(RegistryConfigSettings config) {
return config.monitoring.stackdriverMaxPointsPerRequest;
}
/**
* The reporting interval for {@link google.registry.monitoring.metrics.Metric} instances to be
* sent to a {@link google.registry.monitoring.metrics.MetricWriter}.
*
* @see google.registry.monitoring.metrics.MetricReporter
*/
@Provides
@Config("metricsWriteInterval")
public static Duration provideMetricsWriteInterval(RegistryConfigSettings config) {
return Duration.standardSeconds(config.monitoring.writeIntervalSeconds);
}
/**
* The global automatic transfer length for contacts. After this amount of time has
* elapsed, the transfer is automatically approved.
*
* @see google.registry.flows.contact.ContactTransferRequestFlow
*/
@Provides
@Config("contactAutomaticTransferLength")
public static Duration provideContactAutomaticTransferLength(RegistryConfigSettings config) {
return Duration.standardDays(config.registryPolicy.contactAutomaticTransferDays);
}
/**
* Returns the maximum number of entities that can be checked at one time in an EPP check flow.
*/
@Provides
@Config("maxChecks")
public static int provideMaxChecks() {
return 50;
}
/**
* Returns the delay before executing async delete flow mapreduces.
*
* <p>This delay should be sufficiently longer than a transaction, to solve the following
* problem:
*
* <ul>
* <li>a domain mutation flow starts a transaction
* <li>the domain flow non-transactionally reads a resource and sees that it's not in
* PENDING_DELETE
* <li>the domain flow creates a new reference to this resource
* <li>a contact/host delete flow runs and marks the resource PENDING_DELETE and commits
* <li>the domain flow commits
* </ul>
*
* <p>Although we try not to add references to a PENDING_DELETE resource, strictly speaking that
* is ok as long as the mapreduce eventually sees the new reference (and therefore
* asynchronously fails the delete). Without this delay, the mapreduce might have started before
* the domain flow committed, and could potentially miss the reference.
*
* @see google.registry.flows.async.AsyncFlowEnqueuer
*/
@Provides
@Config("asyncDeleteFlowMapreduceDelay")
public static Duration provideAsyncDeleteFlowMapreduceDelay() {
return Duration.standardSeconds(90);
}
/**
* The server ID used in the 'svID' element of an EPP 'greeting'.
*
* @see <a href="https://tools.ietf.org/html/rfc5730">RFC 7530</a>
*/
@Provides
@Config("greetingServerId")
public static String provideGreetingServerId(RegistryConfigSettings config) {
return config.registryPolicy.greetingServerId;
}
/**
* The name to use for the Cloud KMS KeyRing containing encryption keys for Nomulus secrets.
*
* @see <a
* href="https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings#KeyRing">projects.locations.keyRings</a>
*/
@Provides
@Config("cloudKmsKeyRing")
public static String provideCloudKmsKeyRing(RegistryConfigSettings config) {
return config.kms.keyringName;
}
@Provides
@Config("cloudKmsProjectId")
public static String provideCloudKmsProjectId(RegistryConfigSettings config) {
return config.kms.projectId;
}
@Provides
@Config("customLogicFactoryClass")
public static String provideCustomLogicFactoryClass(RegistryConfigSettings config) {
return config.registryPolicy.customLogicFactoryClass;
}
@Provides
@Config("whoisCommandFactoryClass")
public static String provideWhoisCommandFactoryClass(RegistryConfigSettings config) {
return config.registryPolicy.whoisCommandFactoryClass;
}
/**
* Returns the header text at the top of the reserved terms exported list.
*
* @see google.registry.export.ExportUtils#exportReservedTerms
*/
@Provides
@Config("reservedTermsExportDisclaimer")
public static String provideReservedTermsExportDisclaimer(RegistryConfigSettings config) {
return config.registryPolicy.reservedTermsExportDisclaimer;
}
/**
* Returns the clientId of the registrar used by the {@code CheckApiServlet}.
*/
@Provides
@Config("checkApiServletRegistrarClientId")
public static String provideCheckApiServletRegistrarClientId(RegistryConfigSettings config) {
return config.registryPolicy.checkApiServletClientId;
}
/**
* Returns the clientId of the registrar that admins are automatically logged in as if they
* aren't otherwise associated with one.
*/
@Provides
@Config("registryAdminClientId")
public static String provideRegistryAdminClientId(RegistryConfigSettings config) {
return config.registryPolicy.registryAdminClientId;
}
@Singleton
@Provides
static RegistryConfigSettings provideRegistryConfigSettings() {
return CONFIG_SETTINGS.get();
}
/**
* Provides the OAuth scopes that authentication logic should detect on access tokens.
*
* <p>This list should be a superset of the required OAuth scope set provided below. Note that
* ideally, this setting would not be required and all scopes on an access token would be