private Delegatee(@NotNull SyncHandler handler, @NotNull ExternalIdentityProvider idp, @NotNull ContentSession systemSession, @NotNull SecurityProvider securityProvider, int batchSize) { this.handler = handler; this.idp = idp; this.systemSession = systemSession; this.batchSize = batchSize; root = systemSession.getLatestRoot(); userMgr = securityProvider.getConfiguration(UserConfiguration.class).getUserManager(root, NamePathMapper.DEFAULT); context = handler.createContext(idp, userMgr, new ValueFactoryImpl(root, NamePathMapper.DEFAULT)); log.info("Created delegatee for SyncMBean with session: {} {}", systemSession, systemSession.getAuthInfo().getUserID()); }
/** * 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(); } } }
try { DebugTimer timer = new DebugTimer(); context = syncHandler.createContext(idp, userManager, new ValueFactoryImpl(root, NamePathMapper.DEFAULT)); SyncResult syncResult = context.sync(user); timer.mark("sync");
private void sync(@NotNull String id, boolean isGroup) throws Exception { ctx = sh.createContext(idp, userManager, valueFactory); ExternalIdentity exIdentity = (isGroup) ? idp.getGroup(id) : idp.getUser(id); assertNotNull(exIdentity); SyncResult res = ctx.sync(exIdentity); assertEquals(idp.getName(), res.getIdentity().getExternalIdRef().getProviderName()); assertSame(SyncResult.Status.ADD, res.getStatus()); r.commit(); }