-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b74e196
commit 6367e8e
Showing
4 changed files
with
98 additions
and
77 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/Certificate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.roda.core.data.v2.jobs; | ||
|
||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.Objects; | ||
|
||
public class Certificate implements Serializable { | ||
@Serial | ||
private static final long serialVersionUID = -4981616458177975741L; | ||
private String issuerDN = null; | ||
private String subjectDN = null; | ||
private Date notBefore = null; | ||
private Date notAfter = null; | ||
|
||
public String getIssuerDN() { | ||
return issuerDN; | ||
} | ||
|
||
public void setIssuerDN(String issuerDN) { | ||
this.issuerDN = issuerDN; | ||
} | ||
|
||
public String getSubjectDN() { | ||
return subjectDN; | ||
} | ||
|
||
public void setSubjectDN(String subjectDN) { | ||
this.subjectDN = subjectDN; | ||
} | ||
|
||
public Date getNotBefore() { | ||
return notBefore; | ||
} | ||
|
||
public void setNotBefore(Date notBefore) { | ||
this.notBefore = notBefore; | ||
} | ||
|
||
public Date getNotAfter() { | ||
return notAfter; | ||
} | ||
|
||
public void setNotAfter(Date notAfter) { | ||
this.notAfter = notAfter; | ||
} | ||
|
||
public String getOrganizationName(String dn) { | ||
return getCertificateInfo(dn, "O"); | ||
} | ||
|
||
public String getCommonName(String dn) { | ||
return getCertificateInfo(dn, "CN"); | ||
} | ||
|
||
private String getCertificateInfo(String dn, String field) { | ||
for (String each : dn.split(",\\s")) { | ||
if (each.startsWith(field + "=")) { | ||
String result = each.substring(field.length() + 1); | ||
return result; | ||
} | ||
} | ||
return "NOT FOUND"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
Certificate that = (Certificate) o; | ||
return Objects.equals(issuerDN, that.issuerDN) && Objects.equals(subjectDN, that.subjectDN) | ||
&& Objects.equals(notBefore, that.notBefore) && Objects.equals(notAfter, that.notAfter); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(issuerDN, subjectDN, notBefore, notAfter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,24 @@ | |
*/ | ||
package org.roda.core.data.v2.jobs; | ||
|
||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author Gabriel Barros <[email protected]> | ||
*/ | ||
public class CertificateInfo implements Serializable { | ||
@Serial | ||
private static final long serialVersionUID = 5755199988566186742L; | ||
public enum CertificateStatus { | ||
INTERNAL, VERIFIED, NOT_VERIFIED | ||
} | ||
private CertificateStatus certificateStatus = CertificateStatus.INTERNAL; | ||
private HashSet<Certificate> certificates = new HashSet<>(); | ||
private Set<Certificate> certificates = new HashSet<>(); | ||
private boolean notVerified = false; | ||
|
||
public CertificateStatus getCertificateStatus() { | ||
return certificateStatus; | ||
|
@@ -31,10 +34,14 @@ public void setCertificateStatus(CertificateStatus status) { | |
certificateStatus = status; | ||
} | ||
|
||
public HashSet<Certificate> getCertificates() { | ||
public Set<Certificate> getCertificates() { | ||
return certificates; | ||
} | ||
|
||
public void setCertificates(Set<Certificate> certificates) { | ||
this.certificates = certificates; | ||
} | ||
|
||
public void addCertificates(String issuer, String subject, Date notBefore, Date notAfter) { | ||
Certificate certificate = new Certificate(); | ||
certificate.setIssuerDN(issuer); | ||
|
@@ -48,77 +55,8 @@ public boolean isNotVerified(){ | |
return getCertificateStatus().equals(CertificateStatus.NOT_VERIFIED); | ||
} | ||
|
||
public static class Certificate implements Serializable { | ||
private static final long serialVersionUID = -4981616458177975741L; | ||
private String issuerDN = null; | ||
private String subjectDN = null; | ||
private Date notBefore = null; | ||
private Date notAfter = null; | ||
|
||
public String getIssuerDN() { | ||
return issuerDN; | ||
} | ||
|
||
public void setIssuerDN(String issuerDN) { | ||
this.issuerDN = issuerDN; | ||
} | ||
|
||
public String getSubjectDN() { | ||
return subjectDN; | ||
} | ||
|
||
public void setSubjectDN(String subjectDN) { | ||
this.subjectDN = subjectDN; | ||
} | ||
|
||
public Date getNotBefore() { | ||
return notBefore; | ||
} | ||
|
||
public void setNotBefore(Date notBefore) { | ||
this.notBefore = notBefore; | ||
} | ||
|
||
public Date getNotAfter() { | ||
return notAfter; | ||
} | ||
|
||
public void setNotAfter(Date notAfter) { | ||
this.notAfter = notAfter; | ||
} | ||
|
||
public String getOrganizationName(String dn) { | ||
return getCertificateInfo(dn, "O"); | ||
} | ||
|
||
public String getCommonName(String dn) { | ||
return getCertificateInfo(dn, "CN"); | ||
} | ||
|
||
private String getCertificateInfo(String dn, String field) { | ||
for (String each : dn.split(",\\s")) { | ||
if (each.startsWith(field + "=")) { | ||
String result = each.substring(field.length() + 1); | ||
return result; | ||
} | ||
} | ||
return "NOT FOUND"; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
Certificate that = (Certificate) o; | ||
return Objects.equals(issuerDN, that.issuerDN) && Objects.equals(subjectDN, that.subjectDN) | ||
&& Objects.equals(notBefore, that.notBefore) && Objects.equals(notAfter, that.notAfter); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(issuerDN, subjectDN, notBefore, notAfter); | ||
} | ||
public void setNotVerified(boolean notVerified) { | ||
this.notVerified = notVerified; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters