mirror of
https://github.com/google/nomulus.git
synced 2025-07-02 17:23:32 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
133
java/google/registry/model/eppcommon/Address.java
Normal file
133
java/google/registry/model/eppcommon/Address.java
Normal file
|
@ -0,0 +1,133 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.domain.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.domain.registry.model.Buildable;
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
import com.google.domain.registry.model.JsonMapBuilder;
|
||||
import com.google.domain.registry.model.Jsonifiable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.NormalizedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* Container for generic street address.
|
||||
* <p>
|
||||
* This is the "addrType" type from {@link "http://tools.ietf.org/html/rfc5733"}. It also matches
|
||||
* the "addrType" type from {@link "http://tools.ietf.org/html/draft-lozano-tmch-smd"}.
|
||||
*
|
||||
* @see com.google.domain.registry.model.contact.ContactAddress
|
||||
* @see com.google.domain.registry.model.mark.MarkAddress
|
||||
* @see com.google.domain.registry.model.registrar.RegistrarAddress
|
||||
*/
|
||||
@XmlTransient
|
||||
public class Address extends ImmutableObject implements Jsonifiable {
|
||||
|
||||
/** The schema validation will enforce that this has 3 lines at most. */
|
||||
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
|
||||
List<String> street;
|
||||
|
||||
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
|
||||
String city;
|
||||
|
||||
@XmlElement(name = "sp")
|
||||
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
|
||||
String state;
|
||||
|
||||
@XmlElement(name = "pc")
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
String zip;
|
||||
|
||||
@XmlElement(name = "cc")
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
String countryCode;
|
||||
|
||||
public ImmutableList<String> getStreet() {
|
||||
return nullToEmptyImmutableCopy(street);
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toJsonMap() {
|
||||
return new JsonMapBuilder()
|
||||
.putListOfStrings("street", street)
|
||||
.put("city", city)
|
||||
.put("state", state)
|
||||
.put("zip", zip)
|
||||
.put("countryCode", countryCode)
|
||||
.build();
|
||||
}
|
||||
|
||||
/** A builder for constructing {@link Address}. */
|
||||
@VisibleForTesting
|
||||
public static class Builder<T extends Address> extends Buildable.Builder<T> {
|
||||
public Builder<T> setStreet(ImmutableList<String> street) {
|
||||
checkArgument(
|
||||
street == null || (!street.isEmpty() && street.size() <= 3),
|
||||
"Street address must have [1-3] lines: %s", street);
|
||||
getInstance().street = street;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> setCity(String city) {
|
||||
getInstance().city = city;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> setState(String state) {
|
||||
getInstance().state = state;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> setZip(String zip) {
|
||||
getInstance().zip = zip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> setCountryCode(String countryCode) {
|
||||
checkArgument(
|
||||
countryCode == null || countryCode.length() == 2,
|
||||
"Country code should be a 2 character string");
|
||||
getInstance().countryCode = countryCode;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
90
java/google/registry/model/eppcommon/AuthInfo.java
Normal file
90
java/google/registry/model/eppcommon/AuthInfo.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import com.google.domain.registry.model.EppResource;
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.NormalizedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* The "authInfoType" complex type.
|
||||
* <p>
|
||||
* RFCs 5731 and 5732 define this almost identically up to the namespace.
|
||||
*/
|
||||
@XmlTransient
|
||||
public abstract class AuthInfo extends ImmutableObject {
|
||||
|
||||
/**
|
||||
* Verify that the authorization info is valid for the given resource in the given tld.
|
||||
*
|
||||
* @throws BadAuthInfoException if this authorization info is invalid for this resource
|
||||
*/
|
||||
public abstract void verifyAuthorizedFor(EppResource eppResource) throws BadAuthInfoException;
|
||||
|
||||
protected PasswordAuth pw;
|
||||
|
||||
public PasswordAuth getPw() {
|
||||
return pw;
|
||||
}
|
||||
|
||||
/** The "pwAuthInfoType" complex type. */
|
||||
@Embed
|
||||
@XmlType(namespace = "urn:ietf:params:xml:ns:eppcom-1.0")
|
||||
public static class PasswordAuth extends ImmutableObject {
|
||||
@XmlValue
|
||||
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
|
||||
String value;
|
||||
|
||||
@XmlAttribute(name = "roid")
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
String repoId;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getRepoId() {
|
||||
return repoId;
|
||||
}
|
||||
|
||||
public static PasswordAuth create(String value, String repoId) {
|
||||
PasswordAuth instance = new PasswordAuth();
|
||||
instance.value = value;
|
||||
instance.repoId = repoId;
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static PasswordAuth create(String value) {
|
||||
return create(value, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the repoId for the contact this auth info is associated with. */
|
||||
protected String getRepoId() {
|
||||
return pw.getRepoId();
|
||||
}
|
||||
|
||||
/** Exception to throw when an auth info can't be verified. */
|
||||
public static class BadAuthInfoException extends Exception {}
|
||||
}
|
88
java/google/registry/model/eppcommon/PhoneNumber.java
Normal file
88
java/google/registry/model/eppcommon/PhoneNumber.java
Normal file
|
@ -0,0 +1,88 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.domain.registry.model.Buildable;
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* Container for generic E164 phone number.
|
||||
* <p>
|
||||
* This is the "e164" type from {@link "http://tools.ietf.org/html/rfc5733"}. It also matches the
|
||||
* "e164Type" type from {@link "http://tools.ietf.org/html/draft-lozano-tmch-smd"}.
|
||||
*
|
||||
* <blockquote><p>
|
||||
* "Contact telephone number structure is derived from structures defined in [ITU.E164.2005].
|
||||
* Telephone numbers described in this mapping are character strings that MUST begin with a plus
|
||||
* sign ("+", ASCII value 0x002B), followed by a country code defined in [ITU.E164.2005], followed
|
||||
* by a dot (".", ASCII value 0x002E), followed by a sequence of digits representing the telephone
|
||||
* number. An optional "x" attribute is provided to note telephone extension information."
|
||||
* </blockquote>
|
||||
*
|
||||
* @see com.google.domain.registry.model.contact.ContactPhoneNumber
|
||||
* @see com.google.domain.registry.model.mark.MarkPhoneNumber
|
||||
*/
|
||||
@XmlTransient
|
||||
public class PhoneNumber extends ImmutableObject {
|
||||
|
||||
@XmlValue
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
String phoneNumber;
|
||||
|
||||
@XmlAttribute(name = "x")
|
||||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
|
||||
String extension;
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public String toPhoneString() {
|
||||
return phoneNumber + (extension != null ? " x" + extension : "");
|
||||
}
|
||||
|
||||
/** A builder for constructing {@link PhoneNumber}. */
|
||||
@VisibleForTesting
|
||||
public static class Builder<T extends PhoneNumber> extends Buildable.Builder<T> {
|
||||
@Override
|
||||
public T build() {
|
||||
checkNotNull(getInstance().phoneNumber, "phoneNumber");
|
||||
return super.build();
|
||||
}
|
||||
|
||||
public Builder<T> setPhoneNumber(String phoneNumber) {
|
||||
getInstance().phoneNumber = phoneNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<T> setExtension(String extension) {
|
||||
getInstance().extension = extension;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
35
java/google/registry/model/eppcommon/PresenceMarker.java
Normal file
35
java/google/registry/model/eppcommon/PresenceMarker.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
/**
|
||||
* Used as the value of a tag that is present in the XML but has no children or value.
|
||||
* <p>
|
||||
* When placed in a field "foo", this will correctly unmarshal from both {@code <foo/>} and
|
||||
* {@code <foo></foo>}, and will unmarshal always to {@code <foo/>}.
|
||||
*/
|
||||
@Embed
|
||||
public class PresenceMarker extends ImmutableObject implements Serializable {
|
||||
@XmlTransient
|
||||
boolean marked = true;
|
||||
}
|
113
java/google/registry/model/eppcommon/ProtocolDefinition.java
Normal file
113
java/google/registry/model/eppcommon/ProtocolDefinition.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import static com.google.common.collect.Maps.uniqueIndex;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.domain.registry.model.domain.allocate.AllocateCreateExtension;
|
||||
import com.google.domain.registry.model.domain.fee.FeeCheckExtension;
|
||||
import com.google.domain.registry.model.domain.launch.LaunchCreateExtension;
|
||||
import com.google.domain.registry.model.domain.metadata.MetadataExtension;
|
||||
import com.google.domain.registry.model.domain.rgp.RgpUpdateExtension;
|
||||
import com.google.domain.registry.model.domain.secdns.SecDnsCreateExtension;
|
||||
import com.google.domain.registry.model.eppinput.EppInput.CommandExtension;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
|
||||
/** Constants that define the EPP protocol version we support. */
|
||||
public class ProtocolDefinition {
|
||||
public static final String VERSION = "1.0";
|
||||
|
||||
public static final String LANGUAGE = "en";
|
||||
|
||||
public static final Set<String> SUPPORTED_OBJECT_SERVICES = ImmutableSet.of(
|
||||
"urn:ietf:params:xml:ns:host-1.0",
|
||||
"urn:ietf:params:xml:ns:domain-1.0",
|
||||
"urn:ietf:params:xml:ns:contact-1.0");
|
||||
|
||||
/** Enums repesenting valid service extensions that are recognized by the server. */
|
||||
public enum ServiceExtension {
|
||||
LAUNCH_EXTENSION_1_0(LaunchCreateExtension.class, true),
|
||||
REDEMPTION_GRACE_PERIOD_1_0(RgpUpdateExtension.class, true),
|
||||
SECURE_DNS_1_1(SecDnsCreateExtension.class, true),
|
||||
FEE_0_6(FeeCheckExtension.class, true),
|
||||
ALLOCATE_1_0(AllocateCreateExtension.class, false),
|
||||
METADATA_1_0(MetadataExtension.class, false);
|
||||
|
||||
private String uri;
|
||||
private boolean visible;
|
||||
|
||||
ServiceExtension(Class<? extends CommandExtension> clazz, boolean visible) {
|
||||
this.uri = getCommandExtensionUri(clazz);
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public boolean getVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
/** Returns the namespace URI of the command extension class. */
|
||||
public static String getCommandExtensionUri(Class<? extends CommandExtension> clazz) {
|
||||
return clazz.getPackage().getAnnotation(XmlSchema.class).namespace();
|
||||
}
|
||||
}
|
||||
|
||||
/** Converts a service extension enum to its URI. */
|
||||
private static final Function<ServiceExtension, String> TO_URI_FUNCTION =
|
||||
new Function<ServiceExtension, String>() {
|
||||
@Override
|
||||
public String apply(ServiceExtension serviceExtension) {
|
||||
return serviceExtension.getUri();
|
||||
}};
|
||||
|
||||
/** This stores a map from URI back to the service extension enum. */
|
||||
private static final ImmutableMap<String, ServiceExtension> serviceExtensionByUri =
|
||||
uniqueIndex(EnumSet.allOf(ServiceExtension.class), TO_URI_FUNCTION);
|
||||
|
||||
/** Returns the service extension enum associated with a URI, or null if none are associated. */
|
||||
public static ServiceExtension getServiceExtensionFromUri(String uri) {
|
||||
return serviceExtensionByUri.get(uri);
|
||||
}
|
||||
|
||||
/** A set of all the visible extension URIs. */
|
||||
private static final ImmutableSet<String> visibleServiceExtensionUris =
|
||||
FluentIterable.from(EnumSet.allOf(ServiceExtension.class))
|
||||
.filter(
|
||||
new Predicate<ServiceExtension>() {
|
||||
@Override
|
||||
public boolean apply(ServiceExtension serviceExtension) {
|
||||
return serviceExtension.getVisible();
|
||||
}
|
||||
})
|
||||
.transform(TO_URI_FUNCTION)
|
||||
.toSet();
|
||||
|
||||
/** Return the set of all visible service extension URIs. */
|
||||
public static ImmutableSet<String> getVisibleServiceExtensionUris() {
|
||||
return visibleServiceExtensionUris;
|
||||
}
|
||||
}
|
78
java/google/registry/model/eppcommon/StatusValue.java
Normal file
78
java/google/registry/model/eppcommon/StatusValue.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static com.google.common.base.Strings.nullToEmpty;
|
||||
|
||||
import com.google.domain.registry.model.translators.EnumToAttributeAdapter.EppEnum;
|
||||
import com.google.domain.registry.model.translators.StatusValueAdapter;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* Represents an EPP status value for hosts, contacts, and domains, as defined in RFC 5731, 5732,
|
||||
* and 5733. The values here are the union of all 3 sets of status values.
|
||||
*
|
||||
* <p>The RFCs define extra optional metadata (language and message) that we don't use and therefore
|
||||
* don't model.
|
||||
*
|
||||
* <p>Note that {@code StatusValue.LINKED} should never be stored. Rather, it should be calculated
|
||||
* on the fly whenever needed using an eventually consistent query (i.e. in info flows).
|
||||
*
|
||||
* @see "https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en"
|
||||
*/
|
||||
@XmlJavaTypeAdapter(StatusValueAdapter.class)
|
||||
public enum StatusValue implements EppEnum {
|
||||
|
||||
CLIENT_DELETE_PROHIBITED,
|
||||
CLIENT_HOLD,
|
||||
CLIENT_RENEW_PROHIBITED,
|
||||
CLIENT_TRANSFER_PROHIBITED,
|
||||
CLIENT_UPDATE_PROHIBITED,
|
||||
INACTIVE,
|
||||
LINKED,
|
||||
OK,
|
||||
PENDING_CREATE,
|
||||
PENDING_DELETE,
|
||||
PENDING_TRANSFER,
|
||||
PENDING_UPDATE,
|
||||
SERVER_DELETE_PROHIBITED,
|
||||
SERVER_HOLD,
|
||||
SERVER_RENEW_PROHIBITED,
|
||||
SERVER_TRANSFER_PROHIBITED,
|
||||
SERVER_UPDATE_PROHIBITED;
|
||||
|
||||
private final String xmlName = UPPER_UNDERSCORE.to(LOWER_CAMEL, name());
|
||||
|
||||
@Override
|
||||
public String getXmlName() {
|
||||
return xmlName;
|
||||
}
|
||||
|
||||
public boolean isClientSettable() {
|
||||
// This is the actual definition of client-settable statuses; see RFC5730 section 2.3.
|
||||
return xmlName.startsWith("client");
|
||||
}
|
||||
|
||||
public boolean isChargedStatus() {
|
||||
return xmlName.startsWith("server") && xmlName.endsWith("Prohibited");
|
||||
}
|
||||
|
||||
public static StatusValue fromXmlName(String xmlName) {
|
||||
return StatusValue.valueOf(LOWER_CAMEL.to(UPPER_UNDERSCORE, nullToEmpty(xmlName)));
|
||||
}
|
||||
}
|
85
java/google/registry/model/eppcommon/Trid.java
Normal file
85
java/google/registry/model/eppcommon/Trid.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.eppcommon;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/**
|
||||
* "A {@code TRID} (transaction identifier) element containing the transaction identifier assigned
|
||||
* by the server to the command for which the response is being returned. The transaction identifier
|
||||
* is formed using the {@code clTRID} associated with the command if supplied by the client and a
|
||||
* {@code svTRID} (server transaction identifier) that is assigned by and unique to the server."
|
||||
*/
|
||||
@Embed
|
||||
@XmlType(propOrder = {"clientTransactionId", "serverTransactionId"})
|
||||
public class Trid extends ImmutableObject {
|
||||
|
||||
private static final String SERVER_ID = getServerId();
|
||||
private static final AtomicLong COUNTER = new AtomicLong();
|
||||
|
||||
/** Creates a unique id for this server instance, as a base64 encoded UUID. */
|
||||
private static String getServerId() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
ByteBuffer buffer = ByteBuffer.allocate(16);
|
||||
buffer.asLongBuffer()
|
||||
.put(0, uuid.getMostSignificantBits())
|
||||
.put(1, uuid.getLeastSignificantBits());
|
||||
return BaseEncoding.base64().encode(buffer.array());
|
||||
}
|
||||
|
||||
/** The server transaction id. */
|
||||
@XmlElement(name = "svTRID", namespace = "urn:ietf:params:xml:ns:epp-1.0")
|
||||
String serverTransactionId;
|
||||
|
||||
/** The client transaction id, if provided by the client, otherwise null. */
|
||||
@XmlElement(name = "clTRID", namespace = "urn:ietf:params:xml:ns:epp-1.0")
|
||||
String clientTransactionId;
|
||||
|
||||
public String getServerTransactionId() {
|
||||
return serverTransactionId;
|
||||
}
|
||||
|
||||
public String getClientTransactionId() {
|
||||
return clientTransactionId;
|
||||
}
|
||||
|
||||
public static Trid create(String clientTransactionId) {
|
||||
Trid instance = new Trid();
|
||||
instance.clientTransactionId = clientTransactionId;
|
||||
// The server id can be at most 64 characters. The SERVER_ID is at most 22 characters (128 bits
|
||||
// in base64), plus the dash. That leaves 41 characters, so we just append the counter in hex.
|
||||
instance.serverTransactionId = String.format("%s-%x", SERVER_ID, COUNTER.incrementAndGet());
|
||||
return instance;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static Trid create(String clientTransactionId, String serverTransactionId) {
|
||||
Trid instance = new Trid();
|
||||
instance.clientTransactionId = clientTransactionId;
|
||||
instance.serverTransactionId = serverTransactionId;
|
||||
return instance;
|
||||
}
|
||||
}
|
22
java/google/registry/model/eppcommon/package-info.java
Normal file
22
java/google/registry/model/eppcommon/package-info.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/**
|
||||
* Domain Registry datastore model common/shared classes.
|
||||
* <p>
|
||||
* This package is intended to hold classes which are shared across multiple XML namespaces. As
|
||||
* such, no default namespace is declared in this package, and all objects in this package should be
|
||||
* declared XmlTransient.
|
||||
*/
|
||||
package com.google.domain.registry.model.eppcommon;
|
Loading…
Add table
Add a link
Reference in a new issue