void close() { if (context != null) { context.close(); context = null; } close(systemSession); }
private void close() { if (ctx != null) { ctx.close(); } if (idpRegistration != null) { idpRegistration.unregister(); } if (shRegistration != null) { shRegistration.unregister(); } }
@Test public void testSyncExternalGroupExisting() throws Exception { // create an external external group that already has been synced into the repo ExternalGroup externalGroup = idp.listGroups().next(); SyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory); ctx.sync(externalGroup); ctx.close(); // synchronizing using DynamicSyncContext must update the existing group syncContext.setForceGroupSync(true); SyncResult result = syncContext.sync(externalGroup); assertSame(SyncResult.Status.UPDATE, result.getStatus()); }
/** * Initiates synchronization of a possible remove user * @param id the user id */ private void validateUser(@NotNull String id) throws SyncException { SyncContext context = null; try { Root root = getRoot(); if (root == null) { throw new SyncException("Cannot synchronize user. root == null"); } UserManager userManager = getUserManager(); if (userManager == null) { throw new SyncException("Cannot synchronize user. userManager == null"); } DebugTimer timer = new DebugTimer(); context = syncHandler.createContext(idp, userManager, new ValueFactoryImpl(root, NamePathMapper.DEFAULT)); context.sync(id); timer.mark("sync"); root.commit(); timer.mark("commit"); debug("validateUser({}) {}", id, timer.getString()); } catch (CommitFailedException e) { throw new SyncException("User synchronization failed during commit.", e); } finally { if (context != null) { context.close(); } } }
} finally { if (context != null) { context.close();
@Override public void before() throws Exception { super.before(); // sync external users into the system using the 2 different sync-context implementations Root systemRoot = getSystemRoot(); SyncContext syncContext = new DynamicSyncContext(syncConfig, idp, getUserManager(systemRoot), getValueFactory(systemRoot)); syncContext.sync(idp.getUser(USER_ID)); syncContext.close(); syncContext = new DefaultSyncContext(syncConfig, idp, getUserManager(systemRoot), getValueFactory(systemRoot)); syncContext.sync(idp.getUser(TestIdentityProvider.ID_SECOND_USER)); syncContext.close(); systemRoot.commit(); root.refresh(); principalProvider = createPrincipalProvider(); }
@Test public void testSyncMembershipForExternalGroup() throws Exception { ExternalGroup externalGroup = idp.getGroup("a"); // a group that has declaredGroups SyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory); ctx.sync(externalGroup); ctx.close(); r.commit(); Authorizable gr = userManager.getAuthorizable(externalGroup.getId()); syncContext.syncMembership(externalGroup, gr, 1); assertFalse(gr.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES)); assertFalse(r.hasPendingChanges()); }