This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch 2_1_X in repository https://gitbox.apache.org/repos/asf/syncope.git
commit 7619c6d690792e3a141cf3bc7140b723314f0dcf Author: Francesco Chicchiriccò <[email protected]> AuthorDate: Mon May 25 16:25:03 2020 +0200 [SYNCOPE-1565] Fix JAXB --- .../apache/syncope/client/console/pages/Audit.java | 28 +-- .../console/panels/SchemaTypeWizardBuilder.java | 8 +- .../syncope/common/lib/info/PlatformInfo.java | 184 ++++++++++++++++- .../apache/syncope/common/lib/info/SystemInfo.java | 1 - .../apache/syncope/common/lib/log/LogAppender.java | 4 + .../org/apache/syncope/common/lib/to/SchemaTO.java | 30 ++- .../syncope/common/lib/types/AuditLoggerName.java | 226 ++++++++++++--------- .../org/apache/syncope/common/lib/JAXBTest.java | 32 +++ .../apache/syncope/core/logic/SyncopeLogic.java | 20 +- .../provisioning/java/DefaultAuditManager.java | 9 +- .../java/data/SchemaDataBinderImpl.java | 8 +- .../rest/cxf/service/RemediationServiceImpl.java | 1 - .../common/lib/types/BpmnProcessFormat.java | 15 +- .../core/flowable/impl/FlowableRuntimeUtils.java | 19 +- .../rest/cxf/service/BpmnProcessServiceImpl.java | 3 +- .../apache/syncope/common/lib/scim/SCIMConf.java | 1 - .../syncope/common/lib/scim/SCIMGeneralConf.java | 1 - .../syncope/common/lib/scim/SCIMUserConf.java | 1 - .../syncope/common/lib/scim/SCIMUserNameConf.java | 5 +- .../core/reference/SyslogRewriteAuditAppender.java | 33 ++- .../fit/core/reference/TestFileAuditAppender.java | 22 +- .../reference/TestFileRewriteAuditAppender.java | 11 +- .../syncope/fit/core/AuthenticationITCase.java | 3 + .../apache/syncope/fit/core/DerSchemaITCase.java | 5 +- .../org/apache/syncope/fit/core/LoggerITCase.java | 81 ++++---- .../apache/syncope/fit/core/PlainSchemaITCase.java | 7 +- .../apache/syncope/fit/core/PullTaskITCase.java | 4 + .../org/apache/syncope/fit/core/ReportITCase.java | 11 +- .../org/apache/syncope/fit/core/SCIMITCase.java | 2 + .../apache/syncope/fit/core/UserRequestITCase.java | 4 +- .../apache/syncope/fit/core/UserSelfITCase.java | 9 + .../apache/syncope/fit/core/VirSchemaITCase.java | 3 +- 32 files changed, 541 insertions(+), 250 deletions(-) diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/Audit.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/Audit.java index 272842c..7a01e56 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/Audit.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/Audit.java @@ -92,13 +92,13 @@ public class Audit extends BasePage { Pair<EventCategory, AuditElements.Result> eventCategory = AuditLoggerName.parseEventCategory(toBeRemoved); - AuditLoggerName auditLoggerName = new AuditLoggerName( - eventCategory.getKey().getType(), - eventCategory.getKey().getCategory(), - eventCategory.getKey().getSubcategory(), - CollectionUtils.isEmpty(eventCategory.getKey().getEvents()) - ? null : eventCategory.getKey().getEvents().iterator().next(), - eventCategory.getValue()); + AuditLoggerName auditLoggerName = new AuditLoggerName.Builder(). + type(eventCategory.getKey().getType()). + category(eventCategory.getKey().getCategory()). + subcategory(eventCategory.getKey().getSubcategory()). + event(CollectionUtils.isEmpty(eventCategory.getKey().getEvents()) + ? null : eventCategory.getKey().getEvents().iterator().next()). + result(eventCategory.getValue()).build(); loggerRestClient.disableAudit(auditLoggerName); }); @@ -107,13 +107,13 @@ public class Audit extends BasePage { Pair<EventCategory, AuditElements.Result> eventCategory = AuditLoggerName.parseEventCategory(toBeAdded); - AuditLoggerName auditLoggerName = new AuditLoggerName( - eventCategory.getKey().getType(), - eventCategory.getKey().getCategory(), - eventCategory.getKey().getSubcategory(), - CollectionUtils.isEmpty(eventCategory.getKey().getEvents()) - ? null : eventCategory.getKey().getEvents().iterator().next(), - eventCategory.getValue()); + AuditLoggerName auditLoggerName = new AuditLoggerName.Builder(). + type(eventCategory.getKey().getType()). + category(eventCategory.getKey().getCategory()). + subcategory(eventCategory.getKey().getSubcategory()). + event(CollectionUtils.isEmpty(eventCategory.getKey().getEvents()) + ? null : eventCategory.getKey().getEvents().iterator().next()). + result(eventCategory.getValue()).build(); loggerRestClient.enableAudit(auditLoggerName); }); diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/SchemaTypeWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/SchemaTypeWizardBuilder.java index 099cb25..72f4a18 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/SchemaTypeWizardBuilder.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/SchemaTypeWizardBuilder.java @@ -74,9 +74,9 @@ public class SchemaTypeWizardBuilder extends AjaxWizardBuilder<SchemaTO> { modelObject.getLabels().clear(); modelObject.getLabels().putAll(translations.getObject().stream(). filter(Objects::nonNull). - filter(translation -> translation.getKey() != null). - filter(translation -> translation.getValue() != null). - collect(Collectors.toMap(MutablePair::getKey, MutablePair::getValue))); + filter(translation -> translation.getLeft() != null). + filter(translation -> translation.getRight() != null). + collect(Collectors.toMap(pair -> SchemaTO.toString(pair.getLeft()), MutablePair::getRight))); if (getOriginalItem() == null || StringUtils.isBlank(getOriginalItem().getKey())) { restClient.create(schemaType, modelObject); @@ -136,7 +136,7 @@ public class SchemaTypeWizardBuilder extends AjaxWizardBuilder<SchemaTO> { translations.getObject().clear(); modelObject.getLabels().forEach((locale, display) -> { - translations.getObject().add(MutablePair.of(locale, display)); + translations.getObject().add(MutablePair.of(SchemaTO.toLocale(locale), display)); }); ListView<MutablePair<Locale, String>> labels = diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java b/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java index 5e585b9..bc3cfe8 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/info/PlatformInfo.java @@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.syncope.common.lib.types.ImplementationType; @XmlRootElement(name = "platformInfo") @@ -40,7 +42,7 @@ public class PlatformInfo implements Serializable { @XmlRootElement(name = "provisioningInfo") @XmlType - public class ProvisioningInfo implements Serializable { + public static class ProvisioningInfo implements Serializable { private static final long serialVersionUID = 533340357732839568L; @@ -113,11 +115,47 @@ public class PlatformInfo implements Serializable { public void setAuditManager(final String auditManager) { this.auditManager = auditManager; } + + @Override + public int hashCode() { + return new HashCodeBuilder(). + append(propagationTaskExecutor). + append(virAttrCache). + append(anyObjectProvisioningManager). + append(userProvisioningManager). + append(groupProvisioningManager). + append(notificationManager). + append(auditManager). + build(); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProvisioningInfo other = (ProvisioningInfo) obj; + return new EqualsBuilder(). + append(propagationTaskExecutor, other.propagationTaskExecutor). + append(virAttrCache, other.virAttrCache). + append(anyObjectProvisioningManager, other.anyObjectProvisioningManager). + append(userProvisioningManager, other.userProvisioningManager). + append(groupProvisioningManager, other.groupProvisioningManager). + append(notificationManager, other.notificationManager). + append(auditManager, other.auditManager). + build(); + } } @XmlRootElement(name = "workflowInfo") @XmlType - public class WorkflowInfo implements Serializable { + public static class WorkflowInfo implements Serializable { private static final long serialVersionUID = 6736937721099195324L; @@ -150,11 +188,39 @@ public class PlatformInfo implements Serializable { public void setGroupWorkflowAdapter(final String groupWorkflowAdapter) { this.groupWorkflowAdapter = groupWorkflowAdapter; } + + @Override + public int hashCode() { + return new HashCodeBuilder(). + append(anyObjectWorkflowAdapter). + append(userWorkflowAdapter). + append(groupWorkflowAdapter). + build(); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final WorkflowInfo other = (WorkflowInfo) obj; + return new EqualsBuilder(). + append(anyObjectWorkflowAdapter, other.anyObjectWorkflowAdapter). + append(userWorkflowAdapter, other.userWorkflowAdapter). + append(groupWorkflowAdapter, other.groupWorkflowAdapter). + build(); + } } @XmlRootElement(name = "persistenceInfo") @XmlType - public class PersistenceInfo implements Serializable { + public static class PersistenceInfo implements Serializable { private static final long serialVersionUID = 2902980556801069487L; @@ -247,17 +313,57 @@ public class PlatformInfo implements Serializable { public void setConfDAO(final String confDAO) { this.confDAO = confDAO; } + + @Override + public int hashCode() { + return new HashCodeBuilder(). + append(entityFactory). + append(plainSchemaDAO). + append(plainAttrDAO). + append(plainAttrValueDAO). + append(anySearchDAO). + append(userDAO). + append(groupDAO). + append(anyObjectDAO). + append(confDAO). + build(); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersistenceInfo other = (PersistenceInfo) obj; + return new EqualsBuilder(). + append(entityFactory, other.entityFactory). + append(plainSchemaDAO, other.plainSchemaDAO). + append(plainAttrDAO, other.plainAttrDAO). + append(plainAttrValueDAO, other.plainAttrValueDAO). + append(anySearchDAO, other.anySearchDAO). + append(userDAO, other.userDAO). + append(groupDAO, other.groupDAO). + append(anyObjectDAO, other.anyObjectDAO). + append(confDAO, other.confDAO). + build(); + } } private String version; private String buildNumber; - private final ProvisioningInfo provisioningInfo = new ProvisioningInfo(); + private ProvisioningInfo provisioningInfo; - private final WorkflowInfo workflowInfo = new WorkflowInfo(); + private WorkflowInfo workflowInfo; - private final PersistenceInfo persistenceInfo = new PersistenceInfo(); + private PersistenceInfo persistenceInfo; private boolean selfRegAllowed; @@ -293,14 +399,26 @@ public class PlatformInfo implements Serializable { return provisioningInfo; } + public void setProvisioningInfo(final ProvisioningInfo provisioningInfo) { + this.provisioningInfo = provisioningInfo; + } + public WorkflowInfo getWorkflowInfo() { return workflowInfo; } + public void setWorkflowInfo(final WorkflowInfo workflowInfo) { + this.workflowInfo = workflowInfo; + } + public PersistenceInfo getPersistenceInfo() { return persistenceInfo; } + public void setPersistenceInfo(final PersistenceInfo persistenceInfo) { + this.persistenceInfo = persistenceInfo; + } + public boolean isSelfRegAllowed() { return selfRegAllowed; } @@ -394,4 +512,58 @@ public class PlatformInfo implements Serializable { public void setPwdResetRequiringSecurityQuestions(final boolean pwdResetRequiringSecurityQuestions) { this.pwdResetRequiringSecurityQuestions = pwdResetRequiringSecurityQuestions; } + + @Override + public int hashCode() { + return new HashCodeBuilder(). + append(version). + append(buildNumber). + append(provisioningInfo). + append(workflowInfo). + append(persistenceInfo). + append(selfRegAllowed). + append(pwdResetAllowed). + append(pwdResetRequiringSecurityQuestions). + append(connIdLocations). + append(passwordGenerator). + append(anyTypes). + append(userClasses). + append(anyTypeClasses). + append(resources). + append(entitlements). + append(javaImplInfos). + build(); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PlatformInfo other = (PlatformInfo) obj; + return new EqualsBuilder(). + append(version, other.version). + append(buildNumber, other.buildNumber). + append(provisioningInfo, other.provisioningInfo). + append(workflowInfo, other.workflowInfo). + append(persistenceInfo, other.persistenceInfo). + append(selfRegAllowed, other.selfRegAllowed). + append(pwdResetAllowed, other.pwdResetAllowed). + append(pwdResetRequiringSecurityQuestions, other.pwdResetRequiringSecurityQuestions). + append(connIdLocations, other.connIdLocations). + append(passwordGenerator, other.passwordGenerator). + append(anyTypes, other.anyTypes). + append(userClasses, other.userClasses). + append(anyTypeClasses, other.anyTypeClasses). + append(resources, other.resources). + append(entitlements, other.entitlements). + append(javaImplInfos, other.javaImplInfos). + build(); + } } diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java b/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java index 5d12ad1..5bc110a 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/info/SystemInfo.java @@ -148,5 +148,4 @@ public class SystemInfo implements Serializable { this.maxMemory = maxMemory; } } - } diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/log/LogAppender.java b/common/lib/src/main/java/org/apache/syncope/common/lib/log/LogAppender.java index 85c3d28..99c99b2 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/log/LogAppender.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/log/LogAppender.java @@ -19,7 +19,11 @@ package org.apache.syncope.common.lib.log; import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +@XmlRootElement(name = "logAppender") +@XmlType public class LogAppender implements Serializable { private static final long serialVersionUID = 5975199884460548302L; diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchemaTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchemaTO.java index 2d5f752..5ef7a81 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchemaTO.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/SchemaTO.java @@ -46,6 +46,30 @@ public abstract class SchemaTO implements EntityTO { private static final long serialVersionUID = 4088388951694301759L; + public static Locale toLocale(final String string) { + String[] splitted = string.split(";"); + + String language = ""; + String country = ""; + String variant = ""; + + if (splitted.length > 0) { + language = splitted[0]; + } + if (splitted.length > 1) { + country = splitted[1]; + } + if (splitted.length >= 2) { + country = splitted[2]; + } + + return new Locale(language, country, variant); + } + + public static String toString(final Locale locale) { + return locale.getLanguage() + ";" + locale.getCountry() + ";" + locale.getVariant(); + } + @XmlTransient @JsonProperty("@class") private String discriminator; @@ -55,7 +79,7 @@ public abstract class SchemaTO implements EntityTO { private String anyTypeClass; @XmlJavaTypeAdapter(XmlGenericMapAdapter.class) - private final Map<Locale, String> labels = new HashMap<>(); + private final Map<String, String> labels = new HashMap<>(); @Schema(name = "@class", required = true) public abstract String getDiscriminator(); @@ -85,11 +109,11 @@ public abstract class SchemaTO implements EntityTO { @JsonIgnore public String getLabel(final Locale locale) { - return labels.getOrDefault(locale, key); + return labels.getOrDefault(toString(locale), key); } @JsonProperty - public Map<Locale, String> getLabels() { + public Map<String, String> getLabels() { return labels; } diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/AuditLoggerName.java b/common/lib/src/main/java/org/apache/syncope/common/lib/types/AuditLoggerName.java index a8d6f2a..d524ddb 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/AuditLoggerName.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/AuditLoggerName.java @@ -18,11 +18,11 @@ */ package org.apache.syncope.common.lib.types; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.text.ParseException; import java.util.Map; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -31,6 +31,8 @@ import org.apache.syncope.common.lib.log.EventCategory; import org.apache.syncope.common.lib.types.AuditElements.EventCategoryType; import org.apache.syncope.common.lib.types.AuditElements.Result; +@XmlRootElement(name = "auditLoggerName") +@XmlType public class AuditLoggerName implements Serializable { private static final long serialVersionUID = -647989486671786839L; @@ -43,90 +45,6 @@ public class AuditLoggerName implements Serializable { return domain + "." + loggerName; } - private final EventCategoryType type; - - private final String category; - - private final String subcategory; - - private final String event; - - private final Result result; - - @JsonCreator - public AuditLoggerName( - @JsonProperty("type") final AuditElements.EventCategoryType type, - @JsonProperty("category") final String category, - @JsonProperty("subcategory") final String subcategory, - @JsonProperty("event") final String event, - @JsonProperty("result") final Result result) { - - super(); - - this.type = type == null ? AuditElements.EventCategoryType.CUSTOM : type; - this.category = category; - this.subcategory = subcategory; - this.event = event; - this.result = result == null ? Result.SUCCESS : result; - } - - public AuditElements.EventCategoryType getType() { - return type; - } - - public String getEvent() { - return event; - } - - public String getCategory() { - return category; - } - - public Result getResult() { - return result; - } - - public String getSubcategory() { - return subcategory; - } - - public String toLoggerName() { - return new StringBuilder().append(LoggerType.AUDIT.getPrefix()).append('.'). - append(buildEvent(type, category, subcategory, event, result)).toString(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(). - append(type). - append(category). - append(subcategory). - append(event). - append(result). - build(); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final AuditLoggerName other = (AuditLoggerName) obj; - return new EqualsBuilder(). - append(type, other.type). - append(category, other.category). - append(subcategory, other.subcategory). - append(event, other.event). - append(result, other.result). - build(); - } - public static AuditLoggerName fromLoggerName(final String loggerName) throws ParseException { @@ -141,13 +59,14 @@ public class AuditLoggerName implements Serializable { Map.Entry<EventCategory, Result> eventCategory = parseEventCategory( loggerName.replaceAll(LoggerType.AUDIT.getPrefix() + ".", "")); - return new AuditLoggerName( - eventCategory.getKey().getType(), - eventCategory.getKey().getCategory(), - eventCategory.getKey().getSubcategory(), - eventCategory.getKey().getEvents().isEmpty() - ? StringUtils.EMPTY : eventCategory.getKey().getEvents().iterator().next(), - eventCategory.getValue()); + return new AuditLoggerName.Builder(). + type(eventCategory.getKey().getType()). + category(eventCategory.getKey().getCategory()). + subcategory(eventCategory.getKey().getSubcategory()). + event(eventCategory.getKey().getEvents().isEmpty() + ? StringUtils.EMPTY : eventCategory.getKey().getEvents().iterator().next()). + result(eventCategory.getValue()). + build(); } public static Pair<EventCategory, Result> parseEventCategory(final String event) { @@ -243,4 +162,125 @@ public class AuditLoggerName implements Serializable { return eventBuilder.toString(); } + + public static class Builder { + + private final AuditLoggerName instance = new AuditLoggerName(); + + public Builder type(final AuditElements.EventCategoryType type) { + instance.type = type; + return this; + } + + public Builder category(final String category) { + instance.category = category; + return this; + } + + public Builder subcategory(final String subcategory) { + instance.subcategory = subcategory; + return this; + } + + public Builder event(final String event) { + instance.event = event; + return this; + } + + public Builder result(final Result result) { + instance.result = result; + return this; + } + + public AuditLoggerName build() { + return instance; + } + } + + private EventCategoryType type = AuditElements.EventCategoryType.CUSTOM; + + private String category; + + private String subcategory; + + private String event; + + private Result result = Result.SUCCESS; + + public EventCategoryType getType() { + return type; + } + + public void setType(final EventCategoryType type) { + this.type = type; + } + + public String getCategory() { + return category; + } + + public void setCategory(final String category) { + this.category = category; + } + + public String getSubcategory() { + return subcategory; + } + + public void setSubcategory(final String subcategory) { + this.subcategory = subcategory; + } + + public String getEvent() { + return event; + } + + public void setEvent(final String event) { + this.event = event; + } + + public Result getResult() { + return result; + } + + public void setResult(final Result result) { + this.result = result; + } + + public String toLoggerName() { + return new StringBuilder().append(LoggerType.AUDIT.getPrefix()).append('.'). + append(buildEvent(type, category, subcategory, event, result)).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(). + append(type). + append(category). + append(subcategory). + append(event). + append(result). + build(); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AuditLoggerName other = (AuditLoggerName) obj; + return new EqualsBuilder(). + append(type, other.type). + append(category, other.category). + append(subcategory, other.subcategory). + append(event, other.event). + append(result, other.result). + build(); + } } diff --git a/common/lib/src/test/java/org/apache/syncope/common/lib/JAXBTest.java b/common/lib/src/test/java/org/apache/syncope/common/lib/JAXBTest.java index d1a78bd..45d7851 100644 --- a/common/lib/src/test/java/org/apache/syncope/common/lib/JAXBTest.java +++ b/common/lib/src/test/java/org/apache/syncope/common/lib/JAXBTest.java @@ -33,6 +33,7 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.syncope.common.lib.info.NumbersInfo; +import org.apache.syncope.common.lib.info.PlatformInfo; import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.common.lib.report.UserReportletConf; import org.apache.syncope.common.lib.to.AttrTO; @@ -124,6 +125,37 @@ public class JAXBTest { } @Test + public void platformInfo() throws JAXBException { + JAXBContext context = JAXBContext.newInstance(PlatformInfo.class); + Marshaller marshaller = context.createMarshaller(); + Unmarshaller unmarshaller = context.createUnmarshaller(); + + PlatformInfo original = new PlatformInfo(); + original.setBuildNumber(UUID.randomUUID().toString()); + original.setVersion(UUID.randomUUID().toString()); + original.setPasswordGenerator("PasswordGenerator"); + original.setPwdResetAllowed(true); + original.setPwdResetRequiringSecurityQuestions(true); + original.setSelfRegAllowed(true); + original.getAnyTypeClasses().add("Type1"); + + original.setProvisioningInfo(new PlatformInfo.ProvisioningInfo()); + original.getProvisioningInfo().setUserProvisioningManager("Default"); + + original.setWorkflowInfo(new PlatformInfo.WorkflowInfo()); + original.getWorkflowInfo().setUserWorkflowAdapter("Default"); + + original.setPersistenceInfo(new PlatformInfo.PersistenceInfo()); + original.getPersistenceInfo().setConfDAO("Default"); + + StringWriter writer = new StringWriter(); + marshaller.marshal(original, writer); + + Object actual = unmarshaller.unmarshal(new StringReader(writer.toString())); + assertEquals(original, actual); + } + + @Test public void issueSYNCOPE1541() throws JAXBException { JAXBContext context = JAXBContext.newInstance(ExecTO.class); Marshaller marshaller = context.createMarshaller(); diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java index 68769f2..54d4dc5 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/SyncopeLogic.java @@ -255,6 +255,7 @@ public class SyncopeLogic extends AbstractLogic<EntityTO> { map(URI::toASCIIString).collect(Collectors.toList())); } + PLATFORM_INFO.setWorkflowInfo(new PlatformInfo.WorkflowInfo()); PLATFORM_INFO.getWorkflowInfo(). setAnyObjectWorkflowAdapter(AopUtils.getTargetClass(awfAdapter).getName()); PLATFORM_INFO.getWorkflowInfo(). @@ -262,6 +263,7 @@ public class SyncopeLogic extends AbstractLogic<EntityTO> { PLATFORM_INFO.getWorkflowInfo(). setGroupWorkflowAdapter(AopUtils.getTargetClass(gwfAdapter).getName()); + PLATFORM_INFO.setProvisioningInfo(new PlatformInfo.ProvisioningInfo()); PLATFORM_INFO.getProvisioningInfo(). setAnyObjectProvisioningManager(AopUtils.getTargetClass(aProvisioningManager).getName()); PLATFORM_INFO.getProvisioningInfo(). @@ -277,8 +279,7 @@ public class SyncopeLogic extends AbstractLogic<EntityTO> { PLATFORM_INFO.getProvisioningInfo(). setAuditManager(AopUtils.getTargetClass(auditManager).getName()); - PLATFORM_INFO.setPasswordGenerator(AopUtils.getTargetClass(passwordGenerator).getName()); - + PLATFORM_INFO.setPersistenceInfo(new PlatformInfo.PersistenceInfo()); PLATFORM_INFO.getPersistenceInfo(). setEntityFactory(AopUtils.getTargetClass(entityFactory).getName()); PLATFORM_INFO.getPersistenceInfo(). @@ -298,14 +299,15 @@ public class SyncopeLogic extends AbstractLogic<EntityTO> { PLATFORM_INFO.getPersistenceInfo(). setConfDAO(AopUtils.getTargetClass(confDAO).getName()); - Arrays.stream(ImplementationType.values()). - forEach(type -> { - JavaImplInfo javaImplInfo = new JavaImplInfo(); - javaImplInfo.setType(type); - javaImplInfo.getClasses().addAll(implLookup.getClassNames(type)); + PLATFORM_INFO.setPasswordGenerator(AopUtils.getTargetClass(passwordGenerator).getName()); + + Arrays.stream(ImplementationType.values()).forEach(type -> { + JavaImplInfo javaImplInfo = new JavaImplInfo(); + javaImplInfo.setType(type); + javaImplInfo.getClasses().addAll(implLookup.getClassNames(type)); - PLATFORM_INFO.getJavaImplInfos().add(javaImplInfo); - }); + PLATFORM_INFO.getJavaImplInfos().add(javaImplInfo); + }); } PLATFORM_INFO.setSelfRegAllowed(isSelfRegAllowed()); diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultAuditManager.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultAuditManager.java index ff27cbf..ed04ab9 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultAuditManager.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultAuditManager.java @@ -80,7 +80,8 @@ public class DefaultAuditManager implements AuditManager { AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(who); - auditEntry.setLogger(new AuditLoggerName(type, category, subcategory, event, Result.SUCCESS)); + auditEntry.setLogger(new AuditLoggerName.Builder(). + type(type).category(category).subcategory(subcategory).event(event).result(Result.SUCCESS).build()); auditEntry.setDate(new Date()); org.apache.syncope.core.persistence.api.entity.Logger syncopeLogger = @@ -91,7 +92,8 @@ public class DefaultAuditManager implements AuditManager { return true; } - auditEntry.setLogger(new AuditLoggerName(type, category, subcategory, event, Result.FAILURE)); + auditEntry.setLogger(new AuditLoggerName.Builder(). + type(type).category(category).subcategory(subcategory).event(event).result(Result.FAILURE).build()); syncopeLogger = loggerDAO.find(auditEntry.getLogger().toLoggerName()); auditRequested = syncopeLogger != null && syncopeLogger.getLevel() == LoggerLevel.DEBUG; @@ -134,7 +136,8 @@ public class DefaultAuditManager implements AuditManager { AuditEntry auditEntry = new AuditEntry(); auditEntry.setWho(who); - auditEntry.setLogger(new AuditLoggerName(type, category, subcategory, event, condition)); + auditEntry.setLogger(new AuditLoggerName.Builder(). + type(type).category(category).subcategory(subcategory).event(event).result(condition).build()); auditEntry.setDate(new Date()); auditEntry.setBefore(POJOHelper.serialize((maskSensitive(before)))); if (throwable == null) { diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java index 21f5818..e1c742c 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/SchemaDataBinderImpl.java @@ -90,22 +90,22 @@ public class SchemaDataBinderImpl implements SchemaDataBinder { private <S extends Schema, T extends SchemaTO> void labels(final T src, final S dst) { src.getLabels().forEach((locale, display) -> { - SchemaLabel label = dst.getLabel(locale).orElse(null); + SchemaLabel label = dst.getLabel(SchemaTO.toLocale(locale)).orElse(null); if (label == null) { label = entityFactory.newEntity(SchemaLabel.class); - label.setLocale(locale); + label.setLocale(SchemaTO.toLocale(locale)); label.setSchema(dst); dst.add(label); } label.setDisplay(display); }); - dst.getLabels().removeIf(label -> !src.getLabels().containsKey(label.getLocale())); + dst.getLabels().removeIf(label -> !src.getLabels().containsKey(SchemaTO.toString(label.getLocale()))); } private <S extends Schema, T extends SchemaTO> void labels(final S src, final T dst) { dst.getLabels().putAll(src.getLabels().stream(). - collect(Collectors.toMap(SchemaLabel::getLocale, SchemaLabel::getDisplay))); + collect(Collectors.toMap(label -> SchemaTO.toString(label.getLocale()), SchemaLabel::getDisplay))); } // --------------- PLAIN ----------------- diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RemediationServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RemediationServiceImpl.java index d4a402d..b6ba6e6 100644 --- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RemediationServiceImpl.java +++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RemediationServiceImpl.java @@ -116,5 +116,4 @@ public class RemediationServiceImpl extends AbstractServiceImpl implements Remed ProvisioningResult<?> deleted = logic.remedy(remediationKey, anyKey, isNullPriorityAsync()); return modificationResponse(deleted); } - } diff --git a/ext/flowable/common-lib/src/main/java/org/apache/syncope/common/lib/types/BpmnProcessFormat.java b/ext/flowable/common-lib/src/main/java/org/apache/syncope/common/lib/types/BpmnProcessFormat.java index 549eb9a..9eea132 100644 --- a/ext/flowable/common-lib/src/main/java/org/apache/syncope/common/lib/types/BpmnProcessFormat.java +++ b/ext/flowable/common-lib/src/main/java/org/apache/syncope/common/lib/types/BpmnProcessFormat.java @@ -18,12 +18,23 @@ */ package org.apache.syncope.common.lib.types; +import javax.ws.rs.core.MediaType; + /** * Format for import / export of workflow definition. */ public enum BpmnProcessFormat { - XML, - JSON + XML(MediaType.APPLICATION_XML_TYPE), + JSON(MediaType.APPLICATION_JSON_TYPE); + + private final MediaType mediaType; + + private BpmnProcessFormat(final MediaType mediaType) { + this.mediaType = mediaType; + } + public MediaType getMediaType() { + return mediaType; + } } diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java index 60654cf..3d5cd22 100644 --- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java +++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/impl/FlowableRuntimeUtils.java @@ -88,7 +88,7 @@ public final class FlowableRuntimeUtils { } public static String getWFProcBusinessKey(final String userKey) { - return FlowableRuntimeUtils.getProcBusinessKey(WF_PROCESS_ID, userKey); + return getProcBusinessKey(WF_PROCESS_ID, userKey); } public static String getWFProcInstID(final DomainProcessEngine engine, final String userKey) { @@ -179,31 +179,26 @@ public final class FlowableRuntimeUtils { return; } - engine.getRuntimeService().setVariable(procInstId, FlowableRuntimeUtils.USER_TO, userTO); + engine.getRuntimeService().setVariable(procInstId, USER_TO, userTO); if (password == null) { - String encryptedPwd = engine.getRuntimeService(). - getVariable(procInstId, FlowableRuntimeUtils.ENCRYPTED_PWD, String.class); + String encryptedPwd = engine.getRuntimeService().getVariable(procInstId, ENCRYPTED_PWD, String.class); if (encryptedPwd != null) { userTO.setPassword(decrypt(encryptedPwd)); } } else { userTO.setPassword(password); - engine.getRuntimeService(). - setVariable(procInstId, FlowableRuntimeUtils.ENCRYPTED_PWD, encrypt(password)); + engine.getRuntimeService().setVariable(procInstId, ENCRYPTED_PWD, encrypt(password)); } - engine.getRuntimeService().setVariable( - procInstId, FlowableRuntimeUtils.ENABLED, enabled); + engine.getRuntimeService().setVariable(procInstId, ENABLED, enabled); - engine.getRuntimeService().setVariable( - procInstId, FlowableRuntimeUtils.PROP_BY_RESOURCE, propByRes); + engine.getRuntimeService().setVariable(procInstId, PROP_BY_RESOURCE, propByRes); if (propByRes != null) { propByRes.clear(); } - engine.getRuntimeService().setVariable( - procInstId, FlowableRuntimeUtils.PROP_BY_LINKEDACCOUNT, propByLinkedAccount); + engine.getRuntimeService().setVariable(procInstId, PROP_BY_LINKEDACCOUNT, propByLinkedAccount); if (propByLinkedAccount != null) { propByLinkedAccount.clear(); } diff --git a/ext/flowable/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/BpmnProcessServiceImpl.java b/ext/flowable/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/BpmnProcessServiceImpl.java index 4f976b5..530ca1c 100644 --- a/ext/flowable/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/BpmnProcessServiceImpl.java +++ b/ext/flowable/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/BpmnProcessServiceImpl.java @@ -51,8 +51,7 @@ public class BpmnProcessServiceImpl extends AbstractServiceImpl implements BpmnP StreamingOutput sout = os -> logic.exportDefinition(key, format, os); return Response.ok(sout). - type(format == BpmnProcessFormat.JSON - ? MediaType.APPLICATION_JSON_TYPE : MediaType.APPLICATION_XHTML_XML_TYPE). + type(format.getMediaType()). build(); } diff --git a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMConf.java b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMConf.java index 1875eba..d6161cb 100644 --- a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMConf.java +++ b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMConf.java @@ -55,5 +55,4 @@ public class SCIMConf implements Serializable { public void setEnterpriseUserConf(final SCIMEnterpriseUserConf enterpriseUserConf) { this.enterpriseUserConf = enterpriseUserConf; } - } diff --git a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMGeneralConf.java b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMGeneralConf.java index cf9bc71..fe29e94 100644 --- a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMGeneralConf.java +++ b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMGeneralConf.java @@ -100,5 +100,4 @@ public class SCIMGeneralConf implements Serializable { public void setFilterMaxResults(final int filterMaxResults) { this.filterMaxResults = filterMaxResults; } - } diff --git a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserConf.java b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserConf.java index c2c0d15..1ed62a9 100644 --- a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserConf.java +++ b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserConf.java @@ -191,5 +191,4 @@ public class SCIMUserConf implements Serializable { public List<String> getX509Certificates() { return x509Certificates; } - } diff --git a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserNameConf.java b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserNameConf.java index 2af8005..1f632f0 100644 --- a/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserNameConf.java +++ b/ext/scimv2/common-lib/src/main/java/org/apache/syncope/common/lib/scim/SCIMUserNameConf.java @@ -23,7 +23,11 @@ import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +@XmlRootElement(name = "scimUserNameConf") +@XmlType public class SCIMUserNameConf implements Serializable { private static final long serialVersionUID = -2256008193008290376L; @@ -113,5 +117,4 @@ public class SCIMUserNameConf implements Serializable { public void setHonorificSuffix(final String honorificSuffix) { this.honorificSuffix = honorificSuffix; } - } diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/SyslogRewriteAuditAppender.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/SyslogRewriteAuditAppender.java index 6398777..48e773c 100644 --- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/SyslogRewriteAuditAppender.java +++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/SyslogRewriteAuditAppender.java @@ -35,24 +35,21 @@ public class SyslogRewriteAuditAppender extends DefaultRewriteAuditAppender { @Override public Set<AuditLoggerName> getEvents() { Set<AuditLoggerName> events = new HashSet<>(); - events.add(new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - ResourceLogic.class.getSimpleName(), - null, - "update", - AuditElements.Result.SUCCESS)); - events.add(new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - ConnectorLogic.class.getSimpleName(), - null, - "update", - AuditElements.Result.SUCCESS)); - events.add(new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - ResourceLogic.class.getSimpleName(), - null, - "delete", - AuditElements.Result.SUCCESS)); + events.add(new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category(ResourceLogic.class.getSimpleName()). + event("update"). + result(AuditElements.Result.SUCCESS).build()); + events.add(new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category(ConnectorLogic.class.getSimpleName()). + event("update"). + result(AuditElements.Result.SUCCESS).build()); + events.add(new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category(ResourceLogic.class.getSimpleName()). + event("delete"). + result(AuditElements.Result.SUCCESS).build()); return events; } diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditAppender.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditAppender.java index ca508f7..bcf08b2 100644 --- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditAppender.java +++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileAuditAppender.java @@ -38,18 +38,16 @@ public class TestFileAuditAppender extends DefaultAuditAppender { @Override public Set<AuditLoggerName> getEvents() { Set<AuditLoggerName> events = new HashSet<>(); - events.add(new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - ResourceLogic.class.getSimpleName(), - null, - "create", - AuditElements.Result.SUCCESS)); - events.add(new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - ConnectorLogic.class.getSimpleName(), - null, - "update", - AuditElements.Result.SUCCESS)); + events.add(new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category(ResourceLogic.class.getSimpleName()). + event("create"). + result(AuditElements.Result.SUCCESS).build()); + events.add(new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category(ConnectorLogic.class.getSimpleName()). + event("update"). + result(AuditElements.Result.SUCCESS).build()); return events; } diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileRewriteAuditAppender.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileRewriteAuditAppender.java index 9741a29..c45905e 100644 --- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileRewriteAuditAppender.java +++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestFileRewriteAuditAppender.java @@ -36,12 +36,11 @@ public class TestFileRewriteAuditAppender extends DefaultRewriteAuditAppender { @Override public Set<AuditLoggerName> getEvents() { - return Collections.singleton(new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - ResourceLogic.class.getSimpleName(), - null, - "update", - AuditElements.Result.SUCCESS)); + return Collections.singleton(new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category(ResourceLogic.class.getSimpleName()). + event("update"). + result(AuditElements.Result.SUCCESS).build()); } @Override diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java index 29703fa..0de6530 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/AuthenticationITCase.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.security.AccessControlException; @@ -37,6 +38,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.syncope.client.lib.AnonymousAuthenticationHandler; import org.apache.syncope.client.lib.BasicAuthenticationHandler; import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.patch.DeassociationPatch; @@ -475,6 +477,7 @@ public class AuthenticationITCase extends AbstractITCase { @Test public void issueSYNCOPE434() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // 1. create user with group 'groupForWorkflowApproval' diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DerSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DerSchemaITCase.java index a916663..7ed1d9a 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DerSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/DerSchemaITCase.java @@ -29,6 +29,7 @@ import java.util.Locale; import javax.ws.rs.core.Response; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.DerSchemaTO; +import org.apache.syncope.common.lib.to.SchemaTO; import org.apache.syncope.common.lib.types.ClientExceptionType; import org.apache.syncope.common.lib.types.EntityViolationType; import org.apache.syncope.common.lib.types.SchemaType; @@ -64,8 +65,8 @@ public class DerSchemaITCase extends AbstractITCase { DerSchemaTO schema = new DerSchemaTO(); schema.setKey("derived"); schema.setExpression("derived_sx + '_' + derived_dx"); - schema.getLabels().put(Locale.ENGLISH, "Derived"); - schema.getLabels().put(Locale.ITALIAN, "Derivato"); + schema.getLabels().put(SchemaTO.toString(Locale.ENGLISH), "Derived"); + schema.getLabels().put(SchemaTO.toString(Locale.ITALIAN), "Derivato"); DerSchemaTO actual = createSchema(SchemaType.DERIVED, schema); assertNotNull(actual); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java index 80188cb..58b7e7a 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/LoggerITCase.java @@ -139,12 +139,11 @@ public class LoggerITCase extends AbstractITCase { @Test public void enableDisableAudit() { - AuditLoggerName auditLoggerName = new AuditLoggerName( - EventCategoryType.LOGIC, - ReportLogic.class.getSimpleName(), - null, - "deleteExecution", - AuditElements.Result.FAILURE); + AuditLoggerName auditLoggerName = new AuditLoggerName.Builder(). + type(EventCategoryType.LOGIC). + category(ReportLogic.class.getSimpleName()). + event("deleteExecution"). + result(AuditElements.Result.FAILURE).build(); List<AuditLoggerName> audits = LoggerWrapper.wrap(loggerService.list(LoggerType.AUDIT)); assertNotNull(audits); @@ -269,21 +268,19 @@ public class LoggerITCase extends AbstractITCase { @Test public void customAuditAppender() throws IOException, InterruptedException { - AuditLoggerName auditLoggerResUpd = new AuditLoggerName( - EventCategoryType.LOGIC, - ResourceLogic.class.getSimpleName(), - null, - "update", - AuditElements.Result.SUCCESS); + AuditLoggerName auditLoggerResUpd = new AuditLoggerName.Builder(). + type(EventCategoryType.LOGIC). + category(ResourceLogic.class.getSimpleName()). + event("update"). + result(AuditElements.Result.SUCCESS).build(); LoggerTO resUpd = new LoggerTO(); resUpd.setKey(auditLoggerResUpd.toLoggerName()); - AuditLoggerName auditLoggerConnUpd = new AuditLoggerName( - EventCategoryType.LOGIC, - ConnectorLogic.class.getSimpleName(), - null, - "update", - AuditElements.Result.SUCCESS); + AuditLoggerName auditLoggerConnUpd = new AuditLoggerName.Builder(). + type(EventCategoryType.LOGIC). + category(ConnectorLogic.class.getSimpleName()). + event("update"). + result(AuditElements.Result.SUCCESS).build(); LoggerTO connUpd = new LoggerTO(); connUpd.setKey(auditLoggerConnUpd.toLoggerName()); @@ -375,30 +372,30 @@ public class LoggerITCase extends AbstractITCase { @Test public void issueSYNCOPE1446() { - AuditLoggerName createSuccess = new AuditLoggerName( - AuditElements.EventCategoryType.PROPAGATION, - AnyTypeKind.ANY_OBJECT.name().toLowerCase(), - RESOURCE_NAME_DBSCRIPTED, - "create", - AuditElements.Result.SUCCESS); - AuditLoggerName createFailure = new AuditLoggerName( - AuditElements.EventCategoryType.PROPAGATION, - AnyTypeKind.ANY_OBJECT.name().toLowerCase(), - RESOURCE_NAME_DBSCRIPTED, - "create", - AuditElements.Result.FAILURE); - AuditLoggerName updateSuccess = new AuditLoggerName( - AuditElements.EventCategoryType.PROPAGATION, - AnyTypeKind.ANY_OBJECT.name().toLowerCase(), - RESOURCE_NAME_DBSCRIPTED, - "update", - AuditElements.Result.SUCCESS); - AuditLoggerName updateFailure = new AuditLoggerName( - AuditElements.EventCategoryType.PROPAGATION, - AnyTypeKind.ANY_OBJECT.name().toLowerCase(), - RESOURCE_NAME_DBSCRIPTED, - "update", - AuditElements.Result.FAILURE); + AuditLoggerName createSuccess = new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.PROPAGATION). + category(AnyTypeKind.ANY_OBJECT.name().toLowerCase()). + subcategory(RESOURCE_NAME_DBSCRIPTED). + event("create"). + result(AuditElements.Result.SUCCESS).build(); + AuditLoggerName createFailure = new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.PROPAGATION). + category(AnyTypeKind.ANY_OBJECT.name().toLowerCase()). + subcategory(RESOURCE_NAME_DBSCRIPTED). + event("create"). + result(AuditElements.Result.FAILURE).build(); + AuditLoggerName updateSuccess = new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.PROPAGATION). + category(AnyTypeKind.ANY_OBJECT.name().toLowerCase()). + subcategory(RESOURCE_NAME_DBSCRIPTED). + event("update"). + result(AuditElements.Result.SUCCESS).build(); + AuditLoggerName updateFailure = new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.PROPAGATION). + category(AnyTypeKind.ANY_OBJECT.name().toLowerCase()). + subcategory(RESOURCE_NAME_DBSCRIPTED). + event("update"). + result(AuditElements.Result.FAILURE).build(); try { // 1. setup audit for propagation LoggerTO loggerTO = new LoggerTO(); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java index 3135834..26ffd49 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java @@ -32,6 +32,7 @@ import java.util.Locale; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.Response; import org.apache.commons.lang3.SerializationUtils; +import org.apache.cxf.helpers.IOUtils; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.patch.AttrPatch; import org.apache.syncope.common.lib.patch.UserPatch; @@ -39,6 +40,7 @@ import org.apache.syncope.common.lib.to.AnyTypeClassTO; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; import org.apache.syncope.common.lib.to.ProvisioningResult; +import org.apache.syncope.common.lib.to.SchemaTO; import org.apache.syncope.common.lib.to.UserTO; import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.common.lib.types.CipherAlgorithm; @@ -49,7 +51,6 @@ import org.apache.syncope.common.lib.types.SchemaType; import org.apache.syncope.common.rest.api.beans.SchemaQuery; import org.apache.syncope.fit.AbstractITCase; import org.junit.jupiter.api.Test; -import org.apache.cxf.helpers.IOUtils; public class PlainSchemaITCase extends AbstractITCase { @@ -64,8 +65,8 @@ public class PlainSchemaITCase extends AbstractITCase { public void create() { PlainSchemaTO schemaTO = buildPlainSchemaTO("testAttribute", AttrSchemaType.String); schemaTO.setMandatoryCondition("false"); - schemaTO.getLabels().put(Locale.ENGLISH, "Test"); - schemaTO.getLabels().put(Locale.ITALIAN, "Prova"); + schemaTO.getLabels().put(SchemaTO.toString(Locale.ENGLISH), "Test"); + schemaTO.getLabels().put(SchemaTO.toString(Locale.ITALIAN), "Prova"); PlainSchemaTO newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO); assertEquals(schemaTO, newPlainSchemaTO); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java index 1f230a9..d3eea35 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -46,6 +47,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.tuple.Pair; import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.patch.DeassociationPatch; @@ -721,6 +723,8 @@ public class PullTaskITCase extends AbstractTaskITCase { @Test public void remediation() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); + // First of all, clear any potential conflict with existing user / group ldapCleanup(); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java index ba579bd..3a72ba4 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/ReportITCase.java @@ -311,12 +311,11 @@ public class ReportITCase extends AbstractITCase { @Test public void auditReport() throws IOException { - AuditLoggerName auditLoggerName = new AuditLoggerName( - AuditElements.EventCategoryType.LOGIC, - "UserLogic", - null, - "selfRead", - AuditElements.Result.SUCCESS); + AuditLoggerName auditLoggerName = new AuditLoggerName.Builder(). + type(AuditElements.EventCategoryType.LOGIC). + category("UserLogic"). + event("selfRead"). + result(AuditElements.Result.SUCCESS).build(); try { LoggerTO loggerTO = new LoggerTO(); diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java index 3994005..539abe9 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java @@ -40,6 +40,7 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.scim.SCIMComplexConf; import org.apache.syncope.common.lib.scim.SCIMConf; @@ -131,6 +132,7 @@ public class SCIMITCase extends AbstractITCase { @BeforeEach public void check() { + assumeTrue(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.JSON); assumeTrue(isSCIMAvailable(webClient())); } diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java index 6efce7c..e7917dd 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserRequestITCase.java @@ -51,7 +51,7 @@ public class UserRequestITCase extends AbstractITCase { @BeforeAll public static void loadBpmnProcesses() throws IOException { - assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.YAML); + assumeTrue(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.JSON); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); WebClient.client(bpmnProcessService).type(MediaType.APPLICATION_XML_TYPE); @@ -65,7 +65,7 @@ public class UserRequestITCase extends AbstractITCase { @BeforeEach public void check() { - assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.YAML); + assumeTrue(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.JSON); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); } diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserSelfITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserSelfITCase.java index 555f57c..781875c 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserSelfITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserSelfITCase.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Collections; @@ -39,6 +40,7 @@ import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.patch.BooleanReplacePatchItem; import org.apache.syncope.common.lib.patch.MembershipPatch; @@ -105,6 +107,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void createAndApprove() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // 1. self-create user with membership: goes 'createApproval' with resources and membership but no propagation @@ -143,6 +146,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void createAndUnclaim() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // 1. self-create user with membership: goes 'createApproval' with resources and membership but no propagation @@ -241,6 +245,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void updateWithApproval() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // 1. create user as admin @@ -464,6 +469,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void createWithReject() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); @@ -540,6 +546,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void createWithApproval() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // read forms *before* any operation @@ -627,6 +634,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void updateApproval() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // read forms *before* any operation @@ -704,6 +712,7 @@ public class UserSelfITCase extends AbstractITCase { @Test public void issueSYNCOPE15() { + assumeFalse(clientFactory.getContentType() == SyncopeClientFactoryBean.ContentType.XML); assumeTrue(FlowableDetector.isFlowableEnabledForUserWorkflow(syncopeService)); // read forms *before* any operation diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirSchemaITCase.java index 2848249..03d2840 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/VirSchemaITCase.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.Response; import org.apache.syncope.client.lib.AnonymousAuthenticationHandler; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.ResourceTO; +import org.apache.syncope.common.lib.to.SchemaTO; import org.apache.syncope.common.lib.to.VirSchemaTO; import org.apache.syncope.common.lib.types.ClientExceptionType; import org.apache.syncope.common.lib.types.EntityViolationType; @@ -69,7 +70,7 @@ public class VirSchemaITCase extends AbstractITCase { schema.setExtAttrName("name"); schema.setResource(RESOURCE_NAME_CSV); schema.setAnyType(csv.getProvisions().get(0).getAnyType()); - schema.getLabels().put(Locale.ENGLISH, "Virtual"); + schema.getLabels().put(SchemaTO.toString(Locale.ENGLISH), "Virtual"); schema = createSchema(SchemaType.VIRTUAL, schema); assertNotNull(schema);
