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(@NotNull DefaultSyncConfig config,
@NotNull ExternalIdentityProvider idp,
@NotNull UserManager userManager,
@NotNull ValueFactory valueFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyMembership(@NotNull Authorizable member,
@NotNull 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 @NotNull Group |
createGroup(@NotNull ExternalGroup externalGroup)
Creates a new repository group for the given external one.
|
static @Nullable DefaultSyncedIdentity |
createSyncedIdentity(@Nullable Authorizable auth)
Creates a synced identity from the given authorizable.
|
protected @NotNull User |
createUser(@NotNull ExternalUser externalUser)
Creates a new repository user for the given external one.
|
protected @Nullable Value |
createValue(@Nullable Object v)
Creates a new JCR value of the given object, checking the internal type.
|
protected @Nullable Value[] |
createValues(@NotNull Collection<?> propValues)
Creates an array of JCR values based on the type.
|
protected <T extends Authorizable> |
getAuthorizable(@NotNull ExternalIdentity external,
@NotNull Class<T> type)
Retrieves the repository authorizable that corresponds to the given external identity
|
static @Nullable ExternalIdentityRef |
getIdentityRef(@Nullable Authorizable auth)
Retrieves the external identity ref from the authorizable
|
protected boolean |
isExpired(@NotNull Authorizable auth,
long expirationTime,
@NotNull 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(@Nullable 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(@NotNull 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. |
@NotNull SyncContext |
setForceGroupSync(boolean forceGroupSync)
|
@NotNull SyncContext |
setForceUserSync(boolean forceUserSync)
|
@NotNull SyncContext |
setKeepMissing(boolean keepMissing)
|
@NotNull SyncResult |
sync(@NotNull ExternalIdentity identity)
Synchronizes an external identity with the repository based on the respective configuration.
|
@NotNull SyncResult |
sync(@NotNull String id)
Synchronizes an authorizable with the corresponding external identity with the repository based on the respective
configuration.
|
protected @NotNull DefaultSyncResultImpl |
syncGroup(@NotNull ExternalGroup external,
@NotNull Group group) |
protected void |
syncMembership(@NotNull ExternalIdentity external,
@NotNull Authorizable auth,
long depth)
Recursively sync the memberships of an authorizable up-to the specified depth.
|
protected void |
syncProperties(@NotNull ExternalIdentity ext,
@NotNull Authorizable auth,
@NotNull Map<String,String> mapping)
Syncs the properties specified in the
mapping from the external identity to the given authorizable. |
protected @NotNull DefaultSyncResultImpl |
syncUser(@NotNull ExternalUser external,
@NotNull 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(@NotNull
@NotNull DefaultSyncConfig config,
@NotNull
@NotNull ExternalIdentityProvider idp,
@NotNull
@NotNull UserManager userManager,
@NotNull
@NotNull ValueFactory valueFactory)
@Nullable public static @Nullable DefaultSyncedIdentity createSyncedIdentity(@Nullable @Nullable Authorizable auth) throws RepositoryException
auth - the authorizableRepositoryException - if an error occurs@Nullable public static @Nullable ExternalIdentityRef getIdentityRef(@Nullable @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.@NotNull public @NotNull SyncContext setKeepMissing(boolean keepMissing)
setKeepMissing in interface SyncContextpublic boolean isForceUserSync()
isForceUserSync in interface SyncContexttrue if forced syncing users@NotNull public @NotNull SyncContext setForceUserSync(boolean forceUserSync)
setForceUserSync in interface SyncContextpublic boolean isForceGroupSync()
isForceGroupSync in interface SyncContexttrue if forced syncing groups@NotNull public @NotNull SyncContext setForceGroupSync(boolean forceGroupSync)
SyncContextsetForceGroupSync in interface SyncContext@NotNull public @NotNull SyncResult sync(@NotNull @NotNull ExternalIdentity identity) throws SyncException
sync in interface SyncContextidentity - the identity to sync.SyncException - if an error occurs@NotNull public @NotNull SyncResult sync(@NotNull @NotNull String id) throws SyncException
sync in interface SyncContextid - the id of the authorizableSyncException - if an error occurs@Nullable protected <T extends Authorizable> T getAuthorizable(@NotNull @NotNull ExternalIdentity external, @NotNull @NotNull 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.@NotNull protected @NotNull User createUser(@NotNull @NotNull ExternalUser externalUser) throws RepositoryException
externalUser - the external userRepositoryException - if an error occurs@NotNull protected @NotNull Group createGroup(@NotNull @NotNull ExternalGroup externalGroup) throws RepositoryException
externalGroup - the external groupRepositoryException - if an error occurs@NotNull protected @NotNull DefaultSyncResultImpl syncUser(@NotNull @NotNull ExternalUser external, @NotNull @NotNull User user) throws RepositoryException
RepositoryException@NotNull protected @NotNull DefaultSyncResultImpl syncGroup(@NotNull @NotNull ExternalGroup external, @NotNull @NotNull Group group) throws RepositoryException
RepositoryExceptionprotected void syncMembership(@NotNull
@NotNull ExternalIdentity external,
@NotNull
@NotNull Authorizable auth,
long depth)
throws RepositoryException
external - the external identityauth - the authorizabledepth - recursion depth.RepositoryExceptionprotected void applyMembership(@NotNull
@NotNull Authorizable member,
@NotNull
@NotNull Set<String> groups)
throws RepositoryException
member - the authorizablegroups - set of groups.RepositoryExceptionprotected void syncProperties(@NotNull
@NotNull ExternalIdentity ext,
@NotNull
@NotNull Authorizable auth,
@NotNull
@NotNull 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(@NotNull
@NotNull Authorizable auth,
long expirationTime,
@NotNull
@NotNull 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@Nullable protected @Nullable Value createValue(@Nullable @Nullable Object v) throws RepositoryException
v - the valueRepositoryException - if an error occurs@Nullable protected @Nullable Value[] createValues(@NotNull @NotNull Collection<?> propValues) throws RepositoryException
propValues - the given valuesRepositoryException - if an error occursprotected boolean isSameIDP(@Nullable
@Nullable Authorizable auth)
throws RepositoryException
auth - the authorizable.true if same IDP.RepositoryExceptionprotected boolean isSameIDP(@NotNull
@NotNull 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–2018 The Apache Software Foundation. All rights reserved.