Skip to content

Commit

Permalink
Add user consent to show his info
Browse files Browse the repository at this point in the history
  • Loading branch information
dhfelix committed Nov 20, 2019
1 parent 9e11e7f commit 8c4832f
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>mx.nic.labs.reddog</groupId>
<artifactId>rdap-core</artifactId>
<version>1.2.1</version>
<version>1.3.0</version>
<packaging>jar</packaging>

<name>mx.nic.labs.reddog:rdap-core</name>
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/mx/nic/rdap/core/db/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public class Entity extends RdapObject {
*/
private List<Autnum> autnums;

/**
* consent to publish its own contact information
*/
private UserConsent consent;

public Entity() {
publicIds = new ArrayList<>();
vCardList = new ArrayList<>();
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -167,4 +179,12 @@ public void setAutnums(List<Autnum> autnums) {
this.autnums = autnums;
}

public UserConsent getConsent() {
return consent;
}

public void setConsent(UserConsent consent) {
this.consent = consent;
}

}
6 changes: 6 additions & 0 deletions src/main/java/mx/nic/rdap/core/db/UserConsent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package mx.nic.rdap.core.db;

public interface UserConsent {

public boolean isHandleConsent();
}
293 changes: 293 additions & 0 deletions src/main/java/mx/nic/rdap/core/db/UserConsentByAttribute.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
Loading

0 comments on commit 8c4832f

Please sign in to comment.