Inject RDAP help information in ConfigModule

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140849879
This commit is contained in:
mountford 2016-12-02 07:58:35 -08:00 committed by Ben McIlwain
parent 3740171bbf
commit c59b738b5b
57 changed files with 436 additions and 306 deletions

View file

@ -13,6 +13,7 @@ java_library(
"//java/com/google/common/collect",
"//java/com/google/common/net",
"//third_party/java/appengine:appengine-api",
"//third_party/java/auto:auto_value",
"//third_party/java/dagger",
"//third_party/java/joda_money",
"//third_party/java/joda_time",

View file

@ -26,6 +26,7 @@ import java.net.URI;
import java.net.URL;
import javax.annotation.Nullable;
import javax.inject.Qualifier;
import javax.inject.Singleton;
import org.joda.money.CurrencyUnit;
import org.joda.time.DateTimeConstants;
import org.joda.time.Duration;
@ -921,4 +922,89 @@ public final class ConfigModule {
// TODO(b/32875427): This will be moved into configuration in a text file in a future refactor.
return "google.registry.flows.custom.CustomLogicFactory";
}
/**
* Returns the help path for the RDAP terms of service.
*
* <p>Make sure that this path is equal to the key of the entry in the RDAP help map containing
* the terms of service. The ICANN operational profile requires that the TOS be included in all
* responses, and this string is used to find the TOS in the help map.
*/
@Provides
@Config("rdapTosPath")
public static String provideRdapTosPath() {
return "/tos";
}
/**
* Returns the help text to be used by RDAP.
*
* <p>Make sure that the map entry for the terms of service use the same key as specified in
* rdapTosPath above.
*/
@Singleton
@Provides
@Config("rdapHelpMap")
public static ImmutableMap<String, RdapNoticeDescriptor> provideRdapHelpMap() {
return new ImmutableMap.Builder<String, RdapNoticeDescriptor>()
.put("/", RdapNoticeDescriptor.builder()
.setTitle("RDAP Help")
.setDescription(ImmutableList.of(
"RDAP Help Topics (use /help/topic for information)",
"syntax",
"tos (Terms of Service)"))
.setLinkValueSuffix("help/")
.build())
.put("/index", RdapNoticeDescriptor.builder()
.setTitle("RDAP Help")
.setDescription(ImmutableList.of(
"RDAP Help Topics (use /help/topic for information)",
"syntax",
"tos (Terms of Service)"))
.setLinkValueSuffix("help/index")
.build())
.put("/syntax", RdapNoticeDescriptor.builder()
.setTitle("RDAP Command Syntax")
.setDescription(ImmutableList.of(
"domain/XXXX",
"nameserver/XXXX",
"entity/XXXX",
"domains?name=XXXX",
"domains?nsLdhName=XXXX",
"domains?nsIp=XXXX",
"nameservers?name=XXXX",
"nameservers?ip=XXXX",
"entities?fn=XXXX",
"entities?handle=XXXX",
"help/XXXX"))
.setLinkValueSuffix("help/syntax")
.build())
.put("/tos", RdapNoticeDescriptor.builder()
.setTitle("RDAP Terms of Service")
.setDescription(ImmutableList.of(
"By querying our Domain Database, you are agreeing to comply with these terms so"
+ " please read them carefully.",
"Any information provided is 'as is' without any guarantee of accuracy.",
"Please do not misuse the Domain Database. It is intended solely for"
+ " query-based access.",
"Don't use the Domain Database to allow, enable, or otherwise support the"
+ " transmission of mass unsolicited, commercial advertising or"
+ " solicitations.",
"Don't access our Domain Database through the use of high volume, automated"
+ " electronic processes that send queries or data to the systems of any"
+ " ICANN-accredited registrar.",
"You may only use the information contained in the Domain Database for lawful"
+ " purposes.",
"Do not compile, repackage, disseminate, or otherwise use the information"
+ " contained in the Domain Database in its entirety, or in any substantial"
+ " portion, without our prior written permission.",
"We may retain certain details about queries to our Domain Database for the"
+ " purposes of detecting and preventing misuse.",
"We reserve the right to restrict or deny your access to the database if we"
+ " suspect that you have failed to comply with these terms.",
"We reserve the right to modify this agreement at any time."))
.setLinkValueSuffix("help/tos")
.build())
.build();
}
}

View file

@ -0,0 +1,50 @@
// Copyright 2016 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 com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import javax.annotation.Nullable;
/**
* AutoValue class describing an RDAP Notice object.
*
* <p>This is used for injecting RDAP help pages.
*/
@AutoValue
public abstract class RdapNoticeDescriptor {
public static Builder builder() {
return new AutoValue_RdapNoticeDescriptor.Builder();
}
@Nullable public abstract String getTitle();
public abstract ImmutableList<String> getDescription();
@Nullable public abstract String getTypeString();
@Nullable public abstract String getLinkValueSuffix();
@Nullable public abstract String getLinkHrefUrlString();
/** Builder class for {@link RdapNoticeDescriptor}. */
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder setTitle(@Nullable String title);
public abstract Builder setDescription(Iterable<String> description);
public abstract Builder setTypeString(@Nullable String typeString);
public abstract Builder setLinkValueSuffix(@Nullable String linkValueSuffix);
public abstract Builder setLinkHrefUrlString(@Nullable String linkHrefUrlString);
public abstract RdapNoticeDescriptor build();
}
}