From 8c4832f112e905dad69a407a9cbc95216ab71118 Mon Sep 17 00:00:00 2001 From: dhfelix Date: Wed, 20 Nov 2019 12:11:47 -0600 Subject: [PATCH] Add user consent to show his info --- pom.xml | 2 +- src/main/java/mx/nic/rdap/core/db/Entity.java | 20 ++ .../java/mx/nic/rdap/core/db/UserConsent.java | 6 + .../rdap/core/db/UserConsentByAttribute.java | 293 ++++++++++++++++++ .../nic/rdap/core/db/UserConsentGlobal.java | 44 +++ 5 files changed, 364 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mx/nic/rdap/core/db/UserConsent.java create mode 100644 src/main/java/mx/nic/rdap/core/db/UserConsentByAttribute.java create mode 100644 src/main/java/mx/nic/rdap/core/db/UserConsentGlobal.java diff --git a/pom.xml b/pom.xml index 49d2ac6..22751a9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ mx.nic.labs.reddog rdap-core - 1.2.1 + 1.3.0 jar mx.nic.labs.reddog:rdap-core diff --git a/src/main/java/mx/nic/rdap/core/db/Entity.java b/src/main/java/mx/nic/rdap/core/db/Entity.java index 103a898..1a38a40 100644 --- a/src/main/java/mx/nic/rdap/core/db/Entity.java +++ b/src/main/java/mx/nic/rdap/core/db/Entity.java @@ -42,6 +42,11 @@ public class Entity extends RdapObject { */ private List autnums; + /** + * consent to publish its own contact information + */ + private UserConsent consent; + public Entity() { publicIds = new ArrayList<>(); vCardList = new ArrayList<>(); @@ -71,6 +76,7 @@ public int hashCode() { result = prime * result + ((publicIds == null) ? 0 : publicIds.hashCode()); result = prime * result + ((roles == null) ? 0 : roles.hashCode()); result = prime * result + ((ipNetworks == null) ? 0 : ipNetworks.hashCode()); + result = prime * result + ((consent == null) ? 0 : consent.hashCode()); return result; } @@ -115,6 +121,12 @@ public boolean equals(Object obj) { return false; } else if (autnums.size() != other.autnums.size() || !autnums.containsAll(other.autnums)) return false; + if (consent == null) { + if (other.consent != null) + return false; + } else if (!consent.equals(other.consent)) + return false; + return true; } @@ -167,4 +179,12 @@ public void setAutnums(List autnums) { this.autnums = autnums; } + public UserConsent getConsent() { + return consent; + } + + public void setConsent(UserConsent consent) { + this.consent = consent; + } + } \ No newline at end of file diff --git a/src/main/java/mx/nic/rdap/core/db/UserConsent.java b/src/main/java/mx/nic/rdap/core/db/UserConsent.java new file mode 100644 index 0000000..f19ebf1 --- /dev/null +++ b/src/main/java/mx/nic/rdap/core/db/UserConsent.java @@ -0,0 +1,6 @@ +package mx.nic.rdap.core.db; + +public interface UserConsent { + + public boolean isHandleConsent(); +} diff --git a/src/main/java/mx/nic/rdap/core/db/UserConsentByAttribute.java b/src/main/java/mx/nic/rdap/core/db/UserConsentByAttribute.java new file mode 100644 index 0000000..3364b51 --- /dev/null +++ b/src/main/java/mx/nic/rdap/core/db/UserConsentByAttribute.java @@ -0,0 +1,293 @@ +package mx.nic.rdap.core.db; + +public class UserConsentByAttribute implements UserConsent{ + + private boolean handle; + + private boolean name; + + private boolean companyName; + + private boolean companyURL; + + private boolean email; + + private boolean voice; + + private boolean cellphone; + + private boolean fax; + + private boolean jobTitle; + + private boolean contactUri; + + private boolean type; + + private boolean country; + + private boolean countryCode; + + private boolean city; + + private boolean state; + + private boolean street1; + + private boolean street2; + + private boolean street3; + + private boolean postalCode; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (cellphone ? 1231 : 1237); + result = prime * result + (city ? 1231 : 1237); + result = prime * result + (companyName ? 1231 : 1237); + result = prime * result + (companyURL ? 1231 : 1237); + result = prime * result + (contactUri ? 1231 : 1237); + result = prime * result + (country ? 1231 : 1237); + result = prime * result + (countryCode ? 1231 : 1237); + result = prime * result + (email ? 1231 : 1237); + result = prime * result + (fax ? 1231 : 1237); + result = prime * result + (handle ? 1231 : 1237); + result = prime * result + (jobTitle ? 1231 : 1237); + result = prime * result + (name ? 1231 : 1237); + result = prime * result + (postalCode ? 1231 : 1237); + result = prime * result + (state ? 1231 : 1237); + result = prime * result + (street1 ? 1231 : 1237); + result = prime * result + (street2 ? 1231 : 1237); + result = prime * result + (street3 ? 1231 : 1237); + result = prime * result + (type ? 1231 : 1237); + result = prime * result + (voice ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UserConsentByAttribute other = (UserConsentByAttribute) obj; + if (cellphone != other.cellphone) + return false; + if (city != other.city) + return false; + if (companyName != other.companyName) + return false; + if (companyURL != other.companyURL) + return false; + if (contactUri != other.contactUri) + return false; + if (country != other.country) + return false; + if (countryCode != other.countryCode) + return false; + if (email != other.email) + return false; + if (fax != other.fax) + return false; + if (handle != other.handle) + return false; + if (jobTitle != other.jobTitle) + return false; + if (name != other.name) + return false; + if (postalCode != other.postalCode) + return false; + if (state != other.state) + return false; + if (street1 != other.street1) + return false; + if (street2 != other.street2) + return false; + if (street3 != other.street3) + return false; + if (type != other.type) + return false; + if (voice != other.voice) + return false; + return true; + } + + + + + @Override + public boolean isHandleConsent() { + return isHandle(); + } + + public void setHandle(boolean handle) { + this.handle = handle; + } + + public boolean isHandle() { + return handle; + } + + public void setName(boolean name) { + this.name = name; + } + + public boolean isName() { + return name; + } + + public void setCompanyName(boolean companyName) { + this.companyName = companyName; + } + + public boolean isCompanyName() { + return companyName; + } + + public void setCompanyURL(boolean companyURL) { + this.companyURL = companyURL; + } + + public boolean isCompanyURL() { + return companyURL; + } + + public boolean isEmail() { + return email; + } + + public void setEmail(boolean email) { + this.email = email; + } + + public boolean isVoice() { + return voice; + } + + public void setVoice(boolean voice) { + this.voice = voice; + } + + public boolean isCellphone() { + return cellphone; + } + + public void setCellphone(boolean cellphone) { + this.cellphone = cellphone; + } + + public boolean isFax() { + return fax; + } + + public void setFax(boolean fax) { + this.fax = fax; + } + + public boolean isJobTitle() { + return jobTitle; + } + + public void setJobTitle(boolean jobTitle) { + this.jobTitle = jobTitle; + } + + public boolean isContactUri() { + return contactUri; + } + + public void setContactUri(boolean contactUri) { + this.contactUri = contactUri; + } + + public boolean isType() { + return type; + } + + public void setType(boolean type) { + this.type = type; + } + + public boolean isCountry() { + return country; + } + + public void setCountry(boolean country) { + this.country = country; + } + + public boolean isCountryCode() { + return countryCode; + } + + public void setCountryCode(boolean countryCode) { + this.countryCode = countryCode; + } + + public boolean isCity() { + return city; + } + + public void setCity(boolean city) { + this.city = city; + } + + public boolean isState() { + return state; + } + + public void setState(boolean state) { + this.state = state; + } + + public boolean isStreet1() { + return street1; + } + + public void setStreet1(boolean street1) { + this.street1 = street1; + } + + public boolean isStreet2() { + return street2; + } + + public void setStreet2(boolean street2) { + this.street2 = street2; + } + + public boolean isStreet3() { + return street3; + } + + public void setStreet3(boolean street3) { + this.street3 = street3; + } + + public boolean isPostalCode() { + return postalCode; + } + + public void setPostalCode(boolean postalCode) { + this.postalCode = postalCode; + } + + public boolean isAllTrue() { + if (handle && name && companyName && companyURL && email && voice && cellphone && fax && jobTitle && contactUri + && type && country && countryCode && city && state && street1 && street2 && street3 && postalCode) + return true; + return false; + } + + public boolean isAllFalse() { + if (handle || name || companyName || companyURL || email || voice || cellphone || fax || jobTitle || contactUri + || type || country || countryCode || city || state || street1 || street2 || street3 || postalCode) + return false; + return true; + } + +} diff --git a/src/main/java/mx/nic/rdap/core/db/UserConsentGlobal.java b/src/main/java/mx/nic/rdap/core/db/UserConsentGlobal.java new file mode 100644 index 0000000..a043875 --- /dev/null +++ b/src/main/java/mx/nic/rdap/core/db/UserConsentGlobal.java @@ -0,0 +1,44 @@ +package mx.nic.rdap.core.db; + +public class UserConsentGlobal implements UserConsent{ + + private boolean globalConsent; + + public void setGlobalConsent(boolean globalConsent) { + this.globalConsent = globalConsent; + } + + public boolean isGlobalConsent() { + return globalConsent; + } + + @Override + public boolean isHandleConsent() { + return globalConsent; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (globalConsent ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UserConsentGlobal other = (UserConsentGlobal) obj; + if (globalConsent != other.globalConsent) + return false; + return true; + } + + + +}