diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/Certificate.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/Certificate.java index 2a726b93d1..5d0c1433cb 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/Certificate.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/Certificate.java @@ -6,76 +6,75 @@ 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; + @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 String getIssuerDN() { + return issuerDN; + } - public void setIssuerDN(String issuerDN) { - this.issuerDN = issuerDN; - } + public void setIssuerDN(String issuerDN) { + this.issuerDN = issuerDN; + } - public String getSubjectDN() { - return subjectDN; - } + public String getSubjectDN() { + return subjectDN; + } - public void setSubjectDN(String subjectDN) { - this.subjectDN = subjectDN; - } + public void setSubjectDN(String subjectDN) { + this.subjectDN = subjectDN; + } - public Date getNotBefore() { - return notBefore; - } + public Date getNotBefore() { + return notBefore; + } - public void setNotBefore(Date notBefore) { - this.notBefore = notBefore; - } + public void setNotBefore(Date notBefore) { + this.notBefore = notBefore; + } - public Date getNotAfter() { - return notAfter; - } + public Date getNotAfter() { + return notAfter; + } - public void setNotAfter(Date notAfter) { - this.notAfter = notAfter; - } + public void setNotAfter(Date notAfter) { + this.notAfter = notAfter; + } - public String getOrganizationName(String dn) { - return getCertificateInfo(dn, "O"); - } + public String getOrganizationName(String dn) { + return getCertificateInfo(dn, "O"); + } - public String getCommonName(String dn) { - return getCertificateInfo(dn, "CN"); - } + 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"; + private String getCertificateInfo(String dn, String field) { + for (String each : dn.split(",\\s")) { + if (each.startsWith(field + "=")) { + return each.substring(field.length() + 1); + } } + 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 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); - } + @Override + public int hashCode() { + return Objects.hash(issuerDN, subjectDN, notBefore, notAfter); + } } diff --git a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/CertificateInfo.java b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/CertificateInfo.java index 12d06e8ad9..350362077a 100644 --- a/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/CertificateInfo.java +++ b/roda-common/roda-common-data/src/main/java/org/roda/core/data/v2/jobs/CertificateInfo.java @@ -13,18 +13,21 @@ import java.util.HashSet; import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnore; + /** * @author Gabriel Barros */ 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 Set certificates = new HashSet<>(); - private boolean notVerified = false; public CertificateStatus getCertificateStatus() { return certificateStatus; @@ -42,6 +45,7 @@ public void setCertificates(Set certificates) { this.certificates = certificates; } + @JsonIgnore public void addCertificates(String issuer, String subject, Date notBefore, Date notAfter) { Certificate certificate = new Certificate(); certificate.setIssuerDN(issuer); @@ -51,12 +55,8 @@ public void addCertificates(String issuer, String subject, Date notBefore, Date this.certificates.add(certificate); } - public boolean isNotVerified(){ + @JsonIgnore + public boolean isNotVerified() { return getCertificateStatus().equals(CertificateStatus.NOT_VERIFIED); } - - public void setNotVerified(boolean notVerified) { - this.notVerified = notVerified; - } - } diff --git a/roda-core/roda-core/src/main/java/org/roda/core/plugins/PluginManager.java b/roda-core/roda-core/src/main/java/org/roda/core/plugins/PluginManager.java index d133888c99..5654715970 100644 --- a/roda-core/roda-core/src/main/java/org/roda/core/plugins/PluginManager.java +++ b/roda-core/roda-core/src/main/java/org/roda/core/plugins/PluginManager.java @@ -412,7 +412,9 @@ public PluginInfoList getPluginsInfo(List pluginTypes) { PluginInfoList pluginsInfo = new PluginInfoList(); for (PluginType pluginType : pluginTypes) { - pluginsInfo.addObjects(pluginInfoPerType.getOrDefault(pluginType, Collections.emptyList())); + List orDefault = pluginInfoPerType.getOrDefault(pluginType, Collections.emptyList()); + orDefault.removeIf(p -> p.getCategories().contains(RodaConstants.PLUGIN_CATEGORY_NOT_LISTABLE)); + pluginsInfo.addObjects(orDefault); } return pluginsInfo; @@ -767,7 +769,7 @@ private void addStartupPluginJars(Path jarPath, Attributes mainAttributes, List< boolean optIn = configurationManager.getProperty(RodaConstants.PLUGINS_CERTIFICATE_OPT_IN_PROPERTY, false); CertificateInfo certificateInfo = PluginCertificateUtils.loadAndCheckCertificates(jarPath); if (!certificateInfo.isNotVerified() || optIn) { - LOGGER.info("Adding startup jars from auth plugin " + authPluginClassNamesString); + LOGGER.info("Adding startup jars from auth plugin {}", authPluginClassNamesString); URLClassLoader classLoader = new URLClassLoader(jarClasspath.toArray(new URL[] {}), getClass().getClassLoader()); jarStartupPluginsClassloaderCache.put(authPluginClassNamesString, classLoader); diff --git a/roda-core/roda-core/src/main/resources/config/roda-core.properties b/roda-core/roda-core/src/main/resources/config/roda-core.properties index cedf7f81e3..885743ca99 100644 --- a/roda-core/roda-core/src/main/resources/config/roda-core.properties +++ b/roda-core/roda-core/src/main/resources/config/roda-core.properties @@ -596,7 +596,7 @@ core.user_registration.disabled = false # Plugins certificates setting # ########################################################################## -core.plugins.external.certificates.opt-in = true +# core.plugins.external.certificates.opt-in = false # core.plugins.external.certificates.custom.truststore.enable = false # core.plugins.external.certificates.custom.truststore.type = PKCS12 # core.plugins.external.certificates.custom.truststore.name = custom-truststore.p12