mirror of
https://github.com/google/nomulus
synced 2026-09-06 16:17:13 +00:00
Remove Ofy from RegistrarContact (#1680)
Also renamed the class to RegistrarPoc and deleted some unused methods.
This commit is contained in:
@@ -31,7 +31,7 @@ import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.RegistryLock;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.tld.RegistryLockDao;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.request.Action;
|
||||
@@ -296,8 +296,8 @@ public class RelockDomainAction implements Runnable {
|
||||
|
||||
ImmutableSet<String> registryLockEmailAddresses =
|
||||
registrar.getContacts().stream()
|
||||
.filter(RegistrarContact::isRegistryLockAllowed)
|
||||
.map(RegistrarContact::getRegistryLockEmailAddress)
|
||||
.filter(RegistrarPoc::isRegistryLockAllowed)
|
||||
.map(RegistrarPoc::getRegistryLockEmailAddress)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(toImmutableSet());
|
||||
|
||||
+4
-4
@@ -32,8 +32,8 @@ import com.google.common.net.MediaType;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.flows.certs.CertificateChecker;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarContact.Type;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.registrar.RegistrarPoc.Type;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
@@ -281,9 +281,9 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable
|
||||
*/
|
||||
@VisibleForTesting
|
||||
ImmutableSet<InternetAddress> getEmailAddresses(Registrar registrar, Type contactType) {
|
||||
ImmutableSortedSet<RegistrarContact> contacts = registrar.getContactsOfType(contactType);
|
||||
ImmutableSortedSet<RegistrarPoc> contacts = registrar.getContactsOfType(contactType);
|
||||
ImmutableSet.Builder<InternetAddress> recipientEmails = new ImmutableSet.Builder<>();
|
||||
for (RegistrarContact contact : contacts) {
|
||||
for (RegistrarPoc contact : contacts) {
|
||||
try {
|
||||
recipientEmails.add(new InternetAddress(contact.getEmailAddress()));
|
||||
} catch (AddressException e) {
|
||||
|
||||
@@ -32,7 +32,7 @@ import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.groups.GroupsConnection;
|
||||
import google.registry.groups.GroupsConnection.Role;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
@@ -47,7 +47,7 @@ import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Action that syncs changes to {@link RegistrarContact} entities with Google Groups.
|
||||
* Action that syncs changes to {@link RegistrarPoc} entities with Google Groups.
|
||||
*
|
||||
* <p>This uses the <a href="https://developers.google.com/admin-sdk/directory/">Directory API</a>.
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ public final class SyncGroupMembersAction implements Runnable {
|
||||
* Returns the Google Groups email address for the given registrar ID and RegistrarContact.Type.
|
||||
*/
|
||||
public static String getGroupEmailAddressForContactType(
|
||||
String registrarId, RegistrarContact.Type type, String gSuiteDomainName) {
|
||||
String registrarId, RegistrarPoc.Type type, String gSuiteDomainName) {
|
||||
// Take the registrar's ID, make it lowercase, and remove all characters that aren't
|
||||
// alphanumeric, hyphens, or underscores.
|
||||
return String.format(
|
||||
@@ -171,18 +171,17 @@ public final class SyncGroupMembersAction implements Runnable {
|
||||
private void syncRegistrarContacts(Registrar registrar) {
|
||||
String groupKey = "";
|
||||
try {
|
||||
Set<RegistrarContact> registrarContacts = registrar.getContacts();
|
||||
Set<RegistrarPoc> registrarPocs = registrar.getContacts();
|
||||
long totalAdded = 0;
|
||||
long totalRemoved = 0;
|
||||
for (final RegistrarContact.Type type : RegistrarContact.Type.values()) {
|
||||
for (final RegistrarPoc.Type type : RegistrarPoc.Type.values()) {
|
||||
groupKey =
|
||||
getGroupEmailAddressForContactType(registrar.getRegistrarId(), type, gSuiteDomainName);
|
||||
Set<String> currentMembers = groupsConnection.getMembersOfGroup(groupKey);
|
||||
Set<String> desiredMembers =
|
||||
registrarContacts
|
||||
.stream()
|
||||
registrarPocs.stream()
|
||||
.filter(contact -> contact.getTypes().contains(type))
|
||||
.map(RegistrarContact::getEmailAddress)
|
||||
.map(RegistrarPoc::getEmailAddress)
|
||||
.collect(toImmutableSet());
|
||||
for (String email : Sets.difference(desiredMembers, currentMembers)) {
|
||||
groupsConnection.addMemberToGroup(groupKey, email, Role.MEMBER);
|
||||
|
||||
@@ -17,13 +17,13 @@ package google.registry.export.sheet;
|
||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static google.registry.model.common.Cursor.CursorType.SYNC_REGISTRAR_SHEET;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.ABUSE;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.ADMIN;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.BILLING;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.LEGAL;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.MARKETING;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.TECH;
|
||||
import static google.registry.model.registrar.RegistrarContact.Type.WHOIS;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.ABUSE;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.ADMIN;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.BILLING;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.LEGAL;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.MARKETING;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.TECH;
|
||||
import static google.registry.model.registrar.RegistrarPoc.Type.WHOIS;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
@@ -36,7 +36,7 @@ import com.google.common.collect.Ordering;
|
||||
import google.registry.model.common.Cursor;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.util.Clock;
|
||||
import google.registry.util.DateTimeUtils;
|
||||
import java.io.IOException;
|
||||
@@ -92,7 +92,7 @@ class SyncRegistrarsSheet {
|
||||
.map(
|
||||
registrar -> {
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
|
||||
ImmutableSortedSet<RegistrarContact> contacts = registrar.getContacts();
|
||||
ImmutableSortedSet<RegistrarPoc> contacts = registrar.getContacts();
|
||||
RegistrarAddress address =
|
||||
firstNonNull(
|
||||
registrar.getLocalizedAddress(),
|
||||
@@ -130,10 +130,10 @@ class SyncRegistrarsSheet {
|
||||
builder.put("billingContacts", convertContacts(contacts, byType(BILLING)));
|
||||
builder.put(
|
||||
"contactsMarkedAsWhoisAdmin",
|
||||
convertContacts(contacts, RegistrarContact::getVisibleInWhoisAsAdmin));
|
||||
convertContacts(contacts, RegistrarPoc::getVisibleInWhoisAsAdmin));
|
||||
builder.put(
|
||||
"contactsMarkedAsWhoisTech",
|
||||
convertContacts(contacts, RegistrarContact::getVisibleInWhoisAsTech));
|
||||
convertContacts(contacts, RegistrarPoc::getVisibleInWhoisAsTech));
|
||||
builder.put("emailAddress", convert(registrar.getEmailAddress()));
|
||||
builder.put("address.street", convert(address.getStreet()));
|
||||
builder.put("address.city", convert(address.getCity()));
|
||||
@@ -158,10 +158,10 @@ class SyncRegistrarsSheet {
|
||||
}
|
||||
|
||||
private static String convertContacts(
|
||||
Iterable<RegistrarContact> contacts, Predicate<RegistrarContact> filter) {
|
||||
Iterable<RegistrarPoc> contacts, Predicate<RegistrarPoc> filter) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (RegistrarContact contact : contacts) {
|
||||
for (RegistrarPoc contact : contacts) {
|
||||
if (!filter.test(contact)) {
|
||||
continue;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ class SyncRegistrarsSheet {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static Predicate<RegistrarContact> byType(final RegistrarContact.Type type) {
|
||||
private static Predicate<RegistrarPoc> byType(final RegistrarPoc.Type type) {
|
||||
return contact -> contact.getTypes().contains(type);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.rde.RdeRevision;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.replay.LastSqlTransaction;
|
||||
import google.registry.model.replay.ReplayGap;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
@@ -75,7 +74,6 @@ public final class EntityClasses {
|
||||
PollMessage.OneTime.class,
|
||||
RdeRevision.class,
|
||||
Registrar.class,
|
||||
RegistrarContact.class,
|
||||
Registry.class,
|
||||
ReplayGap.class,
|
||||
ServerSecret.class);
|
||||
|
||||
@@ -35,7 +35,7 @@ import google.registry.model.common.GaeUserIdConverter;
|
||||
import google.registry.model.pricing.StaticPremiumListPricingEngine;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.model.tld.Registry.TldType;
|
||||
@@ -127,8 +127,7 @@ public final class OteAccountBuilder {
|
||||
private final Registry sunriseTld;
|
||||
private final Registry gaTld;
|
||||
private final Registry eapTld;
|
||||
private final ImmutableList.Builder<RegistrarContact> contactsBuilder =
|
||||
new ImmutableList.Builder<>();
|
||||
private final ImmutableList.Builder<RegistrarPoc> contactsBuilder = new ImmutableList.Builder<>();
|
||||
|
||||
private ImmutableList<Registrar> registrars;
|
||||
private boolean replaceExisting = false;
|
||||
@@ -259,7 +258,7 @@ public final class OteAccountBuilder {
|
||||
private void saveAllEntities() {
|
||||
// use ImmutableObject instead of Registry so that the Key generation doesn't break
|
||||
ImmutableList<Registry> registries = ImmutableList.of(sunriseTld, gaTld, eapTld);
|
||||
ImmutableList<RegistrarContact> contacts = contactsBuilder.build();
|
||||
ImmutableList<RegistrarPoc> contacts = contactsBuilder.build();
|
||||
|
||||
tm().transact(
|
||||
() -> {
|
||||
@@ -269,7 +268,7 @@ public final class OteAccountBuilder {
|
||||
registries.stream()
|
||||
.map(registry -> Registry.createVKey(registry.getTldStr())),
|
||||
registrars.stream().map(Registrar::createVKey),
|
||||
contacts.stream().map(RegistrarContact::createVKey))
|
||||
contacts.stream().map(RegistrarPoc::createVKey))
|
||||
.collect(toImmutableList());
|
||||
ImmutableMap<VKey<? extends ImmutableObject>, ImmutableObject> existingObjects =
|
||||
tm().loadByKeysIfPresent(keys);
|
||||
@@ -351,10 +350,10 @@ public final class OteAccountBuilder {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static RegistrarContact createRegistrarContact(
|
||||
private static RegistrarPoc createRegistrarContact(
|
||||
String email, String gaeUserId, Registrar registrar) {
|
||||
return new RegistrarContact.Builder()
|
||||
.setParent(registrar)
|
||||
return new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName(email)
|
||||
.setEmailAddress(email)
|
||||
.setGaeUserId(gaeUserId)
|
||||
|
||||
@@ -217,11 +217,9 @@ public class Registrar extends ImmutableObject
|
||||
immutableEnumSet(
|
||||
Type.REAL, Type.PDT, Type.OTE, Type.EXTERNAL_MONITORING, Type.MONITORING, Type.INTERNAL);
|
||||
|
||||
/**
|
||||
* Compare two instances of {@link RegistrarContact} by their email addresses lexicographically.
|
||||
*/
|
||||
private static final Comparator<RegistrarContact> CONTACT_EMAIL_COMPARATOR =
|
||||
comparing(RegistrarContact::getEmailAddress, String::compareTo);
|
||||
/** Compare two instances of {@link RegistrarPoc} by their email addresses lexicographically. */
|
||||
private static final Comparator<RegistrarPoc> CONTACT_EMAIL_COMPARATOR =
|
||||
comparing(RegistrarPoc::getEmailAddress, String::compareTo);
|
||||
|
||||
/**
|
||||
* A caching {@link Supplier} of a registrarId to {@link Registrar} map.
|
||||
@@ -628,46 +626,43 @@ public class Registrar extends ImmutableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all {@link RegistrarContact} objects for this registrar sorted by their email
|
||||
* Returns a list of all {@link RegistrarPoc} objects for this registrar sorted by their email
|
||||
* address.
|
||||
*/
|
||||
public ImmutableSortedSet<RegistrarContact> getContacts() {
|
||||
public ImmutableSortedSet<RegistrarPoc> getContacts() {
|
||||
return Streams.stream(getContactsIterable())
|
||||
.filter(Objects::nonNull)
|
||||
.collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of {@link RegistrarContact} objects of a given type for this registrar sorted by
|
||||
* Returns a list of {@link RegistrarPoc} objects of a given type for this registrar sorted by
|
||||
* their email address.
|
||||
*/
|
||||
public ImmutableSortedSet<RegistrarContact> getContactsOfType(final RegistrarContact.Type type) {
|
||||
public ImmutableSortedSet<RegistrarPoc> getContactsOfType(final RegistrarPoc.Type type) {
|
||||
return Streams.stream(getContactsIterable())
|
||||
.filter(Objects::nonNull)
|
||||
.filter((@Nullable RegistrarContact contact) -> contact.getTypes().contains(type))
|
||||
.filter((@Nullable RegistrarPoc contact) -> contact.getTypes().contains(type))
|
||||
.collect(toImmutableSortedSet(CONTACT_EMAIL_COMPARATOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link RegistrarContact} that is the WHOIS abuse contact for this registrar, or
|
||||
* empty if one does not exist.
|
||||
* Returns the {@link RegistrarPoc} that is the WHOIS abuse contact for this registrar, or empty
|
||||
* if one does not exist.
|
||||
*/
|
||||
public Optional<RegistrarContact> getWhoisAbuseContact() {
|
||||
return getContacts().stream()
|
||||
.filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse)
|
||||
.findFirst();
|
||||
public Optional<RegistrarPoc> getWhoisAbuseContact() {
|
||||
return getContacts().stream().filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse).findFirst();
|
||||
}
|
||||
|
||||
private Iterable<RegistrarContact> getContactsIterable() {
|
||||
private Iterable<RegistrarPoc> getContactsIterable() {
|
||||
if (tm().isOfy()) {
|
||||
return auditedOfy().load().type(RegistrarContact.class).ancestor(Registrar.this);
|
||||
return auditedOfy().load().type(RegistrarPoc.class).ancestor(Registrar.this);
|
||||
} else {
|
||||
return tm().transact(
|
||||
() ->
|
||||
jpaTm()
|
||||
.query(
|
||||
"FROM RegistrarPoc WHERE registrarId = :registrarId",
|
||||
RegistrarContact.class)
|
||||
"FROM RegistrarPoc WHERE registrarId = :registrarId", RegistrarPoc.class)
|
||||
.setParameter("registrarId", clientIdentifier)
|
||||
.getResultStream()
|
||||
.collect(toImmutableList()));
|
||||
|
||||
+40
-113
@@ -18,10 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||
import static google.registry.model.registrar.Registrar.checkValidEmail;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
@@ -31,36 +28,26 @@ import static google.registry.util.PasswordUtils.hashPassword;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Ignore;
|
||||
import com.googlecode.objectify.annotation.Index;
|
||||
import com.googlecode.objectify.annotation.OnLoad;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.JsonMapBuilder;
|
||||
import google.registry.model.Jsonifiable;
|
||||
import google.registry.model.UnsafeSerializable;
|
||||
import google.registry.model.annotations.InCrossTld;
|
||||
import google.registry.model.annotations.ReportedOn;
|
||||
import google.registry.model.registrar.RegistrarContact.RegistrarPocId;
|
||||
import google.registry.model.registrar.RegistrarPoc.RegistrarPocId;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.PostLoad;
|
||||
import javax.persistence.Index;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
/**
|
||||
* A contact for a Registrar. Note, equality, hashCode and comparable have been overridden to only
|
||||
@@ -69,21 +56,12 @@ import javax.persistence.Transient;
|
||||
* <p>IMPORTANT NOTE: Any time that you change, update, or delete RegistrarContact entities, you
|
||||
* *MUST* also modify the persisted Registrar entity with {@link Registrar#contactsRequireSyncing}
|
||||
* set to true.
|
||||
*
|
||||
* <p>TODO(b/177567432): Rename the class name to RegistrarPoc after database migration
|
||||
*/
|
||||
@ReportedOn
|
||||
@Entity
|
||||
@javax.persistence.Entity(name = "RegistrarPoc")
|
||||
@Table(
|
||||
indexes = {
|
||||
@javax.persistence.Index(columnList = "gaeUserId", name = "registrarpoc_gae_user_id_idx")
|
||||
})
|
||||
@Table(indexes = {@Index(columnList = "gaeUserId", name = "registrarpoc_gae_user_id_idx")})
|
||||
@IdClass(RegistrarPocId.class)
|
||||
@InCrossTld
|
||||
public class RegistrarContact extends ImmutableObject implements Jsonifiable, UnsafeSerializable {
|
||||
|
||||
@Parent @Transient Key<Registrar> parent;
|
||||
public class RegistrarPoc extends ImmutableObject implements Jsonifiable, UnsafeSerializable {
|
||||
|
||||
/**
|
||||
* Registrar contacts types for partner communication tracking.
|
||||
@@ -122,9 +100,9 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
String name;
|
||||
|
||||
/** The email address of the contact. */
|
||||
@Id @javax.persistence.Id String emailAddress;
|
||||
@Id String emailAddress;
|
||||
|
||||
@Ignore @javax.persistence.Id String registrarId;
|
||||
@Id String registrarId;
|
||||
|
||||
/** External email address of this contact used for registry lock confirmations. */
|
||||
String registryLockEmailAddress;
|
||||
@@ -148,7 +126,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
*
|
||||
* @see com.google.appengine.api.users.User#getUserId()
|
||||
*/
|
||||
@Index String gaeUserId;
|
||||
String gaeUserId;
|
||||
|
||||
/**
|
||||
* Whether this contact is publicly visible in WHOIS registrar query results as an Admin contact.
|
||||
@@ -168,7 +146,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
boolean visibleInDomainWhoisAsAbuse = false;
|
||||
|
||||
/**
|
||||
* Whether or not the contact is allowed to set their registry lock password through the registrar
|
||||
* Whether the contact is allowed to set their registry lock password through the registrar
|
||||
* console. This will be set to false on contact creation and when the user sets a password.
|
||||
*/
|
||||
boolean allowedToSetRegistryLockPassword = false;
|
||||
@@ -182,16 +160,6 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
/** Randomly generated hash salt. */
|
||||
String registryLockPasswordSalt;
|
||||
|
||||
public static ImmutableSet<Type> typesFromCSV(String csv) {
|
||||
return typesFromStrings(Arrays.asList(csv.split(",")));
|
||||
}
|
||||
|
||||
public static ImmutableSet<Type> typesFromStrings(Iterable<String> typeNames) {
|
||||
return Streams.stream(typeNames)
|
||||
.map(Enums.stringConverter(Type.class))
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to update the contacts associated with a Registrar. This requires querying for the
|
||||
* existing contacts, deleting existing contacts that are not part of the given {@code contacts}
|
||||
@@ -201,45 +169,23 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
* relevant Registrar entity with the {@link Registrar#contactsRequireSyncing} field set to true.
|
||||
*/
|
||||
public static void updateContacts(
|
||||
final Registrar registrar, final ImmutableSet<RegistrarContact> contacts) {
|
||||
final Registrar registrar, final ImmutableSet<RegistrarPoc> contacts) {
|
||||
tm().transact(
|
||||
() -> {
|
||||
if (tm().isOfy()) {
|
||||
ImmutableSet<Key<RegistrarContact>> existingKeys =
|
||||
ImmutableSet.copyOf(
|
||||
auditedOfy()
|
||||
.load()
|
||||
.type(RegistrarContact.class)
|
||||
.ancestor(registrar)
|
||||
.keys());
|
||||
tm().delete(
|
||||
difference(
|
||||
existingKeys,
|
||||
contacts.stream().map(Key::create).collect(toImmutableSet()))
|
||||
.stream()
|
||||
.map(key -> VKey.createOfy(RegistrarContact.class, key))
|
||||
.collect(toImmutableSet()));
|
||||
} else {
|
||||
ImmutableSet<String> emailAddressesToKeep =
|
||||
contacts.stream()
|
||||
.map(RegistrarContact::getEmailAddress)
|
||||
.collect(toImmutableSet());
|
||||
jpaTm()
|
||||
.query(
|
||||
"DELETE FROM RegistrarPoc WHERE registrarId = :registrarId AND "
|
||||
+ "emailAddress NOT IN :emailAddressesToKeep")
|
||||
.setParameter("registrarId", registrar.getRegistrarId())
|
||||
.setParameter("emailAddressesToKeep", emailAddressesToKeep)
|
||||
.executeUpdate();
|
||||
}
|
||||
ImmutableSet<String> emailAddressesToKeep =
|
||||
contacts.stream().map(RegistrarPoc::getEmailAddress).collect(toImmutableSet());
|
||||
jpaTm()
|
||||
.query(
|
||||
"DELETE FROM RegistrarPoc WHERE registrarId = :registrarId AND "
|
||||
+ "emailAddress NOT IN :emailAddressesToKeep")
|
||||
.setParameter("registrarId", registrar.getRegistrarId())
|
||||
.setParameter("emailAddressesToKeep", emailAddressesToKeep)
|
||||
.executeUpdate();
|
||||
|
||||
tm().putAll(contacts);
|
||||
});
|
||||
}
|
||||
|
||||
public Key<Registrar> getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -371,31 +317,11 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Sets Cloud SQL specific fields when the entity is loaded from Datastore. */
|
||||
@OnLoad
|
||||
void onLoad() {
|
||||
registrarId = parent.getName();
|
||||
public VKey<RegistrarPoc> createVKey() {
|
||||
return VKey.createSql(RegistrarPoc.class, new RegistrarPocId(emailAddress, registrarId));
|
||||
}
|
||||
|
||||
/** Sets Datastore specific fields when the entity is loaded from Cloud SQL. */
|
||||
@PostLoad
|
||||
void postLoad() {
|
||||
parent = Key.create(getCrossTldKey(), Registrar.class, registrarId);
|
||||
}
|
||||
|
||||
public VKey<RegistrarContact> createVKey() {
|
||||
return createVKey(Key.create(this));
|
||||
}
|
||||
|
||||
/** Creates a {@link VKey} instance from a {@link Key} instance. */
|
||||
public static VKey<RegistrarContact> createVKey(Key<RegistrarContact> key) {
|
||||
Key<Registrar> parent = key.getParent();
|
||||
String registrarId = parent.getName();
|
||||
String emailAddress = key.getName();
|
||||
return VKey.create(RegistrarContact.class, new RegistrarPocId(emailAddress, registrarId), key);
|
||||
}
|
||||
|
||||
/** Class to represent the composite primary key for {@link RegistrarContact} entity. */
|
||||
/** Class to represent the composite primary key for {@link RegistrarPoc} entity. */
|
||||
@VisibleForTesting
|
||||
public static class RegistrarPocId extends ImmutableObject implements Serializable {
|
||||
|
||||
@@ -404,6 +330,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
String registrarId;
|
||||
|
||||
// Hibernate requires this default constructor.
|
||||
@SuppressWarnings("unused")
|
||||
private RegistrarPocId() {}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -413,27 +340,18 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
}
|
||||
}
|
||||
|
||||
/** A builder for constructing a {@link RegistrarContact}, since it is immutable. */
|
||||
public static class Builder extends Buildable.Builder<RegistrarContact> {
|
||||
/** A builder for constructing a {@link RegistrarPoc}, since it is immutable. */
|
||||
public static class Builder extends Buildable.Builder<RegistrarPoc> {
|
||||
public Builder() {}
|
||||
|
||||
private Builder(RegistrarContact instance) {
|
||||
private Builder(RegistrarPoc instance) {
|
||||
super(instance);
|
||||
}
|
||||
|
||||
public Builder setParent(Registrar parent) {
|
||||
return this.setParent(Key.create(parent));
|
||||
}
|
||||
|
||||
public Builder setParent(Key<Registrar> parentKey) {
|
||||
getInstance().parent = parentKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Build the registrar, nullifying empty fields. */
|
||||
@Override
|
||||
public RegistrarContact build() {
|
||||
checkNotNull(getInstance().parent, "Registrar parent cannot be null");
|
||||
public RegistrarPoc build() {
|
||||
checkNotNull(getInstance().registrarId, "Registrar ID cannot be null");
|
||||
checkValidEmail(getInstance().emailAddress);
|
||||
// Check allowedToSetRegistryLockPassword here because if we want to allow the user to set
|
||||
// a registry lock password, we must also set up the correct registry lock email concurrently
|
||||
@@ -443,7 +361,6 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
!isNullOrEmpty(getInstance().registryLockEmailAddress),
|
||||
"Registry lock email must not be null if allowing registry lock access");
|
||||
}
|
||||
getInstance().registrarId = getInstance().parent.getName();
|
||||
return cloneEmptyToNull(super.build());
|
||||
}
|
||||
|
||||
@@ -467,6 +384,16 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable, Un
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRegistrarId(String registrarId) {
|
||||
getInstance().registrarId = registrarId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRegistrar(Registrar registrar) {
|
||||
getInstance().registrarId = registrar.getRegistrarId();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setFaxNumber(String faxNumber) {
|
||||
getInstance().faxNumber = faxNumber;
|
||||
return this;
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
package google.registry.persistence.converter;
|
||||
|
||||
import google.registry.model.registrar.RegistrarContact.Type;
|
||||
import google.registry.model.registrar.RegistrarPoc.Type;
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.reporting.HistoryEntryDao;
|
||||
import google.registry.persistence.VKey;
|
||||
@@ -777,7 +777,7 @@ public class RdapJsonFormatter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a JSON object for a {@link RegistrarContact}.
|
||||
* Creates a JSON object for a {@link RegistrarPoc}.
|
||||
*
|
||||
* <p>Returns empty if this contact shouldn't be visible (doesn't have a role).
|
||||
*
|
||||
@@ -794,11 +794,10 @@ public class RdapJsonFormatter {
|
||||
* <li>Registrar inside a Nameserver isn't required at all, and if given doesn't require any
|
||||
* contacts
|
||||
*
|
||||
* @param registrarContact the registrar contact for which the JSON object should be created
|
||||
* @param registrarPoc the registrar contact for which the JSON object should be created
|
||||
*/
|
||||
static Optional<RdapContactEntity> makeRdapJsonForRegistrarContact(
|
||||
RegistrarContact registrarContact) {
|
||||
ImmutableList<RdapEntity.Role> roles = makeRdapRoleList(registrarContact);
|
||||
static Optional<RdapContactEntity> makeRdapJsonForRegistrarContact(RegistrarPoc registrarPoc) {
|
||||
ImmutableList<RdapEntity.Role> roles = makeRdapRoleList(registrarPoc);
|
||||
if (roles.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -808,20 +807,20 @@ public class RdapJsonFormatter {
|
||||
// Create the vCard.
|
||||
VcardArray.Builder vcardBuilder = VcardArray.builder();
|
||||
// MUST include FN member: RDAP Response Profile 3.2
|
||||
String name = registrarContact.getName();
|
||||
String name = registrarPoc.getName();
|
||||
if (name != null) {
|
||||
vcardBuilder.add(Vcard.create("fn", "text", name));
|
||||
}
|
||||
// MUST include TEL and EMAIL members: RDAP Response Profile 2.4.5, 3.2
|
||||
String voicePhoneNumber = registrarContact.getPhoneNumber();
|
||||
String voicePhoneNumber = registrarPoc.getPhoneNumber();
|
||||
if (voicePhoneNumber != null) {
|
||||
vcardBuilder.add(makePhoneEntry(PHONE_TYPE_VOICE, "tel:" + voicePhoneNumber));
|
||||
}
|
||||
String faxPhoneNumber = registrarContact.getFaxNumber();
|
||||
String faxPhoneNumber = registrarPoc.getFaxNumber();
|
||||
if (faxPhoneNumber != null) {
|
||||
vcardBuilder.add(makePhoneEntry(PHONE_TYPE_FAX, "tel:" + faxPhoneNumber));
|
||||
}
|
||||
String emailAddress = registrarContact.getEmailAddress();
|
||||
String emailAddress = registrarPoc.getEmailAddress();
|
||||
if (emailAddress != null) {
|
||||
vcardBuilder.add(Vcard.create("email", "text", emailAddress));
|
||||
}
|
||||
@@ -857,16 +856,15 @@ public class RdapJsonFormatter {
|
||||
*
|
||||
* <p>3.2. For direct Registrar queries, we SHOULD have at least "admin" and "tech".
|
||||
*/
|
||||
private static ImmutableList<RdapEntity.Role> makeRdapRoleList(
|
||||
RegistrarContact registrarContact) {
|
||||
private static ImmutableList<RdapEntity.Role> makeRdapRoleList(RegistrarPoc registrarPoc) {
|
||||
ImmutableList.Builder<RdapEntity.Role> rolesBuilder = new ImmutableList.Builder<>();
|
||||
if (registrarContact.getVisibleInWhoisAsAdmin()) {
|
||||
if (registrarPoc.getVisibleInWhoisAsAdmin()) {
|
||||
rolesBuilder.add(RdapEntity.Role.ADMIN);
|
||||
}
|
||||
if (registrarContact.getVisibleInWhoisAsTech()) {
|
||||
if (registrarPoc.getVisibleInWhoisAsTech()) {
|
||||
rolesBuilder.add(RdapEntity.Role.TECH);
|
||||
}
|
||||
if (registrarContact.getVisibleInDomainWhoisAsAbuse()) {
|
||||
if (registrarPoc.getVisibleInDomainWhoisAsAbuse()) {
|
||||
rolesBuilder.add(RdapEntity.Role.ABUSE);
|
||||
}
|
||||
return rolesBuilder.build();
|
||||
|
||||
@@ -34,7 +34,7 @@ import google.registry.beam.spec11.ThreatMatch;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo;
|
||||
import google.registry.util.EmailMessage;
|
||||
import google.registry.util.SendEmailService;
|
||||
@@ -219,7 +219,7 @@ public class Spec11EmailUtils {
|
||||
return new InternetAddress(
|
||||
registrar
|
||||
.getWhoisAbuseContact()
|
||||
.map(RegistrarContact::getEmailAddress)
|
||||
.map(RegistrarPoc::getEmailAddress)
|
||||
.orElse(registrar.getEmailAddress()));
|
||||
}
|
||||
}
|
||||
|
||||
+18
-38
@@ -16,26 +16,21 @@ package google.registry.request.auth;
|
||||
|
||||
import static com.google.common.base.MoreObjects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.Streams.stream;
|
||||
import static google.registry.model.ofy.ObjectifyService.auditedOfy;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
|
||||
import com.google.appengine.api.users.User;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.googlecode.objectify.Key;
|
||||
import dagger.Lazy;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.groups.GroupsConnection;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.Registrar.State;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
@@ -43,8 +38,8 @@ import javax.inject.Inject;
|
||||
/**
|
||||
* Allows access only to {@link Registrar}s the current user has access to.
|
||||
*
|
||||
* <p>A user has OWNER role on a Registrar if there exists a {@link RegistrarContact} with that
|
||||
* user's gaeId and the registrar as a parent.
|
||||
* <p>A user has OWNER role on a Registrar if there exists a {@link RegistrarPoc} with that user's
|
||||
* gaeId and the registrar as a parent.
|
||||
*
|
||||
* <p>An "admin" has in addition OWNER role on {@code #registryAdminClientId} and to all non-{@code
|
||||
* REAL} registrars (see {@link Registrar#getType}).
|
||||
@@ -54,8 +49,8 @@ import javax.inject.Inject;
|
||||
* <p>A user is an "admin" if they are a GAE-admin, or if their email is in the "Support" G Suite
|
||||
* group.
|
||||
*
|
||||
* <p>NOTE: to check whether the user is in the "Support" G Suite group, we need a connection to
|
||||
* G Suite. This in turn requires we have valid JsonCredentials, which not all environments have set
|
||||
* <p>NOTE: to check whether the user is in the "Support" G Suite group, we need a connection to G
|
||||
* Suite. This in turn requires we have valid JsonCredentials, which not all environments have set
|
||||
* up. This connection will be created lazily (only if needed).
|
||||
*
|
||||
* <p>Specifically, we don't instantiate the connection if: (a) gSuiteSupportGroupEmailAddress isn't
|
||||
@@ -319,34 +314,19 @@ public class AuthenticatedRegistrarAccessor {
|
||||
logger.atInfo().log("Checking registrar contacts for user ID %s.", user.getUserId());
|
||||
|
||||
// Find all registrars that have a registrar contact with this user's ID.
|
||||
if (tm().isOfy()) {
|
||||
ImmutableList<Key<Registrar>> accessibleClientIds =
|
||||
stream(
|
||||
auditedOfy()
|
||||
.load()
|
||||
.type(RegistrarContact.class)
|
||||
.filter("gaeUserId", user.getUserId()))
|
||||
.map(RegistrarContact::getParent)
|
||||
.collect(toImmutableList());
|
||||
// Filter out disabled registrars (note that pending registrars still allow console login).
|
||||
auditedOfy().load().keys(accessibleClientIds).values().stream()
|
||||
.filter(registrar -> registrar.getState() != State.DISABLED)
|
||||
.forEach(registrar -> builder.put(registrar.getRegistrarId(), Role.OWNER));
|
||||
} else {
|
||||
jpaTm()
|
||||
.transact(
|
||||
() ->
|
||||
jpaTm()
|
||||
.query(
|
||||
"SELECT r FROM Registrar r INNER JOIN RegistrarPoc rp ON "
|
||||
+ "r.clientIdentifier = rp.registrarId WHERE rp.gaeUserId = "
|
||||
+ ":gaeUserId AND r.state != :state",
|
||||
Registrar.class)
|
||||
.setParameter("gaeUserId", user.getUserId())
|
||||
.setParameter("state", State.DISABLED)
|
||||
.getResultStream()
|
||||
.forEach(registrar -> builder.put(registrar.getRegistrarId(), Role.OWNER)));
|
||||
}
|
||||
jpaTm()
|
||||
.transact(
|
||||
() ->
|
||||
jpaTm()
|
||||
.query(
|
||||
"SELECT r FROM Registrar r INNER JOIN RegistrarPoc rp ON "
|
||||
+ "r.clientIdentifier = rp.registrarId WHERE rp.gaeUserId = "
|
||||
+ ":gaeUserId AND r.state != :state",
|
||||
Registrar.class)
|
||||
.setParameter("gaeUserId", user.getUserId())
|
||||
.setParameter("state", State.DISABLED)
|
||||
.getResultStream()
|
||||
.forEach(registrar -> builder.put(registrar.getRegistrarId(), Role.OWNER)));
|
||||
|
||||
// Admins have ADMIN access to all registrars, and also OWNER access to the registry registrar
|
||||
// and all non-REAL or non-live registrars.
|
||||
|
||||
+21
-24
@@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.common.GaeUserIdConverter;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.tools.params.OptionalPhoneNumberParameter;
|
||||
import google.registry.tools.params.PathParameter;
|
||||
import java.io.IOException;
|
||||
@@ -51,7 +51,7 @@ import javax.annotation.Nullable;
|
||||
@Parameters(
|
||||
separators = " =",
|
||||
commandDescription = "Create/read/update/delete the various contact lists for a Registrar.")
|
||||
final class RegistrarContactCommand extends MutatingCommand {
|
||||
final class RegistrarPocCommand extends MutatingCommand {
|
||||
|
||||
@Parameter(
|
||||
description = "Client identifier of the registrar account.",
|
||||
@@ -155,8 +155,7 @@ final class RegistrarContactCommand extends MutatingCommand {
|
||||
private static final ImmutableSet<Mode> MODES_REQUIRING_CONTACT_SYNC =
|
||||
ImmutableSet.of(Mode.CREATE, Mode.UPDATE, Mode.DELETE);
|
||||
|
||||
@Nullable
|
||||
private ImmutableSet<RegistrarContact.Type> contactTypes;
|
||||
@Nullable private ImmutableSet<RegistrarPoc.Type> contactTypes;
|
||||
|
||||
@Override
|
||||
protected void init() throws Exception {
|
||||
@@ -179,17 +178,16 @@ final class RegistrarContactCommand extends MutatingCommand {
|
||||
contactTypes = ImmutableSet.of();
|
||||
} else {
|
||||
contactTypes =
|
||||
contactTypeNames
|
||||
.stream()
|
||||
.map(Enums.stringConverter(RegistrarContact.Type.class))
|
||||
contactTypeNames.stream()
|
||||
.map(Enums.stringConverter(RegistrarPoc.Type.class))
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
ImmutableSet<RegistrarContact> contacts = registrar.getContacts();
|
||||
Map<String, RegistrarContact> contactsMap = new LinkedHashMap<>();
|
||||
for (RegistrarContact rc : contacts) {
|
||||
ImmutableSet<RegistrarPoc> contacts = registrar.getContacts();
|
||||
Map<String, RegistrarPoc> contactsMap = new LinkedHashMap<>();
|
||||
for (RegistrarPoc rc : contacts) {
|
||||
contactsMap.put(rc.getEmailAddress(), rc);
|
||||
}
|
||||
RegistrarContact oldContact;
|
||||
RegistrarPoc oldContact;
|
||||
switch (mode) {
|
||||
case LIST:
|
||||
listContacts(contacts);
|
||||
@@ -206,7 +204,7 @@ final class RegistrarContactCommand extends MutatingCommand {
|
||||
contactsMap.get(checkNotNull(email, "--email is required when --mode=UPDATE")),
|
||||
"No contact with the given email: %s",
|
||||
email);
|
||||
RegistrarContact newContact = updateContact(oldContact, registrar);
|
||||
RegistrarPoc newContact = updateContact(oldContact, registrar);
|
||||
checkArgument(
|
||||
!oldContact.getVisibleInDomainWhoisAsAbuse()
|
||||
|| newContact.getVisibleInDomainWhoisAsAbuse(),
|
||||
@@ -236,19 +234,19 @@ final class RegistrarContactCommand extends MutatingCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void listContacts(Set<RegistrarContact> contacts) throws IOException {
|
||||
private void listContacts(Set<RegistrarPoc> contacts) throws IOException {
|
||||
List<String> result = new ArrayList<>();
|
||||
for (RegistrarContact c : contacts) {
|
||||
for (RegistrarPoc c : contacts) {
|
||||
result.add(c.toStringMultilinePlainText());
|
||||
}
|
||||
Files.write(output, Joiner.on('\n').join(result).getBytes(UTF_8));
|
||||
}
|
||||
|
||||
private RegistrarContact createContact(Registrar registrar) {
|
||||
private RegistrarPoc createContact(Registrar registrar) {
|
||||
checkArgument(!isNullOrEmpty(name), "--name is required when --mode=CREATE");
|
||||
checkArgument(!isNullOrEmpty(email), "--email is required when --mode=CREATE");
|
||||
RegistrarContact.Builder builder = new RegistrarContact.Builder();
|
||||
builder.setParent(registrar);
|
||||
RegistrarPoc.Builder builder = new RegistrarPoc.Builder();
|
||||
builder.setRegistrar(registrar);
|
||||
builder.setName(name);
|
||||
builder.setEmailAddress(email);
|
||||
if (!isNullOrEmpty(registryLockEmail)) {
|
||||
@@ -282,11 +280,11 @@ final class RegistrarContactCommand extends MutatingCommand {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private RegistrarContact updateContact(RegistrarContact contact, Registrar registrar) {
|
||||
private RegistrarPoc updateContact(RegistrarPoc contact, Registrar registrar) {
|
||||
checkNotNull(registrar);
|
||||
checkArgument(!isNullOrEmpty(email), "--email is required when --mode=UPDATE");
|
||||
RegistrarContact.Builder builder =
|
||||
contact.asBuilder().setEmailAddress(email).setParent(registrar);
|
||||
RegistrarPoc.Builder builder =
|
||||
contact.asBuilder().setEmailAddress(email).setRegistrar(registrar);
|
||||
if (!isNullOrEmpty(name)) {
|
||||
builder.setName(name);
|
||||
}
|
||||
@@ -327,12 +325,11 @@ final class RegistrarContactCommand extends MutatingCommand {
|
||||
}
|
||||
|
||||
private void unsetOtherWhoisAbuseFlags(
|
||||
ImmutableSet<RegistrarContact> contacts, @Nullable String emailAddressNotToChange) {
|
||||
for (RegistrarContact contact : contacts) {
|
||||
ImmutableSet<RegistrarPoc> contacts, @Nullable String emailAddressNotToChange) {
|
||||
for (RegistrarPoc contact : contacts) {
|
||||
if (!contact.getEmailAddress().equals(emailAddressNotToChange)
|
||||
&& contact.getVisibleInDomainWhoisAsAbuse()) {
|
||||
RegistrarContact newContact =
|
||||
contact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build();
|
||||
RegistrarPoc newContact = contact.asBuilder().setVisibleInDomainWhoisAsAbuse(false).build();
|
||||
stageEntityChange(contact, newContact);
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public final class RegistryTool {
|
||||
.put("login", LoginCommand.class)
|
||||
.put("logout", LogoutCommand.class)
|
||||
.put("pending_escrow", PendingEscrowCommand.class)
|
||||
.put("registrar_contact", RegistrarContactCommand.class)
|
||||
.put("registrar_poc", RegistrarPocCommand.class)
|
||||
.put("renew_domain", RenewDomainCommand.class)
|
||||
.put("resave_environment_entities", ResaveEnvironmentEntitiesCommand.class)
|
||||
.put("save_sql_credential", SaveSqlCredentialCommand.class)
|
||||
|
||||
@@ -23,14 +23,14 @@ import com.beust.jcommander.Parameters;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.annotations.DeleteAfterMigration;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.tld.Registry;
|
||||
|
||||
/**
|
||||
* Command to re-save all environment entities to ensure that they have valid commit logs.
|
||||
*
|
||||
* <p>The entities that are re-saved are those of type {@link Registry}, {@link Registrar}, and
|
||||
* {@link RegistrarContact}.
|
||||
* {@link RegistrarPoc}.
|
||||
*/
|
||||
@Parameters(commandDescription = "Re-save all environment entities.")
|
||||
@DeleteAfterMigration
|
||||
@@ -42,7 +42,7 @@ final class ResaveEnvironmentEntitiesCommand implements CommandWithRemoteApi {
|
||||
public void run() {
|
||||
batchSave(Registry.class);
|
||||
batchSave(Registrar.class);
|
||||
batchSave(RegistrarContact.class);
|
||||
batchSave(RegistrarPoc.class);
|
||||
}
|
||||
|
||||
private static <T> void batchSave(Class<T> clazz) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.groups.GroupsConnection;
|
||||
import google.registry.groups.GroupsConnection.Role;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
@@ -64,7 +64,7 @@ public class CreateGroupsAction implements Runnable {
|
||||
if (registrar == null) {
|
||||
return;
|
||||
}
|
||||
List<RegistrarContact.Type> types = asList(RegistrarContact.Type.values());
|
||||
List<RegistrarPoc.Type> types = asList(RegistrarPoc.Type.values());
|
||||
// Concurrently create the groups for each RegistrarContact.Type, collecting the results from
|
||||
// each call (which are either an Exception if it failed, or absent() if it succeeded).
|
||||
List<Optional<Exception>> results =
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.google.common.net.InternetDomainName;
|
||||
import com.google.re2j.Pattern;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.ui.forms.FormException;
|
||||
import google.registry.ui.forms.FormField;
|
||||
import google.registry.ui.forms.FormFieldException;
|
||||
@@ -217,10 +217,10 @@ public final class RegistrarFormFields {
|
||||
public static final FormField<String, String> CONTACT_REGISTRY_LOCK_PASSWORD_FIELD =
|
||||
FormFields.NAME.asBuilderNamed("registryLockPassword").build();
|
||||
|
||||
public static final FormField<String, Set<RegistrarContact.Type>> CONTACT_TYPES =
|
||||
public static final FormField<String, Set<RegistrarPoc.Type>> CONTACT_TYPES =
|
||||
FormField.named("types")
|
||||
.uppercased()
|
||||
.asEnum(RegistrarContact.Type.class)
|
||||
.asEnum(RegistrarPoc.Type.class)
|
||||
.asSet(Splitter.on(',').omitEmptyStrings().trimResults())
|
||||
.build();
|
||||
|
||||
@@ -348,8 +348,8 @@ public final class RegistrarFormFields {
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutableList<RegistrarContact.Builder> getRegistrarContactBuilders(
|
||||
ImmutableSet<RegistrarContact> existingContacts, @Nullable Map<String, ?> args) {
|
||||
public static ImmutableList<RegistrarPoc.Builder> getRegistrarContactBuilders(
|
||||
ImmutableSet<RegistrarPoc> existingContacts, @Nullable Map<String, ?> args) {
|
||||
if (args == null) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public final class RegistrarFormFields {
|
||||
if (!contactsAsMaps.isPresent()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
ImmutableList.Builder<RegistrarContact.Builder> result = new ImmutableList.Builder<>();
|
||||
ImmutableList.Builder<RegistrarPoc.Builder> result = new ImmutableList.Builder<>();
|
||||
for (Map<String, ?> contactAsMap : contactsAsMaps.get()) {
|
||||
String emailAddress =
|
||||
CONTACT_EMAIL_ADDRESS_FIELD
|
||||
@@ -365,20 +365,19 @@ public final class RegistrarFormFields {
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException("Contacts from UI must have email addresses"));
|
||||
// Start with a new builder if the contact didn't previously exist
|
||||
RegistrarContact.Builder contactBuilder =
|
||||
RegistrarPoc.Builder contactBuilder =
|
||||
existingContacts.stream()
|
||||
.filter(rc -> rc.getEmailAddress().equals(emailAddress))
|
||||
.findFirst()
|
||||
.map(RegistrarContact::asBuilder)
|
||||
.orElse(new RegistrarContact.Builder());
|
||||
.map(RegistrarPoc::asBuilder)
|
||||
.orElse(new RegistrarPoc.Builder());
|
||||
applyRegistrarContactArgs(contactBuilder, contactAsMap);
|
||||
result.add(contactBuilder);
|
||||
}
|
||||
return result.build();
|
||||
}
|
||||
|
||||
private static void applyRegistrarContactArgs(
|
||||
RegistrarContact.Builder builder, Map<String, ?> args) {
|
||||
private static void applyRegistrarContactArgs(RegistrarPoc.Builder builder, Map<String, ?> args) {
|
||||
builder.setName(CONTACT_NAME_FIELD.extractUntyped(args).orElse(null));
|
||||
builder.setEmailAddress(CONTACT_EMAIL_ADDRESS_FIELD.extractUntyped(args).orElse(null));
|
||||
builder.setRegistryLockEmailAddress(
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ import com.google.template.soy.tofu.SoyTofu;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Action.Method;
|
||||
import google.registry.request.Parameter;
|
||||
@@ -227,9 +227,9 @@ public final class ConsoleRegistrarCreatorAction extends HtmlAction {
|
||||
.setZip(optionalZip.orElse(null))
|
||||
.build())
|
||||
.build();
|
||||
RegistrarContact contact =
|
||||
new RegistrarContact.Builder()
|
||||
.setParent(registrar)
|
||||
RegistrarPoc contact =
|
||||
new RegistrarPoc.Builder()
|
||||
.setRegistrar(registrar)
|
||||
.setName(consoleUserEmail.get())
|
||||
.setEmailAddress(consoleUserEmail.get())
|
||||
.setGaeUserId(gaeUserId)
|
||||
|
||||
+34
-36
@@ -42,8 +42,8 @@ import google.registry.export.sheet.SyncRegistrarsSheetAction;
|
||||
import google.registry.flows.certs.CertificateChecker;
|
||||
import google.registry.flows.certs.CertificateChecker.InsecureCertificateException;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarContact.Type;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.registrar.RegistrarPoc.Type;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Action.Service;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
@@ -116,7 +116,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
|
||||
@Inject RegistrarSettingsAction() {}
|
||||
|
||||
private static boolean hasPhone(RegistrarContact contact) {
|
||||
private static boolean hasPhone(RegistrarPoc contact) {
|
||||
return contact.getPhoneNumber() != null;
|
||||
}
|
||||
|
||||
@@ -202,15 +202,15 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
|
||||
abstract Registrar updatedRegistrar();
|
||||
|
||||
abstract ImmutableSet<RegistrarContact> contacts();
|
||||
abstract ImmutableSet<RegistrarPoc> contacts();
|
||||
|
||||
abstract ImmutableSet<RegistrarContact> updatedContacts();
|
||||
abstract ImmutableSet<RegistrarPoc> updatedContacts();
|
||||
|
||||
static EmailInfo create(
|
||||
Registrar registrar,
|
||||
Registrar updatedRegistrar,
|
||||
ImmutableSet<RegistrarContact> contacts,
|
||||
ImmutableSet<RegistrarContact> updatedContacts) {
|
||||
ImmutableSet<RegistrarPoc> contacts,
|
||||
ImmutableSet<RegistrarPoc> updatedContacts) {
|
||||
return new AutoValue_RegistrarSettingsAction_EmailInfo(
|
||||
registrar, updatedRegistrar, contacts, updatedContacts);
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
|
||||
// Keep the current contacts so we can later check that no required contact was
|
||||
// removed, email the changes to the contacts
|
||||
ImmutableSet<RegistrarContact> contacts = registrar.getContacts();
|
||||
ImmutableSet<RegistrarPoc> contacts = registrar.getContacts();
|
||||
|
||||
Registrar updatedRegistrar = registrar;
|
||||
// Do OWNER only updates to the registrar from the request.
|
||||
@@ -273,7 +273,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
updatedRegistrar = checkAndUpdateAdminControlledFields(updatedRegistrar, args);
|
||||
|
||||
// read the contacts from the request.
|
||||
ImmutableSet<RegistrarContact> updatedContacts = readContacts(registrar, contacts, args);
|
||||
ImmutableSet<RegistrarPoc> updatedContacts = readContacts(registrar, contacts, args);
|
||||
|
||||
// Save the updated contacts
|
||||
if (!updatedContacts.equals(contacts)) {
|
||||
@@ -281,7 +281,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
throw new ForbiddenException("Only OWNERs can update the contacts");
|
||||
}
|
||||
checkContactRequirements(contacts, updatedContacts);
|
||||
RegistrarContact.updateContacts(updatedRegistrar, updatedContacts);
|
||||
RegistrarPoc.updateContacts(updatedRegistrar, updatedContacts);
|
||||
updatedRegistrar = updatedRegistrar.asBuilder().setContactsRequireSyncing(true).build();
|
||||
}
|
||||
|
||||
@@ -293,10 +293,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
}
|
||||
|
||||
private Map<String, Object> expandRegistrarWithContacts(
|
||||
Iterable<RegistrarContact> contacts, Registrar registrar) {
|
||||
Iterable<RegistrarPoc> contacts, Registrar registrar) {
|
||||
ImmutableSet<Map<String, Object>> expandedContacts =
|
||||
Streams.stream(contacts)
|
||||
.map(RegistrarContact::toDiffableFieldMap)
|
||||
.map(RegistrarPoc::toDiffableFieldMap)
|
||||
// Note: per the javadoc, toDiffableFieldMap includes sensitive data but we don't want
|
||||
// to display it here
|
||||
.peek(
|
||||
@@ -463,10 +463,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
}
|
||||
|
||||
/** Reads the contacts from the supplied args. */
|
||||
public static ImmutableSet<RegistrarContact> readContacts(
|
||||
Registrar registrar, ImmutableSet<RegistrarContact> existingContacts, Map<String, ?> args) {
|
||||
public static ImmutableSet<RegistrarPoc> readContacts(
|
||||
Registrar registrar, ImmutableSet<RegistrarPoc> existingContacts, Map<String, ?> args) {
|
||||
return RegistrarFormFields.getRegistrarContactBuilders(existingContacts, args).stream()
|
||||
.map(builder -> builder.setParent(registrar).build())
|
||||
.map(builder -> builder.setRegistrar(registrar).build())
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
@@ -476,11 +476,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
* @throws FormException if the checks fail.
|
||||
*/
|
||||
void checkContactRequirements(
|
||||
ImmutableSet<RegistrarContact> existingContacts,
|
||||
ImmutableSet<RegistrarContact> updatedContacts) {
|
||||
ImmutableSet<RegistrarPoc> existingContacts, ImmutableSet<RegistrarPoc> updatedContacts) {
|
||||
// Check that no two contacts use the same email address.
|
||||
Set<String> emails = new HashSet<>();
|
||||
for (RegistrarContact contact : updatedContacts) {
|
||||
for (RegistrarPoc contact : updatedContacts) {
|
||||
if (!emails.add(contact.getEmailAddress())) {
|
||||
throw new ContactRequirementException(
|
||||
String.format(
|
||||
@@ -489,14 +488,14 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
}
|
||||
}
|
||||
// Check that required contacts don't go away, once they are set.
|
||||
Multimap<Type, RegistrarContact> oldContactsByType = HashMultimap.create();
|
||||
for (RegistrarContact contact : existingContacts) {
|
||||
Multimap<Type, RegistrarPoc> oldContactsByType = HashMultimap.create();
|
||||
for (RegistrarPoc contact : existingContacts) {
|
||||
for (Type t : contact.getTypes()) {
|
||||
oldContactsByType.put(t, contact);
|
||||
}
|
||||
}
|
||||
Multimap<Type, RegistrarContact> newContactsByType = HashMultimap.create();
|
||||
for (RegistrarContact contact : updatedContacts) {
|
||||
Multimap<Type, RegistrarPoc> newContactsByType = HashMultimap.create();
|
||||
for (RegistrarPoc contact : updatedContacts) {
|
||||
for (Type t : contact.getTypes()) {
|
||||
newContactsByType.put(t, contact);
|
||||
}
|
||||
@@ -507,7 +506,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
}
|
||||
}
|
||||
ensurePhoneNumberNotRemovedForContactTypes(oldContactsByType, newContactsByType, Type.TECH);
|
||||
Optional<RegistrarContact> domainWhoisAbuseContact =
|
||||
Optional<RegistrarPoc> domainWhoisAbuseContact =
|
||||
getDomainWhoisVisibleAbuseContact(updatedContacts);
|
||||
// If the new set has a domain WHOIS abuse contact, it must have a phone number.
|
||||
if (domainWhoisAbuseContact.isPresent()
|
||||
@@ -525,13 +524,12 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
}
|
||||
|
||||
private static void checkContactRegistryLockRequirements(
|
||||
ImmutableSet<RegistrarContact> existingContacts,
|
||||
ImmutableSet<RegistrarContact> updatedContacts) {
|
||||
ImmutableSet<RegistrarPoc> existingContacts, ImmutableSet<RegistrarPoc> updatedContacts) {
|
||||
// Any contact(s) with new passwords must be allowed to set them
|
||||
for (RegistrarContact updatedContact : updatedContacts) {
|
||||
for (RegistrarPoc updatedContact : updatedContacts) {
|
||||
if (updatedContact.isRegistryLockAllowed()
|
||||
|| updatedContact.isAllowedToSetRegistryLockPassword()) {
|
||||
RegistrarContact existingContact =
|
||||
RegistrarPoc existingContact =
|
||||
existingContacts.stream()
|
||||
.filter(
|
||||
contact -> contact.getEmailAddress().equals(updatedContact.getEmailAddress()))
|
||||
@@ -564,10 +562,10 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
|
||||
// Any previously-existing contacts with registry lock enabled cannot be deleted
|
||||
existingContacts.stream()
|
||||
.filter(RegistrarContact::isRegistryLockAllowed)
|
||||
.filter(RegistrarPoc::isRegistryLockAllowed)
|
||||
.forEach(
|
||||
contact -> {
|
||||
Optional<RegistrarContact> updatedContactOptional =
|
||||
Optional<RegistrarPoc> updatedContactOptional =
|
||||
updatedContacts.stream()
|
||||
.filter(
|
||||
updatedContact ->
|
||||
@@ -593,8 +591,8 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
* one before.
|
||||
*/
|
||||
private static void ensurePhoneNumberNotRemovedForContactTypes(
|
||||
Multimap<Type, RegistrarContact> oldContactsByType,
|
||||
Multimap<Type, RegistrarContact> newContactsByType,
|
||||
Multimap<Type, RegistrarPoc> oldContactsByType,
|
||||
Multimap<Type, RegistrarPoc> newContactsByType,
|
||||
Type... types) {
|
||||
for (Type type : types) {
|
||||
if (oldContactsByType.get(type).stream().anyMatch(RegistrarSettingsAction::hasPhone)
|
||||
@@ -615,9 +613,9 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
* WHOIS record. Therefore it is possible to return inside the loop once one such contact is
|
||||
* found.
|
||||
*/
|
||||
private static Optional<RegistrarContact> getDomainWhoisVisibleAbuseContact(
|
||||
Set<RegistrarContact> contacts) {
|
||||
return contacts.stream().filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse).findFirst();
|
||||
private static Optional<RegistrarPoc> getDomainWhoisVisibleAbuseContact(
|
||||
Set<RegistrarPoc> contacts) {
|
||||
return contacts.stream().filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -626,7 +624,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
* contact addresses and enqueues a task to re-sync the registrar sheet.
|
||||
*/
|
||||
private void sendExternalUpdatesIfNecessary(EmailInfo emailInfo) {
|
||||
ImmutableSet<RegistrarContact> existingContacts = emailInfo.contacts();
|
||||
ImmutableSet<RegistrarPoc> existingContacts = emailInfo.contacts();
|
||||
if (!sendEmailUtils.hasRecipients() && existingContacts.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -663,7 +661,7 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
||||
DiffUtils.prettyPrintDiffedMap(diffs, null)),
|
||||
existingContacts.stream()
|
||||
.filter(c -> c.getTypes().contains(Type.ADMIN))
|
||||
.map(RegistrarContact::getEmailAddress)
|
||||
.map(RegistrarPoc::getEmailAddress)
|
||||
.collect(toImmutableList()));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.google.common.net.MediaType;
|
||||
import com.google.gson.Gson;
|
||||
import google.registry.model.domain.RegistryLock;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.tld.RegistryLockDao;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Action.Method;
|
||||
@@ -118,17 +118,15 @@ public final class RegistryLockGetAction implements JsonGetAction {
|
||||
}
|
||||
}
|
||||
|
||||
static Optional<RegistrarContact> getContactMatchingLogin(User user, Registrar registrar) {
|
||||
ImmutableList<RegistrarContact> matchingContacts =
|
||||
static Optional<RegistrarPoc> getContactMatchingLogin(User user, Registrar registrar) {
|
||||
ImmutableList<RegistrarPoc> matchingContacts =
|
||||
registrar.getContacts().stream()
|
||||
.filter(contact -> contact.getGaeUserId() != null)
|
||||
.filter(contact -> Objects.equals(contact.getGaeUserId(), user.getUserId()))
|
||||
.collect(toImmutableList());
|
||||
if (matchingContacts.size() > 1) {
|
||||
ImmutableList<String> matchingEmails =
|
||||
matchingContacts.stream()
|
||||
.map(RegistrarContact::getEmailAddress)
|
||||
.collect(toImmutableList());
|
||||
matchingContacts.stream().map(RegistrarPoc::getEmailAddress).collect(toImmutableList());
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"User ID %s had multiple matching contacts with email addresses %s",
|
||||
@@ -157,15 +155,15 @@ public final class RegistryLockGetAction implements JsonGetAction {
|
||||
Registrar registrar = getRegistrarAndVerifyLockAccess(registrarAccessor, registrarId, isAdmin);
|
||||
User user = authResult.userAuthInfo().get().user();
|
||||
|
||||
Optional<RegistrarContact> contactOptional = getContactMatchingLogin(user, registrar);
|
||||
Optional<RegistrarPoc> contactOptional = getContactMatchingLogin(user, registrar);
|
||||
boolean isRegistryLockAllowed =
|
||||
isAdmin || contactOptional.map(RegistrarContact::isRegistryLockAllowed).orElse(false);
|
||||
isAdmin || contactOptional.map(RegistrarPoc::isRegistryLockAllowed).orElse(false);
|
||||
// Use the contact's registry lock email if it's present, else use the login email (for admins)
|
||||
String relevantEmail =
|
||||
isAdmin
|
||||
? user.getEmail()
|
||||
// if the contact isn't present, we shouldn't display the email anyway so empty is fine
|
||||
: contactOptional.flatMap(RegistrarContact::getRegistryLockEmailAddress).orElse("");
|
||||
: contactOptional.flatMap(RegistrarPoc::getRegistryLockEmailAddress).orElse("");
|
||||
return ImmutableMap.of(
|
||||
LOCK_ENABLED_FOR_CONTACT_PARAM,
|
||||
isRegistryLockAllowed,
|
||||
|
||||
@@ -33,7 +33,7 @@ import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.flows.domain.DomainFlowUtils;
|
||||
import google.registry.model.domain.RegistryLock;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Action.Method;
|
||||
import google.registry.request.HttpException.ForbiddenException;
|
||||
@@ -192,7 +192,7 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc
|
||||
// registry lock enabled, and that the user provided a correct password
|
||||
Registrar registrar =
|
||||
getRegistrarAndVerifyLockAccess(registrarAccessor, postInput.registrarId, false);
|
||||
RegistrarContact registrarContact =
|
||||
RegistrarPoc registrarPoc =
|
||||
getContactMatchingLogin(user, registrar)
|
||||
.orElseThrow(
|
||||
() ->
|
||||
@@ -200,16 +200,16 @@ public class RegistryLockPostAction implements Runnable, JsonActionRunner.JsonAc
|
||||
String.format(
|
||||
"Cannot match user %s to registrar contact", user.getUserId())));
|
||||
checkArgument(
|
||||
registrarContact.verifyRegistryLockPassword(postInput.password),
|
||||
registrarPoc.verifyRegistryLockPassword(postInput.password),
|
||||
"Incorrect registry lock password for contact");
|
||||
return registrarContact
|
||||
return registrarPoc
|
||||
.getRegistryLockEmailAddress()
|
||||
.orElseThrow(
|
||||
() ->
|
||||
new IllegalStateException(
|
||||
String.format(
|
||||
"Contact %s had no registry lock email address",
|
||||
registrarContact.getEmailAddress())));
|
||||
registrarPoc.getEmailAddress())));
|
||||
}
|
||||
|
||||
/** Value class that represents the expected input body from the UI request. */
|
||||
|
||||
@@ -32,7 +32,7 @@ import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import google.registry.model.translators.EnumToAttributeAdapter.EppEnum;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.util.Objects;
|
||||
@@ -80,11 +80,9 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
||||
"Could not load registrar %s",
|
||||
domain.getCurrentSponsorRegistrarId());
|
||||
Registrar registrar = registrarOptional.get();
|
||||
Optional<RegistrarContact> abuseContact =
|
||||
registrar
|
||||
.getContacts()
|
||||
.stream()
|
||||
.filter(RegistrarContact::getVisibleInDomainWhoisAsAbuse)
|
||||
Optional<RegistrarPoc> abuseContact =
|
||||
registrar.getContacts().stream()
|
||||
.filter(RegistrarPoc::getVisibleInDomainWhoisAsAbuse)
|
||||
.findFirst();
|
||||
return WhoisResponseResults.create(
|
||||
new DomainEmitter()
|
||||
@@ -102,10 +100,10 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
|
||||
// is an abuse contact, we can get an email address from it.
|
||||
.emitField(
|
||||
"Registrar Abuse Contact Email",
|
||||
abuseContact.map(RegistrarContact::getEmailAddress).orElse(""))
|
||||
abuseContact.map(RegistrarPoc::getEmailAddress).orElse(""))
|
||||
.emitField(
|
||||
"Registrar Abuse Contact Phone",
|
||||
abuseContact.map(RegistrarContact::getPhoneNumber).orElse(""))
|
||||
abuseContact.map(RegistrarPoc::getPhoneNumber).orElse(""))
|
||||
.emitStatusValues(domain.getStatusValues(), domain.getGracePeriods())
|
||||
.emitContact("Registrant", Optional.of(domain.getRegistrant()), preferUnicode)
|
||||
.emitContact("Admin", getContactReference(Type.ADMIN), preferUnicode)
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.whois;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarPoc;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -44,7 +44,7 @@ class RegistrarWhoisResponse extends WhoisResponseImpl {
|
||||
|
||||
@Override
|
||||
public WhoisResponseResults getResponse(boolean preferUnicode, String disclaimer) {
|
||||
Set<RegistrarContact> contacts = registrar.getContacts();
|
||||
Set<RegistrarPoc> contacts = registrar.getContacts();
|
||||
String plaintext =
|
||||
new RegistrarEmitter()
|
||||
.emitField("Registrar", registrar.getRegistrarName())
|
||||
@@ -59,8 +59,8 @@ class RegistrarWhoisResponse extends WhoisResponseImpl {
|
||||
registrar.getPhoneNumber(), registrar.getFaxNumber(), registrar.getEmailAddress())
|
||||
.emitField("Registrar WHOIS Server", registrar.getWhoisServer())
|
||||
.emitField("Registrar URL", registrar.getUrl())
|
||||
.emitRegistrarContacts("Admin", contacts, AdminOrTech.ADMIN)
|
||||
.emitRegistrarContacts("Technical", contacts, AdminOrTech.TECH)
|
||||
.emitRegistrarPocs("Admin", contacts, AdminOrTech.ADMIN)
|
||||
.emitRegistrarPocs("Technical", contacts, AdminOrTech.TECH)
|
||||
.emitLastUpdated(getTimestamp())
|
||||
.emitFooter(disclaimer)
|
||||
.toString();
|
||||
@@ -70,11 +70,9 @@ class RegistrarWhoisResponse extends WhoisResponseImpl {
|
||||
/** An emitter with logic for registrars. */
|
||||
static class RegistrarEmitter extends Emitter<RegistrarEmitter> {
|
||||
/** Emits the registrar contact of the given type. */
|
||||
RegistrarEmitter emitRegistrarContacts(
|
||||
String contactLabel,
|
||||
Iterable<RegistrarContact> contacts,
|
||||
AdminOrTech type) {
|
||||
for (RegistrarContact contact : contacts) {
|
||||
RegistrarEmitter emitRegistrarPocs(
|
||||
String contactLabel, Iterable<RegistrarPoc> contacts, AdminOrTech type) {
|
||||
for (RegistrarPoc contact : contacts) {
|
||||
if ((type == AdminOrTech.ADMIN && contact.getVisibleInWhoisAsAdmin())
|
||||
|| (type == AdminOrTech.TECH && contact.getVisibleInWhoisAsTech())) {
|
||||
emitField(contactLabel + " Contact", contact.getName())
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<class>google.registry.model.poll.PollMessage$Autorenew</class>
|
||||
<class>google.registry.model.rde.RdeRevision</class>
|
||||
<class>google.registry.model.registrar.Registrar</class>
|
||||
<class>google.registry.model.registrar.RegistrarContact</class>
|
||||
<class>google.registry.model.registrar.RegistrarPoc</class>
|
||||
<class>google.registry.model.tld.label.PremiumList</class>
|
||||
<class>google.registry.model.tld.label.PremiumList$PremiumEntry</class>
|
||||
<class>google.registry.model.tld.label.ReservedList</class>
|
||||
|
||||
Reference in New Issue
Block a user