Import code from internal repository to git

This commit is contained in:
Justine Tunney 2016-03-01 17:18:14 -05:00
commit 0ef0c933d2
2490 changed files with 281594 additions and 0 deletions

View file

@ -0,0 +1,50 @@
package(
default_visibility = ["//java/com/google/domain/registry:registry_project"],
)
java_library(
name = "backend",
srcs = glob(["*.java"]),
deps = [
"//java/com/google/common/base",
"//java/com/google/common/collect",
"//java/com/google/common/net",
"//java/com/google/domain/registry/backup",
"//java/com/google/domain/registry/bigquery",
"//java/com/google/domain/registry/config",
"//java/com/google/domain/registry/cron",
"//java/com/google/domain/registry/dns",
"//java/com/google/domain/registry/dns/writer/api",
"//java/com/google/domain/registry/export",
"//java/com/google/domain/registry/export/sheet",
"//java/com/google/domain/registry/flows",
"//java/com/google/domain/registry/gcs",
"//java/com/google/domain/registry/groups",
"//java/com/google/domain/registry/keyring/api",
"//java/com/google/domain/registry/mapreduce",
"//java/com/google/domain/registry/model",
"//java/com/google/domain/registry/rde",
"//java/com/google/domain/registry/request",
"//java/com/google/domain/registry/request:modules",
"//java/com/google/domain/registry/tmch",
"//java/com/google/domain/registry/util",
"//third_party/java/bouncycastle",
"//third_party/java/dagger",
"//third_party/java/jsr305_annotations",
"//third_party/java/jsr330_inject",
"//third_party/java/servlet/servlet_api",
],
)
# This rule is used so bazel can generate "backend_jar_deploy.jar" (which
# contains transitive dependencies) for deployment to App Engine. It MUST
# explicitly depend upon upon anything loaded at runtime, e.g. old servlets
# referenced by the module's web.xml file, that isn't statically linked above.
java_binary(
name = "backend_jar",
create_executable = 0,
runtime_deps = [
":backend",
],
)

View file

@ -0,0 +1,74 @@
// Copyright 2016 Google Inc. 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.module.backend;
import com.google.domain.registry.bigquery.BigqueryModule;
import com.google.domain.registry.config.ConfigModule;
import com.google.domain.registry.dns.writer.api.VoidDnsWriterModule;
import com.google.domain.registry.export.DriveModule;
import com.google.domain.registry.export.sheet.SpreadsheetServiceModule;
import com.google.domain.registry.gcs.GcsServiceModule;
import com.google.domain.registry.groups.DirectoryModule;
import com.google.domain.registry.groups.GroupsModule;
import com.google.domain.registry.groups.GroupssettingsModule;
import com.google.domain.registry.keyring.api.KeyModule;
import com.google.domain.registry.keyring.api.VoidKeyringModule;
import com.google.domain.registry.rde.JSchModule;
import com.google.domain.registry.request.Modules.AppIdentityCredentialModule;
import com.google.domain.registry.request.Modules.DatastoreServiceModule;
import com.google.domain.registry.request.Modules.GoogleCredentialModule;
import com.google.domain.registry.request.Modules.Jackson2Module;
import com.google.domain.registry.request.Modules.ModulesServiceModule;
import com.google.domain.registry.request.Modules.URLFetchServiceModule;
import com.google.domain.registry.request.Modules.UrlFetchTransportModule;
import com.google.domain.registry.request.Modules.UseAppIdentityCredentialForGoogleApisModule;
import com.google.domain.registry.request.RequestModule;
import com.google.domain.registry.util.SystemClock.SystemClockModule;
import com.google.domain.registry.util.SystemSleeper.SystemSleeperModule;
import dagger.Component;
import javax.inject.Singleton;
/** Dagger component with instance lifetime for "backend" App Engine module. */
@Singleton
@Component(
modules = {
AppIdentityCredentialModule.class,
BigqueryModule.class,
ConfigModule.class,
DatastoreServiceModule.class,
DirectoryModule.class,
DriveModule.class,
GcsServiceModule.class,
GoogleCredentialModule.class,
GroupsModule.class,
GroupssettingsModule.class,
JSchModule.class,
Jackson2Module.class,
KeyModule.class,
ModulesServiceModule.class,
SpreadsheetServiceModule.class,
SystemClockModule.class,
SystemSleeperModule.class,
URLFetchServiceModule.class,
UrlFetchTransportModule.class,
UseAppIdentityCredentialForGoogleApisModule.class,
VoidDnsWriterModule.class,
VoidKeyringModule.class,
})
interface BackendComponent {
BackendRequestComponent startRequest(RequestModule requestModule);
}

View file

@ -0,0 +1,39 @@
// Copyright 2016 Google Inc. 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.module.backend;
import static com.google.domain.registry.model.registry.Registries.assertTldExists;
import static com.google.domain.registry.request.RequestParameters.extractRequiredParameter;
import com.google.domain.registry.request.Parameter;
import com.google.domain.registry.request.RequestParameters;
import dagger.Module;
import dagger.Provides;
import javax.servlet.http.HttpServletRequest;
/**
* Dagger module for injecting common settings for all Backend tasks.
*/
@Module
public class BackendModule {
@Provides
@Parameter(RequestParameters.PARAM_TLD)
static String provideTld(HttpServletRequest req) {
return assertTldExists(extractRequiredParameter(req, RequestParameters.PARAM_TLD));
}
}

View file

