Skip to content

Commit cdc666e

Browse files
committed
[SYNCOPE-1896] Fixing ConnectorObject serialization for Audit
1 parent eb0aaec commit cdc666e

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DefaultAuditManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,20 @@ public void audit(
149149
auditEntry.setWho(who);
150150
auditEntry.setLogger(auditLoggerName);
151151
auditEntry.setDate(OffsetDateTime.now());
152-
auditEntry.setBefore(POJOHelper.serialize((maskSensitive(before))));
152+
auditEntry.setBefore(before instanceof String
153+
? (String) before
154+
: POJOHelper.serialize((maskSensitive(before))));
153155
if (throwable == null) {
154-
auditEntry.setOutput(POJOHelper.serialize((maskSensitive(output))));
156+
auditEntry.setOutput(output instanceof String
157+
? (String) output
158+
: POJOHelper.serialize((maskSensitive(output))));
155159
} else {
156160
auditEntry.setOutput(throwable.getMessage());
157161
auditEntry.setThrowable(ExceptionUtils2.getFullStackTrace(throwable));
158162
}
159163
if (input != null) {
160164
auditEntry.getInputs().addAll(Arrays.stream(input).
161-
map(DefaultAuditManager::maskSensitive).map(POJOHelper::serialize).
165+
map(item -> item instanceof String ? (String) item : POJOHelper.serialize(maskSensitive(item))).
162166
collect(Collectors.toList()));
163167
}
164168

core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import org.apache.syncope.common.lib.types.UnmatchingRule;
4343
import org.apache.syncope.core.persistence.api.entity.Any;
4444
import org.apache.syncope.core.persistence.api.entity.ExternalResource;
45+
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
46+
import org.apache.syncope.core.persistence.api.entity.group.Group;
4547
import org.apache.syncope.core.persistence.api.entity.task.PushTask;
4648
import org.apache.syncope.core.persistence.api.entity.user.User;
4749
import org.apache.syncope.core.provisioning.api.AuditManager;
@@ -54,6 +56,7 @@
5456
import org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException;
5557
import org.apache.syncope.core.provisioning.api.pushpull.PushActions;
5658
import org.apache.syncope.core.provisioning.api.pushpull.SyncopePushResultHandler;
59+
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
5760
import org.apache.syncope.core.provisioning.java.job.AfterHandlingJob;
5861
import org.apache.syncope.core.provisioning.java.propagation.DefaultPropagationReporter;
5962
import org.apache.syncope.core.spring.security.AuthContextUtils;
@@ -95,7 +98,7 @@ protected void update(
9598
final Boolean enable,
9699
final ConnectorObject beforeObj,
97100
final ProvisioningReport result) {
98-
101+
99102
List<String> ownedResources = getAnyUtils().getAllResources(any).stream().
100103
map(ExternalResource::getKey).collect(Collectors.toList());
101104

@@ -493,9 +496,13 @@ protected void doHandle(final Any<?> any, final Provision provision) throws JobE
493496
profile.getTask().getResource().getKey(),
494497
operation,
495498
resultStatus,
496-
beforeObj,
497-
output,
498-
any));
499+
beforeObj == null ? null : POJOHelper.serialize(beforeObj),
500+
output == null ? null : output instanceof Exception ? output : POJOHelper.serialize(output),
501+
any instanceof User
502+
? userDataBinder.getUserTO((User) any, true)
503+
: any instanceof Group
504+
? groupDataBinder.getGroupTO((Group) any, true)
505+
: anyObjectDataBinder.getAnyObjectTO((AnyObject) any, true)));
499506
AfterHandlingJob.schedule(scheduler, jobMap);
500507
}
501508
}

core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultRealmPushResultHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException;
5050
import org.apache.syncope.core.provisioning.api.pushpull.PushActions;
5151
import org.apache.syncope.core.provisioning.api.pushpull.RealmPushResultHandler;
52+
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
5253
import org.apache.syncope.core.provisioning.java.job.AfterHandlingJob;
5354
import org.apache.syncope.core.provisioning.java.propagation.DefaultPropagationReporter;
5455
import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
@@ -441,9 +442,9 @@ private void doHandle(final Realm realm) throws JobExecutionException {
441442
profile.getTask().getResource().getKey(),
442443
operation,
443444
resultStatus,
444-
beforeObj,
445-
output,
446-
realm));
445+
beforeObj == null ? null : POJOHelper.serialize(beforeObj),
446+
output == null ? null : output instanceof Exception ? output : POJOHelper.serialize(output),
447+
binder.getRealmTO(realm, true)));
447448
AfterHandlingJob.schedule(scheduler, jobMap);
448449
}
449450
}

0 commit comments

Comments
 (0)