public class DefaultSyncContext extends Object implements SyncContext
| Modifier and Type | Field and Description |
|---|---|
protected DefaultSyncConfig |
config |
protected boolean |
forceGroupSync |
protected boolean |
forceUserSync |
protected ExternalIdentityProvider |
idp |
protected boolean |
keepMissing |
protected long |
now |
protected Value |
nowValue |
static String |
REP_EXTERNAL_ID
Name of the
ExternalIdentity.getExternalId() property of a synchronized identity. |
static String |
REP_LAST_SYNCED
Name of the property that stores the time when an identity was synced.
|
protected UserManager |
userManager |
protected ValueFactory |
valueFactory |
| Constructor and Description |
|---|
DefaultSyncContext(DefaultSyncConfig config,
ExternalIdentityProvider idp,
UserManager userManager,
ValueFactory valueFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyMembership(Authorizable member,
Set<String> groups)
Ensures that the given authorizable is member of the specific groups.
|
void |
close()
Closes this context and releases any resources bound to it.
|
protected Group |
createGroup(ExternalGroup externalGroup)
Creates a new repository group for the given external one.
|
static DefaultSyncedIdentity |
createSyncedIdentity(Authorizable auth)
Creates a synced identity from the given authorizable.
|
protected User |
createUser(ExternalUser externalUser)
Creates a new repository user for the given external one.
|
protected Value |
createValue(Object v)
Creates a new JCR value of the given object, checking the internal type.
|
protected Value[] |
createValues(Collection<?> propValues)
Creates an array of JCR values based on the type.
|
protected <T extends Authorizable> |
getAuthorizable(ExternalIdentity external,
Class<T> type)
Retrieves the repository authorizable that corresponds to the given external identity
|
static ExternalIdentityRef |
getIdentityRef(Authorizable auth)
Retrieves the external identity ref from the authorizable
|
protected boolean |
isExpired(Authorizable auth,
long expirationTime,
String type)
Checks if the given authorizable needs syncing based on the
REP_LAST_SYNCED property. |
boolean |
isForceGroupSync()
Defines if synchronization of groups always will perform, i.e.
|
boolean |
isForceUserSync()
Defines if synchronization of users always will perform, i.e.
|
boolean |
isKeepMissing()
Defines if synchronization keeps missing external identities on synchronization of authorizables.
|
protected boolean |
isSameIDP(Authorizable auth)
Checks if the given authorizable was synced from the same IDP by comparing the IDP name of the
"rep:externalId" property.
|
protected boolean |
isSameIDP(ExternalIdentityRef ref)
Tests if the given
ExternalIdentityRef refers to the same IDP
as associated with this context instance. |
static String |
joinPaths(String... paths)
Deprecated.
Since Oak 1.3.10. Please use
PathUtils.concatRelativePaths(String...) instead. |
SyncContext |
setForceGroupSync(boolean forceGroupSync)
|
SyncContext |
setForceUserSync(boolean forceUserSync)
|
SyncContext |
setKeepMissing(boolean keepMissing)
|
SyncResult |
sync(ExternalIdentity identity)
Synchronizes an external identity with the repository based on the respective configuration.
|
SyncResult |
sync(String id)
Synchronizes an authorizable with the corresponding external identity with the repository based on the respective
configuration.
|
protected DefaultSyncResultImpl |
syncGroup(ExternalGroup external,
Group group) |
protected void |
syncMembership(ExternalIdentity external,
Authorizable auth,
long depth)
Recursively sync the memberships of an authorizable up-to the specified depth.
|
protected void |
syncProperties(ExternalIdentity ext,
Authorizable auth,
Map<String,String> mapping)
Syncs the properties specified in the
mapping from the external identity to the given authorizable. |
protected DefaultSyncResultImpl |
syncUser(ExternalUser external,
User user) |
public static final String REP_EXTERNAL_ID
ExternalIdentity.getExternalId() property of a synchronized identity.public static final String REP_LAST_SYNCED
protected final DefaultSyncConfig config
protected final ExternalIdentityProvider idp
protected final UserManager userManager
protected final ValueFactory valueFactory
protected boolean keepMissing
protected boolean forceUserSync
protected boolean forceGroupSync
protected final long now
protected final Value nowValue
public DefaultSyncContext(@Nonnull DefaultSyncConfig config, @Nonnull ExternalIdentityProvider idp, @Nonnull UserManager userManager, @Nonnull ValueFactory valueFactory)
@CheckForNull public static DefaultSyncedIdentity createSyncedIdentity(@Nullable Authorizable auth) throws RepositoryException
auth - the authorizableRepositoryException - if an error occurs@CheckForNull public static ExternalIdentityRef getIdentityRef(@Nullable Authorizable auth) throws RepositoryException
auth - the authorizableRepositoryException - if an error occurspublic static String joinPaths(String... paths)
PathUtils.concatRelativePaths(String...) instead.paths - relative pathspublic void close()
Root passed during the creation call. This is the responsibility of the
application.close in interface SyncContextpublic boolean isKeepMissing()
false.isKeepMissing in interface SyncContexttrue if keep missing.@Nonnull public SyncContext setKeepMissing(boolean keepMissing)
setKeepMissing in interface SyncContextpublic boolean isForceUserSync()
isForceUserSync in interface SyncContexttrue if forced syncing users@Nonnull public SyncContext setForceUserSync(boolean forceUserSync)
setForceUserSync in interface SyncContextpublic boolean isForceGroupSync()
isForceGroupSync in interface SyncContexttrue if forced syncing groups@Nonnull public SyncContext setForceGroupSync(boolean forceGroupSync)
SyncContextsetForceGroupSync in interface SyncContext@Nonnull public SyncResult sync(@Nonnull ExternalIdentity identity) throws SyncException
sync in interface SyncContextidentity - the identity to sync.SyncException - if an error occurs@Nonnull public SyncResult sync(@Nonnull String id) throws SyncException
sync in interface SyncContextid - the id of the authorizableSyncException - if an error occurs@CheckForNull protected <T extends Authorizable> T getAuthorizable(@Nonnull ExternalIdentity external, @Nonnull Class<T> type) throws RepositoryException, SyncException
external - the external identitytype - the authorizable typenull if not found.RepositoryException - if an error occurs.SyncException - if the repository contains a colliding authorizable with the same name.@Nonnull protected User createUser(@Nonnull ExternalUser externalUser) throws RepositoryException
externalUser - the external userRepositoryException - if an error occurs@Nonnull protected Group createGroup(@Nonnull ExternalGroup externalGroup) throws RepositoryException
externalGroup - the external groupRepositoryException - if an error occurs@Nonnull protected DefaultSyncResultImpl syncUser(@Nonnull ExternalUser external, @Nonnull User user) throws RepositoryException
RepositoryException@Nonnull protected DefaultSyncResultImpl syncGroup(@Nonnull ExternalGroup external, @Nonnull Group group) throws RepositoryException
RepositoryExceptionprotected void syncMembership(@Nonnull ExternalIdentity external, @Nonnull Authorizable auth, long depth) throws RepositoryException
external - the external identityauth - the authorizabledepth - recursion depth.RepositoryExceptionprotected void applyMembership(@Nonnull Authorizable member, @Nonnull Set<String> groups) throws RepositoryException
member - the authorizablegroups - set of groups.RepositoryExceptionprotected void syncProperties(@Nonnull ExternalIdentity ext, @Nonnull Authorizable auth, @Nonnull Map<String,String> mapping) throws RepositoryException
mapping from the external identity to the given authorizable.
Note that this method does not check for value equality and just blindly copies or deletes the properties.ext - external identityauth - the authorizablemapping - the property mappingRepositoryException - if an error occursprotected boolean isExpired(@Nonnull Authorizable auth, long expirationTime, @Nonnull String type) throws RepositoryException
REP_LAST_SYNCED property.auth - the authorizable to checkexpirationTime - the expiration time to compare to.type - debug message typetrue if the authorizable needs syncRepositoryException@CheckForNull protected Value createValue(@Nullable Object v) throws RepositoryException
v - the valueRepositoryException - if an error occurs@CheckForNull protected Value[] createValues(@Nonnull Collection<?> propValues) throws RepositoryException
propValues - the given valuesRepositoryException - if an error occursprotected boolean isSameIDP(@Nullable Authorizable auth) throws RepositoryException
auth - the authorizable.true if same IDP.RepositoryExceptionprotected boolean isSameIDP(@Nonnull ExternalIdentityRef ref)
ExternalIdentityRef refers to the same IDP
as associated with this context instance.ref - The ExternalIdentityRef to be tested.true if ExternalIdentityRef.getProviderName() refers
to the IDP associated with this context instance.Copyright © 2012-2017 The Apache Software Foundation. All Rights Reserved.