@ -0,0 +1,102 @@
// Copyright 2016 Google Inc. 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.module.backend;
import com.google.domain.registry.backup.BackupModule;
import com.google.domain.registry.backup.CommitLogCheckpointAction;
import com.google.domain.registry.backup.DeleteOldCommitLogsAction;
import com.google.domain.registry.backup.ExportCommitLogDiffAction;
import com.google.domain.registry.backup.RestoreCommitLogsAction;
import com.google.domain.registry.cron.CommitLogFanoutAction;
import com.google.domain.registry.cron.CronModule;
import com.google.domain.registry.cron.TldFanoutAction;
import com.google.domain.registry.dns.DnsModule;
import com.google.domain.registry.dns.PublishDnsUpdatesAction;
import com.google.domain.registry.dns.ReadDnsQueueAction;
import com.google.domain.registry.dns.RefreshDns;
import com.google.domain.registry.dns.WriteDnsTask;
import com.google.domain.registry.export.BigqueryPollJobAction;
import com.google.domain.registry.export.ExportRequestModule;
import com.google.domain.registry.export.ExportReservedTermsTask;
import com.google.domain.registry.export.SyncGroupMembersTask;
import com.google.domain.registry.export.sheet.SheetModule;
import com.google.domain.registry.export.sheet.SyncRegistrarsSheetTask;
import com.google.domain.registry.flows.async.AsyncFlowsModule;
import com.google.domain.registry.flows.async.DeleteContactResourceAction;
import com.google.domain.registry.flows.async.DeleteHostResourceAction;
import com.google.domain.registry.flows.async.DnsRefreshForHostRenameAction;
import com.google.domain.registry.mapreduce.MapreduceModule;
import com.google.domain.registry.rde.BrdaCopyTask;
import com.google.domain.registry.rde.RdeModule;
import com.google.domain.registry.rde.RdeReportTask;
import com.google.domain.registry.rde.RdeReporter;
import com.google.domain.registry.rde.RdeStagingAction;
import com.google.domain.registry.rde.RdeUploadTask;
import com.google.domain.registry.request.RequestModule;
import com.google.domain.registry.request.RequestScope;
import com.google.domain.registry.tmch.NordnUploadAction;
import com.google.domain.registry.tmch.NordnVerifyAction;
import com.google.domain.registry.tmch.TmchCrlTask;
import com.google.domain.registry.tmch.TmchDnlTask;
import com.google.domain.registry.tmch.TmchModule;
import com.google.domain.registry.tmch.TmchSmdrlTask;
import dagger.Subcomponent;
/** Dagger component with per-request lifetime for "backend" App Engine module. */
@RequestScope
@Subcomponent(
modules = {
AsyncFlowsModule.class,
BackendModule.class,
BackupModule.class,
CronModule.class,
DnsModule.class,
ExportRequestModule.class,
MapreduceModule.class,
RdeModule.class,
RequestModule.class,
SheetModule.class,
TmchModule.class,
})
interface BackendRequestComponent {
BigqueryPollJobAction bigqueryPollJobAction();
BrdaCopyTask brdaCopyTask();
CommitLogCheckpointAction commitLogCheckpointAction();
CommitLogFanoutAction commitLogFanoutAction();
DeleteContactResourceAction deleteContactResourceAction();
DeleteHostResourceAction deleteHostResourceAction();
DeleteOldCommitLogsAction deleteOldCommitLogsAction();
DnsRefreshForHostRenameAction dnsRefreshForHostRenameAction();
ExportCommitLogDiffAction exportCommitLogDiffAction();
ExportReservedTermsTask exportReservedTermsTask();
NordnUploadAction nordnUploadAction();
NordnVerifyAction nordnVerifyAction();
PublishDnsUpdatesAction publishDnsUpdatesAction();
ReadDnsQueueAction readDnsQueueAction();
RdeReportTask rdeReportTask();
RdeStagingAction rdeStagingAction();
RdeUploadTask rdeUploadTask();
RdeReporter rdeReporter();
RefreshDns refreshDns();
RestoreCommitLogsAction restoreCommitLogsAction();
SyncGroupMembersTask syncGroupMembersTask();
SyncRegistrarsSheetTask syncRegistrarsSheetTask();
TldFanoutAction tldFanoutAction();
TmchCrlTask tmchCrlTask();
TmchDnlTask tmchDnlTask();
TmchSmdrlTask tmchSmdrlTask();
WriteDnsTask writeDnsTask();
}

View file

@ -0,0 +1,58 @@
// Copyright 2016 Google Inc. 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.module.backend;
import static java.util.Arrays.asList;
import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.domain.registry.request.RequestHandler;
import com.google.domain.registry.request.RequestModule;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.io.IOException;
import java.lang.reflect.Method;
import java.security.Security;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** Servlet that should handle all requests to our "backend" App Engine module. */
public final class BackendServlet extends HttpServlet {
private static final BackendComponent component = DaggerBackendComponent.create();
private static final RequestHandler<BackendRequestComponent> requestHandler =
RequestHandler.create(BackendRequestComponent.class, FluentIterable
.from(asList(BackendRequestComponent.class.getMethods()))
.transform(new Function<Method, Method>() {
@Override
public Method apply(Method method) {
method.setAccessible(true); // Make App Engine's security manager happy.
return method;
}}));
@Override
public void init() {
Security.addProvider(new BouncyCastleProvider());
}
@Override
public void service(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
requestHandler.handleRequest(req, rsp, component.startRequest(new RequestModule(req, rsp)));
}
}

View file

@ -0,0 +1,16 @@
// Copyright 2016 Google Inc. 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.module.backend;