Skip to content

Instantly share code, notes, and snippets.

View ilgrosso's full-sized avatar

Francesco Chicchiriccò ilgrosso

View GitHub Profile
@ilgrosso
ilgrosso / Logic.java
Created June 15, 2023 14:19
Syncope: update single attribute onto External Resource
public class ICLDAPLogic extends AbstractTransactionalLogic<EntityTO> {
private final UserDAO userDAO;
private final ExternalResourceDAO resourceDAO;
private final MappingManager mappingManager;
private final PropagationTaskExecutor taskExecutor;
@ilgrosso
ilgrosso / ReplacingMavenReleasePlugin.md
Last active May 5, 2023 13:25
Apache Syncope's release process changes since maven-release-plugin does not work anymore

During the release process for Apache Syncope 2.1.14 I noticed that release:prepare was not advancing POM version from 2.1.14-SNAPSHOT to 2.1.14, nor it was creating the syncope-2.1.14 tag.

Waiting to understand the reason, I was able to replace the actions peformed by release:prepare and release:perform with the following.

Release prepare

Plugin steps: http://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html

Change version to 2.1.14

@ilgrosso
ilgrosso / AttributesEnrichingPropagationActions.java
Last active February 24, 2020 07:29
AttributesEnrichingPropagationActions
public class AttributesEnrichingPropagationAction implements PropagationActions {
@Autowired
private UserDAO userDAO;
@Transactional(readonly = true)
@Override
public void before(final PropagationTask task, final ConnectorObject beforeObj) {
// do something only if propagating users
if (AnyTypeKind.USER == task.getAnyTypeKind()) {
@ilgrosso
ilgrosso / LdapIncrementalPullCorrelationRule.java
Last active September 25, 2019 13:24
LdapIncrementalPullCorrelationRule
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.core.persistence.api.dao.PullCorrelationRule;
import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
import org.apache.syncope.core.persistence.api.entity.resource.Provision;
import org.identityconnectors.framework.common.objects.SyncDelta;
public class GFSLdapPullRule implements PullCorrelationRule {
@Override
@ilgrosso
ilgrosso / FirefoxOnDocker.md
Last active August 16, 2019 12:27
Firefox on Docker
@ilgrosso
ilgrosso / WicketPlugin.java
Created July 16, 2018 11:49
Hotswap: tentative Wicket plugin
import java.lang.reflect.Method;
import org.hotswap.agent.annotation.Init;
import org.hotswap.agent.annotation.OnClassLoadEvent;
import org.hotswap.agent.annotation.OnResourceFileEvent;
import org.hotswap.agent.annotation.Plugin;
import org.hotswap.agent.command.Scheduler;
import org.hotswap.agent.javassist.CannotCompileException;
import org.hotswap.agent.javassist.CtClass;
import org.hotswap.agent.javassist.NotFoundException;
import org.hotswap.agent.logging.AgentLogger;
List<PullActions> actions = new ArrayList<>();
for (String className : pullTask.getActionsClassNames()) {
try {
PullActions pullActions;
if (className.indexOf('.') == -1) {
ExtensionScript script = null; // suppose to fetch it using className as key
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(new InputStreamReader(script.getContent()));
package org.apache.syncope.core.provisioning.java.pushpull;
import javax.script.Bindings;
import javax.script.Invocable;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import javax.script.SimpleBindings;
import org.apache.syncope.common.lib.patch.AnyPatch;
import org.apache.syncope.common.lib.to.AnyTO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.Transformer;
import org.apache.commons.collections4.list.SetUniqueList;
// Given this user...
UserTO userTO = ...
List<String> groupKeys = SetUniqueList.setUniqueList(new ArrayList<String>());
// First statically assigned groups...
@ilgrosso
ilgrosso / ODataJClient4_EntityRetrieve.java
Last active January 4, 2016 20:29
ODataJClient4: EntityRetrieve
ODataClient client = ODataClientFactory.getV3(); // or ODataClientFactory.getV4();
String serviceRoot = ...;
URIBuilder uriBuilder = client.getURIBuilder(serviceRoot).
appendEntityTypeSegment("Customer").appendKeySegment(-10).expand("Info");
// long version (using ATOM)
ODataEntityRequest req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build());
req.setFormat(ODataPubFormat.ATOM);
ODataRetrieveResponse<ODataEntity> res = req.execute();