mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 10:16:07 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
19
java/google/registry/config/BUILD
Normal file
19
java/google/registry/config/BUILD
Normal file
|
@ -0,0 +1,19 @@
|
|||
package(default_visibility = ["//java/com/google/domain/registry:registry_project"])
|
||||
|
||||
|
||||
java_library(
|
||||
name = "config",
|
||||
srcs = glob(["*.java"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/common/annotations",
|
||||
"//java/com/google/common/base",
|
||||
"//java/com/google/common/collect",
|
||||
"//java/com/google/common/net",
|
||||
"//third_party/java/appengine:appengine-api",
|
||||
"//third_party/java/dagger",
|
||||
"//third_party/java/joda_money",
|
||||
"//third_party/java/joda_time",
|
||||
"//third_party/java/jsr305_annotations",
|
||||
],
|
||||
)
|
570
java/google/registry/config/ConfigModule.java
Normal file
570
java/google/registry/config/ConfigModule.java
Normal file
|
@ -0,0 +1,570 @@
|
|||
// Copyright 2016 The Domain Registry 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 com.google.domain.registry.config;
|
||||
|
||||
import static com.google.domain.registry.config.ConfigUtils.makeUrl;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTimeConstants;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/** Dagger module for injecting configuration settings. */
|
||||
@Module
|
||||
public final class ConfigModule {
|
||||
|
||||
/** Dagger qualifier for configuration settings. */
|
||||
@Qualifier
|
||||
@Documented
|
||||
public static @interface Config {
|
||||
String value() default "";
|
||||
}
|
||||
|
||||
private static final RegistryEnvironment registryEnvironment = RegistryEnvironment.get();
|
||||
|
||||
@Provides
|
||||
public static RegistryEnvironment provideRegistryEnvironment() {
|
||||
return registryEnvironment;
|
||||
}
|
||||
|
||||
@Provides
|
||||
public static RegistryConfig provideConfig(RegistryEnvironment environment) {
|
||||
return environment.config();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("projectId")
|
||||
public static String provideProjectId(RegistryConfig config) {
|
||||
return config.getProjectId();
|
||||
}
|
||||
|
||||
/** @see RegistryConfig#getZoneFilesBucket() */
|
||||
@Provides
|
||||
@Config("zoneFilesBucket")
|
||||
public static String provideZoneFilesBucket(RegistryConfig config) {
|
||||
return config.getZoneFilesBucket();
|
||||
}
|
||||
|
||||
/** @see RegistryConfig#getCommitsBucket() */
|
||||
@Provides
|
||||
@Config("commitLogGcsBucket")
|
||||
public static String provideCommitLogGcsBucket(RegistryConfig config) {
|
||||
return config.getCommitsBucket();
|
||||
}
|
||||
|
||||
/** @see RegistryConfig#getCommitLogDatastoreRetention() */
|
||||
@Provides
|
||||
@Config("commitLogDatastoreRetention")
|
||||
public static Duration provideCommitLogDatastoreRetention(RegistryConfig config) {
|
||||
return config.getCommitLogDatastoreRetention();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("domainListsGcsBucket")
|
||||
public static String provideDomainListsGcsBucket(RegistryConfig config) {
|
||||
return config.getDomainListsBucket();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum number of commit logs to delete per transaction.
|
||||
*
|
||||
* <p>If we assume that the average key size is 256 bytes and that each manifest has six
|
||||
* mutations, we can do about 5,000 deletes in a single transaction before hitting the 10mB limit.
|
||||
* Therefore 500 should be a safe number, since it's an order of a magnitude less space than we
|
||||
* need.
|
||||
*
|
||||
* <p>Transactions also have a four minute time limit. Since we have to perform N subqueries to
|
||||
* fetch mutation keys, 500 would be a safe number if those queries were performed in serial,
|
||||
* since each query would have about 500ms to complete, which is an order a magnitude more time
|
||||
* than we need. However this does not apply, since the subqueries are performed asynchronously.
|
||||
*
|
||||
* @see com.google.domain.registry.backup.DeleteOldCommitLogsAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("commitLogMaxDeletes")
|
||||
public static int provideCommitLogMaxDeletes() {
|
||||
return 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch size for the number of transactions' worth of commit log data to process at once when
|
||||
* exporting a commit log diff.
|
||||
*
|
||||
* @see com.google.domain.registry.backup.ExportCommitLogDiffAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("commitLogDiffExportBatchSize")
|
||||
public static int provideCommitLogDiffExportBatchSize() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Google Cloud Storage bucket for staging BRDA escrow deposits.
|
||||
*
|
||||
* @see com.google.domain.registry.rde.PendingDepositChecker
|
||||
*/
|
||||
@Provides
|
||||
@Config("brdaBucket")
|
||||
public static String provideBrdaBucket(@Config("projectId") String projectId) {
|
||||
return projectId + "-icann-brda";
|
||||
}
|
||||
|
||||
/** @see com.google.domain.registry.rde.BrdaCopyAction */
|
||||
@Provides
|
||||
@Config("brdaDayOfWeek")
|
||||
public static int provideBrdaDayOfWeek() {
|
||||
return DateTimeConstants.TUESDAY;
|
||||
}
|
||||
|
||||
/** Amount of time between BRDA deposits. */
|
||||
@Provides
|
||||
@Config("brdaInterval")
|
||||
public static Duration provideBrdaInterval() {
|
||||
return Duration.standardDays(7);
|
||||
}
|
||||
|
||||
/** Maximum amount of time generating an BRDA deposit for a TLD could take, before killing. */
|
||||
@Provides
|
||||
@Config("brdaLockTimeout")
|
||||
public static Duration provideBrdaLockTimeout() {
|
||||
return Duration.standardHours(5);
|
||||
}
|
||||
|
||||
/** Returns {@code true} if the target zone should be created in DNS if it does not exist. */
|
||||
@Provides
|
||||
@Config("dnsCreateZone")
|
||||
public static boolean provideDnsCreateZone(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of domain and host updates to batch together to send to
|
||||
* PublishDnsUpdatesAction, to avoid exceeding AppEngine's limits.
|
||||
* */
|
||||
@Provides
|
||||
@Config("dnsTldUpdateBatchSize")
|
||||
public static int provideDnsTldUpdateBatchSize() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
/** The maximum interval (seconds) to lease tasks from the dns-pull queue. */
|
||||
@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 records. */
|
||||
@Provides
|
||||
@Config("dnsDefaultTtl")
|
||||
public static Duration provideDnsDefaultTtl() {
|
||||
return Duration.standardSeconds(180);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of sharded entity group roots used for performing strongly consistent scans.
|
||||
*
|
||||
* <p><b>Warning:</b> This number may increase but never decrease.
|
||||
*
|
||||
* @see com.google.domain.registry.model.index.EppResourceIndex
|
||||
*/
|
||||
@Provides
|
||||
@Config("eppResourceIndexBucketCount")
|
||||
public static int provideEppResourceIndexBucketCount(RegistryConfig config) {
|
||||
return config.getEppResourceIndexBucketCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns size of Google Cloud Storage client connection buffer in bytes.
|
||||
*
|
||||
* @see com.google.domain.registry.gcs.GcsUtils
|
||||
*/
|
||||
@Provides
|
||||
@Config("gcsBufferSize")
|
||||
public static int provideGcsBufferSize() {
|
||||
return 1024 * 1024;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the email address of the admin account for the Google App.
|
||||
*
|
||||
* @see com.google.domain.registry.groups.DirectoryGroupsConnection
|
||||
*/
|
||||
@Provides
|
||||
@Config("googleAppsAdminEmailAddress")
|
||||
public static String provideGoogleAppsAdminEmailAddress(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return "admin@registry.google";
|
||||
default:
|
||||
return "admin@domainregistry-sandbox.co";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the publicly accessible domain name for the running Google Apps instance.
|
||||
*
|
||||
* @see com.google.domain.registry.export.SyncGroupMembersAction
|
||||
* @see com.google.domain.registry.tools.server.CreateGroupsAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("publicDomainName")
|
||||
public static String providePublicDomainName(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return "registry.google";
|
||||
default:
|
||||
return "domainregistry-sandbox.co";
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("tmchCaTestingMode")
|
||||
public static boolean provideTmchCaTestingMode(RegistryConfig config) {
|
||||
return config.getTmchCaTestingMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
*
|
||||
* @see com.google.domain.registry.tmch.TmchCrlAction
|
||||
* @see "http://tools.ietf.org/html/draft-lozano-tmch-func-spec-08#section-5.2.3.2"
|
||||
*/
|
||||
@Provides
|
||||
@Config("tmchCrlUrl")
|
||||
public static URL provideTmchCrlUrl(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return makeUrl("http://crl.icann.org/tmch.crl");
|
||||
default:
|
||||
return makeUrl("http://crl.icann.org/tmch_pilot.crl");
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("tmchMarksdbUrl")
|
||||
public static String provideTmchMarksdbUrl(RegistryConfig config) {
|
||||
return config.getTmchMarksdbUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Google Cloud Storage bucket for staging escrow deposits pending upload.
|
||||
*
|
||||
* @see com.google.domain.registry.rde.RdeStagingAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdeBucket")
|
||||
public static String provideRdeBucket(@Config("projectId") String projectId) {
|
||||
return projectId + "-rde";
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of Ghostryde buffer in bytes for each layer in the pipeline.
|
||||
*
|
||||
* @see com.google.domain.registry.rde.Ghostryde
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdeGhostrydeBufferSize")
|
||||
public static Integer provideRdeGhostrydeBufferSize() {
|
||||
return 64 * 1024;
|
||||
}
|
||||
|
||||
/** Amount of time between RDE deposits. */
|
||||
@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. */
|
||||
@Provides
|
||||
@Config("rdeReportLockTimeout")
|
||||
public static Duration provideRdeReportLockTimeout() {
|
||||
return Duration.standardSeconds(60);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 com.google.domain.registry.rde.RdeReportAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdeReportUrlPrefix")
|
||||
public static String provideRdeReportUrlPrefix(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return "https://ry-api.icann.org/report/registry-escrow-report";
|
||||
default:
|
||||
return "https://test-ry-api.icann.org:8543/report/registry-escrow-report";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Size of RYDE generator buffer in bytes for each of the five layers.
|
||||
*
|
||||
* @see com.google.domain.registry.rde.RydePgpCompressionOutputStream
|
||||
* @see com.google.domain.registry.rde.RydePgpFileOutputStream
|
||||
* @see com.google.domain.registry.rde.RydePgpSigningOutputStream
|
||||
* @see com.google.domain.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. */
|
||||
@Provides
|
||||
@Config("rdeStagingLockTimeout")
|
||||
public static Duration provideRdeStagingLockTimeout() {
|
||||
return Duration.standardHours(5);
|
||||
}
|
||||
|
||||
/** Maximum amount of time it should ever take to upload an escrow deposit, before killing. */
|
||||
@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.
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdeUploadSftpCooldown")
|
||||
public static Duration provideRdeUploadSftpCooldown() {
|
||||
return Duration.standardHours(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 com.google.domain.registry.rde.RdeUploadAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdeUploadUrl")
|
||||
public static URI provideRdeUploadUrl(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return URI.create("sftp://GoogleTLD@sftpipm2.ironmountain.com/Outbox");
|
||||
default:
|
||||
return URI.create("sftp://google@ppftpipm.ironmountain.com/Outbox");
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Config("registrarConsoleEnabled")
|
||||
public static boolean provideRegistrarConsoleEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Maximum amount of time for syncing a spreadsheet, before killing. */
|
||||
@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 com.google.domain.registry.export.sheet.SyncRegistrarsSheetAction
|
||||
*/
|
||||
@Provides
|
||||
@Config("sheetRegistrarId")
|
||||
public static Optional<String> provideSheetRegistrarId(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return Optional.of("1n2Gflqsgo9iDXcdt9VEskOVySZ8qIhQHJgjqsleCKdE");
|
||||
case ALPHA:
|
||||
case CRASH:
|
||||
return Optional.of("16BwRt6v11Iw-HujCbAkmMxqw3sUG13B8lmXLo-uJTsE");
|
||||
case SANDBOX:
|
||||
return Optional.of("1TlR_UMCtfpkxT9oUEoF5JEbIvdWNkLRuURltFkJ_7_8");
|
||||
case QA:
|
||||
return Optional.of("1RoY1XZhLLwqBkrz0WbEtaT9CU6c8nUAXfId5BtM837o");
|
||||
default:
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
/** Amount of time between synchronizations of the Registrar spreadsheet. */
|
||||
@Provides
|
||||
@Config("sheetRegistrarInterval")
|
||||
public static Duration provideSheetRegistrarInterval() {
|
||||
return Duration.standardHours(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns SSH client connection and read timeout.
|
||||
*
|
||||
* @see com.google.domain.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. */
|
||||
@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}.
|
||||
*
|
||||
* @see com.google.domain.registry.util.TaskEnqueuer
|
||||
*/
|
||||
@Provides
|
||||
@Config("transientFailureRetries")
|
||||
public static int provideTransientFailureRetries() {
|
||||
return 12; // Four seconds.
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount of time public HTTP proxies are permitted to cache our WHOIS responses.
|
||||
*
|
||||
* @see com.google.domain.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 com.google.domain.registry.rdap.RdapActionBase
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdapResultSetMaxSize")
|
||||
public static int provideRdapResultSetMaxSize() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base for RDAP link paths.
|
||||
*
|
||||
* @see com.google.domain.registry.rdap.RdapActionBase
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdapLinkBase")
|
||||
public static String provideRdapLinkBase() {
|
||||
return "https://nic.google/rdap/";
|
||||
}
|
||||
|
||||
/**
|
||||
* WHOIS server displayed in RDAP query responses.
|
||||
*
|
||||
* @see com.google.domain.registry.rdap.RdapActionBase
|
||||
*/
|
||||
@Provides
|
||||
@Config("rdapWhoisServer")
|
||||
public static String provideRdapWhoisServer() {
|
||||
return "whois.nic.google";
|
||||
}
|
||||
|
||||
/** Returns Braintree Merchant Account IDs for each supported currency. */
|
||||
@Provides
|
||||
@Config("braintreeMerchantAccountIds")
|
||||
public static ImmutableMap<CurrencyUnit, String> provideBraintreeMerchantAccountId(
|
||||
RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return ImmutableMap.of(
|
||||
CurrencyUnit.USD, "charlestonregistryUSD",
|
||||
CurrencyUnit.JPY, "charlestonregistryJPY");
|
||||
default:
|
||||
return ImmutableMap.of(
|
||||
CurrencyUnit.USD, "google",
|
||||
CurrencyUnit.JPY, "google-jpy");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Braintree Merchant ID of Registry, used for accessing Braintree API.
|
||||
*
|
||||
* <p>This is a base32 value copied from the Braintree website.
|
||||
*/
|
||||
@Provides
|
||||
@Config("braintreeMerchantId")
|
||||
public static String provideBraintreeMerchantId(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return "6gm2mm48k9ty4zmx";
|
||||
default:
|
||||
// Valentine: Domain Registry Braintree Sandbox
|
||||
return "vqgn8khkq2cs6y9s";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Braintree Public Key of Registry, used for accessing Braintree API.
|
||||
*
|
||||
* <p>This is a base32 value copied from the Braintree website.
|
||||
*
|
||||
* @see com.google.domain.registry.keyring.api.Keyring#getBraintreePrivateKey()
|
||||
*/
|
||||
@Provides
|
||||
@Config("braintreePublicKey")
|
||||
public static String provideBraintreePublicKey(RegistryEnvironment environment) {
|
||||
switch (environment) {
|
||||
case PRODUCTION:
|
||||
return "tzcfxggzgbh2jg5x";
|
||||
default:
|
||||
// Valentine: Domain Registry Braintree Sandbox
|
||||
return "tzcyzvm3mn7zkdnx";
|
||||
}
|
||||
}
|
||||
}
|
37
java/google/registry/config/ConfigUtils.java
Normal file
37
java/google/registry/config/ConfigUtils.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2016 The Domain Registry 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 com.google.domain.registry.config;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/** Helper methods for configuration classes. */
|
||||
final class ConfigUtils {
|
||||
|
||||
/**
|
||||
* Creates a URL instance.
|
||||
*
|
||||
* @throws RuntimeException to rethrow {@link MalformedURLException}
|
||||
*/
|
||||
static URL makeUrl(String url) {
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ConfigUtils() {}
|
||||
}
|
243
java/google/registry/config/RegistryConfig.java
Normal file
243
java/google/registry/config/RegistryConfig.java
Normal file
|
@ -0,0 +1,243 @@
|
|||
// Copyright 2016 The Domain Registry 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 com.google.domain.registry.config;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Domain Registry configuration.
|
||||
*
|
||||
* <p>The goal of this custom configuration system is to have our project environments configured
|
||||
* in type-safe Java code that can be refactored, rather than XML files and system properties.
|
||||
*
|
||||
* <p><b>Note:</b> This interface is deprecated by {@link ConfigModule}.
|
||||
*/
|
||||
public interface RegistryConfig {
|
||||
|
||||
/**
|
||||
* Returns the App Engine project ID, which is based off the environment name.
|
||||
*/
|
||||
public String getProjectId();
|
||||
|
||||
/**
|
||||
* Returns the Google Cloud Storage bucket for storing backup snapshots.
|
||||
*
|
||||
* @see com.google.domain.registry.export.ExportSnapshotServlet
|
||||
*/
|
||||
public String getSnapshotsBucket();
|
||||
|
||||
/**
|
||||
* Returns the Google Cloud Storage bucket for storing exported domain lists.
|
||||
*
|
||||
* @see com.google.domain.registry.export.ExportDomainListsAction
|
||||
*/
|
||||
public String getDomainListsBucket();
|
||||
|
||||
/**
|
||||
* Number of sharded commit log buckets.
|
||||
*
|
||||
* <p>This number is crucial for determining how much transactional throughput the system can
|
||||
* allow, because it determines how many entity groups are available for writing commit logs.
|
||||
* Since entity groups have a one transaction per second SLA (which is actually like ten in
|
||||
* practice), a registry that wants to be able to handle one hundred transactions per second
|
||||
* should have one hundred buckets.
|
||||
*
|
||||
* <p><b>Warning:</b> This can be raised but never lowered.
|
||||
*
|
||||
* @see com.google.domain.registry.model.ofy.CommitLogBucket
|
||||
*/
|
||||
public int getCommitLogBucketCount();
|
||||
|
||||
/**
|
||||
* Returns the length of time before commit logs should be deleted from datastore.
|
||||
*
|
||||
* <p>The only reason you'll want to retain this commit logs in datastore is for performing
|
||||
* point-in-time restoration queries for subsystems like RDE.
|
||||
*
|
||||
* @see com.google.domain.registry.backup.DeleteOldCommitLogsAction
|
||||
* @see com.google.domain.registry.model.translators.CommitLogRevisionsTranslatorFactory
|
||||
*/
|
||||
public Duration getCommitLogDatastoreRetention();
|
||||
|
||||
/**
|
||||
* Returns the Google Cloud Storage bucket for storing commit logs.
|
||||
*
|
||||
* @see com.google.domain.registry.backup.ExportCommitLogDiffAction
|
||||
*/
|
||||
public String getCommitsBucket();
|
||||
|
||||
/**
|
||||
* Returns the Google Cloud Storage bucket for storing zone files.
|
||||
*
|
||||
* @see com.google.domain.registry.backup.ExportCommitLogDiffAction
|
||||
*/
|
||||
public String getZoneFilesBucket();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if TMCH certificate authority should be in testing mode.
|
||||
*
|
||||
* @see com.google.domain.registry.tmch.TmchCertificateAuthority
|
||||
*/
|
||||
public boolean getTmchCaTestingMode();
|
||||
|
||||
/**
|
||||
* URL prefix for communicating with MarksDB ry interface.
|
||||
*
|
||||
* <p>This URL is used for DNL, SMDRL, and LORDN.
|
||||
*
|
||||
* @see com.google.domain.registry.tmch.Marksdb
|
||||
* @see com.google.domain.registry.tmch.NordnUploadAction
|
||||
*/
|
||||
public String getTmchMarksdbUrl();
|
||||
|
||||
public Optional<String> getECatcherAddress();
|
||||
|
||||
/**
|
||||
* Returns the address of the Domain Registry app HTTP server.
|
||||
*
|
||||
* <p>This is used by {@code registry_tool} to connect to the App Engine remote API.
|
||||
*/
|
||||
public HostAndPort getServer();
|
||||
|
||||
/** Returns the amount of time a singleton should be cached, before expiring. */
|
||||
public Duration getSingletonCacheRefreshDuration();
|
||||
|
||||
/**
|
||||
* Returns the amount of time a domain label list should be cached in memory before expiring.
|
||||
*
|
||||
* @see com.google.domain.registry.model.registry.label.ReservedList
|
||||
* @see com.google.domain.registry.model.registry.label.PremiumList
|
||||
*/
|
||||
public Duration getDomainLabelListCacheDuration();
|
||||
|
||||
/** Returns the amount of time a singleton should be cached in persist mode, before expiring. */
|
||||
public Duration getSingletonCachePersistDuration();
|
||||
|
||||
/**
|
||||
* Returns the header text at the top of the reserved terms exported list.
|
||||
*
|
||||
* @see com.google.domain.registry.export.ExportUtils#exportReservedTerms
|
||||
*/
|
||||
public String getReservedTermsExportDisclaimer();
|
||||
|
||||
/**
|
||||
* Returns a display name that is used on outgoing emails sent by Domain Registry.
|
||||
*
|
||||
* @see com.google.domain.registry.util.SendEmailUtils
|
||||
*/
|
||||
public String getGoogleAppsAdminEmailDisplayName();
|
||||
|
||||
/**
|
||||
* Returns the email address that outgoing emails from the app are sent from.
|
||||
*
|
||||
* @see com.google.domain.registry.util.SendEmailUtils
|
||||
*/
|
||||
public String getGoogleAppsSendFromEmailAddress();
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
public String getContactAndHostRepositoryIdentifier();
|
||||
|
||||
/**
|
||||
* 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 com.google.domain.registry.ui.server.registrar.RegistrarServlet
|
||||
*/
|
||||
public ImmutableList<String> getRegistrarChangesNotificationEmailAddresses();
|
||||
|
||||
/**
|
||||
* Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
|
||||
*
|
||||
* @see "com.google.domain.registry.whois.DomainWhoisResponse"
|
||||
* @see "com.google.domain.registry.whois.RegistrarWhoisResponse"
|
||||
*/
|
||||
public String getRegistrarDefaultWhoisServer();
|
||||
|
||||
/**
|
||||
* Returns the default referral URL that is used unless registrars have specified otherwise.
|
||||
*/
|
||||
public URL getRegistrarDefaultReferralUrl();
|
||||
|
||||
/**
|
||||
* Returns the title of the project used in generating documentation.
|
||||
*/
|
||||
public String getDocumentationProjectTitle();
|
||||
|
||||
/**
|
||||
* Returns the maximum number of entities that can be checked at one time in an EPP check flow.
|
||||
*/
|
||||
public int getMaxChecks();
|
||||
|
||||
/**
|
||||
* Returns the number of EppResourceIndex buckets to be used.
|
||||
*/
|
||||
public int getEppResourceIndexBucketCount();
|
||||
|
||||
/**
|
||||
* Returns the base duration that gets doubled on each retry within {@code Ofy}.
|
||||
*/
|
||||
public Duration getBaseOfyRetryDuration();
|
||||
|
||||
/**
|
||||
* Returns the global automatic transfer length for contacts. After this amount of time has
|
||||
* elapsed, the transfer is automatically improved.
|
||||
*/
|
||||
public Duration getContactAutomaticTransferLength();
|
||||
|
||||
/**
|
||||
* Returns the clientId of the registrar used by the {@code CheckApiServlet}.
|
||||
*/
|
||||
public String getCheckApiServletRegistrarClientId();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public Duration getAsyncDeleteFlowMapreduceDelay();
|
||||
|
||||
/**
|
||||
* Returns the amount of time to back off following an async flow task failure.
|
||||
*
|
||||
* This should be ~orders of magnitude larger than the rate on the queue, in order to prevent
|
||||
* the logs from filling up with unnecessarily failures.
|
||||
*/
|
||||
public Duration getAsyncFlowFailureBackoff();
|
||||
}
|
90
java/google/registry/config/RegistryEnvironment.java
Normal file
90
java/google/registry/config/RegistryEnvironment.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Copyright 2016 The Domain Registry 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 com.google.domain.registry.config;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Registry environments. */
|
||||
public enum RegistryEnvironment {
|
||||
|
||||
/** Production environment. */
|
||||
PRODUCTION,
|
||||
|
||||
/** Development environment. */
|
||||
ALPHA,
|
||||
|
||||
/** Load/Backup/Restore Testing environment. */
|
||||
CRASH,
|
||||
|
||||
/** Local machine environment. */
|
||||
LOCAL,
|
||||
|
||||
/** Quality Assurance environment. */
|
||||
QA,
|
||||
|
||||
/** Sandbox environment. */
|
||||
SANDBOX,
|
||||
|
||||
/**
|
||||
* Unit testing environment.
|
||||
*
|
||||
* <p>This is the default enum value. This is because it's non-trivial to configure the system
|
||||
* property that specifies the environment in our unit tests.
|
||||
*
|
||||
* <p>Do not use this environment outside of unit tests.
|
||||
*/
|
||||
UNITTEST;
|
||||
|
||||
/** Returns environment configured by system property {@value #PROPERTY}. */
|
||||
public static RegistryEnvironment get() {
|
||||
return valueOf(System.getProperty(PROPERTY, UNITTEST.name()).toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns configuration for this Domain Registry environment.
|
||||
*
|
||||
* <p><b>WARNING:</b> Do not store this value to a static field, otherwise you won't be able to
|
||||
* override it for testing. You should instead store the environment object to a static field.
|
||||
*/
|
||||
public RegistryConfig config() {
|
||||
if (configOverride != null) {
|
||||
return configOverride;
|
||||
} else if (this == UNITTEST) {
|
||||
return testingConfig;
|
||||
} else {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
/** Globally override registry configuration from within a unit test. */
|
||||
@VisibleForTesting
|
||||
public static void overrideConfigurationForTesting(@Nullable RegistryConfig newConfig) {
|
||||
configOverride = newConfig;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static RegistryConfig configOverride;
|
||||
|
||||
// TODO(b/19247780) Use true dependency injection for this. In the mean time, if you're not
|
||||
// Google, you'll need to change this to include your own config class implementation at compile
|
||||
// time.
|
||||
private static final RegistryConfig testingConfig = new TestRegistryConfig();
|
||||
private final RegistryConfig config = new TestRegistryConfig();
|
||||
|
||||
/** System property for configuring which environment we should use. */
|
||||
public static final String PROPERTY = "com.google.domain.registry.environment";
|
||||
}
|
181
java/google/registry/config/TestRegistryConfig.java
Normal file
181
java/google/registry/config/TestRegistryConfig.java
Normal file
|
@ -0,0 +1,181 @@
|
|||
// Copyright 2016 The Domain Registry 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 com.google.domain.registry.config;
|
||||
|
||||
import static com.google.domain.registry.config.ConfigUtils.makeUrl;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* An implementation of RegistryConfig for unit testing that contains suitable testing data.
|
||||
*/
|
||||
public class TestRegistryConfig implements RegistryConfig {
|
||||
|
||||
public TestRegistryConfig() {}
|
||||
|
||||
@Override
|
||||
public String getProjectId() {
|
||||
return "domain-registry";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCommitLogBucketCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getCommitLogDatastoreRetention() {
|
||||
return Duration.standardDays(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSnapshotsBucket() {
|
||||
return getProjectId() + "-snapshots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainListsBucket() {
|
||||
return getProjectId() + "-domain-lists";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommitsBucket() {
|
||||
return getProjectId() + "-commits";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getZoneFilesBucket() {
|
||||
return getProjectId() + "-zonefiles";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTmchCaTestingMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTmchMarksdbUrl() {
|
||||
return "https://ry.marksdb.org";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getECatcherAddress() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostAndPort getServer() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getSingletonCacheRefreshDuration() {
|
||||
// All cache durations are set to zero so that unit tests can update and then retrieve data
|
||||
// immediately without failure.
|
||||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getDomainLabelListCacheDuration() {
|
||||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getSingletonCachePersistDuration() {
|
||||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReservedTermsExportDisclaimer() {
|
||||
return "This is a disclaimer.\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGoogleAppsAdminEmailDisplayName() {
|
||||
return "Testing Domain Registry";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGoogleAppsSendFromEmailAddress() {
|
||||
return "noreply@testing.example";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getRegistrarChangesNotificationEmailAddresses() {
|
||||
return ImmutableList.of("notification@test.example", "notification2@test.example");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRegistrarDefaultWhoisServer() {
|
||||
return "whois.nic.fakewhois.example";
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getRegistrarDefaultReferralUrl() {
|
||||
return makeUrl("http://www.referral.example/path");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDocumentationProjectTitle() {
|
||||
return "Domain Registry";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxChecks() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEppResourceIndexBucketCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getBaseOfyRetryDuration() {
|
||||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContactAndHostRepositoryIdentifier() {
|
||||
return "ROID";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getContactAutomaticTransferLength() {
|
||||
return standardDays(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCheckApiServletRegistrarClientId() {
|
||||
return "TheRegistrar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getAsyncDeleteFlowMapreduceDelay() {
|
||||
return Duration.standardSeconds(90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Duration getAsyncFlowFailureBackoff() {
|
||||
return Duration.standardMinutes(10);
|
||||
}
|
||||
}
|
16
java/google/registry/config/package-info.java
Normal file
16
java/google/registry/config/package-info.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2016 The Domain Registry 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.
|
||||
|
||||
@javax.annotation.ParametersAreNonnullByDefault
|
||||
package com.google.domain.registry.config;
|
Loading…
Add table
Add a link
Reference in a new issue