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 javax.jcr.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 org.apache.jackrabbit.api.security.user.UserManager |
userManager |
protected javax.jcr.ValueFactory |
valueFactory |
| Constructor and Description |
|---|
DefaultSyncContext(DefaultSyncConfig config,
ExternalIdentityProvider idp,
org.apache.jackrabbit.api.security.user.UserManager userManager,
javax.jcr.ValueFactory valueFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyMembership(org.apache.jackrabbit.api.security.user.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 org.apache.jackrabbit.api.security.user.Group |
createGroup(ExternalGroup externalGroup)
Creates a new repository group for the given external one.
|
static DefaultSyncedIdentity |
createSyncedIdentity(org.apache.jackrabbit.api.security.user.Authorizable auth)
Creates a synced identity from the given authorizable.
|
protected org.apache.jackrabbit.api.security.user.User |
createUser(ExternalUser externalUser)
Creates a new repository user for the given external one.
|
protected javax.jcr.Value |
createValue(Object v)
Creates a new JCR value of the given object, checking the internal type.
|
protected javax.jcr.Value[] |
createValues(Collection<?> propValues)
Creates an array of JCR values based on the type.
|
protected <T extends org.apache.jackrabbit.api.security.user.Authorizable> |
getAuthorizable(ExternalIdentity external,
Class<T> type)
Retrieves the repository authorizable that corresponds to the given external identity
|
static ExternalIdentityRef |
getIdentityRef(org.apache.jackrabbit.api.security.user.Authorizable auth)
Retrieves the external identity ref from the authorizable
|
protected boolean |
isExpired(org.apache.jackrabbit.api.security.user.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(org.apache.jackrabbit.api.security.user.Authorizable auth)
Checks if the given authorizable was synced from the same IDP by comparing the IDP name of the
"rep:externalId" property.
|
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,
org.apache.jackrabbit.api.security.user.Group group) |
protected void |
syncMembership(ExternalIdentity external,
org.apache.jackrabbit.api.security.user.Authorizable auth,
long depth)
Recursively sync the memberships of an authorizable up-to the specified depth.
|
protected void |
syncProperties(ExternalIdentity ext,
org.apache.jackrabbit.api.security.user.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,
org.apache.jackrabbit.api.security.user.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 org.apache.jackrabbit.api.security.user.UserManager userManager
protected final javax.jcr.ValueFactory valueFactory
protected boolean keepMissing
protected boolean forceUserSync
protected boolean forceGroupSync
protected final long now
protected final javax.jcr.Value nowValue
public DefaultSyncContext(@Nonnull DefaultSyncConfig config, @Nonnull ExternalIdentityProvider idp, @Nonnull org.apache.jackrabbit.api.security.user.UserManager userManager, @Nonnull javax.jcr.ValueFactory valueFactory)
@CheckForNull public static DefaultSyncedIdentity createSyncedIdentity(@Nullable org.apache.jackrabbit.api.security.user.Authorizable auth) throws javax.jcr.RepositoryException
auth - the authorizablejavax.jcr.RepositoryException - if an error occurs@CheckForNull public static ExternalIdentityRef getIdentityRef(@Nullable org.apache.jackrabbit.api.security.user.Authorizable auth) throws javax.jcr.RepositoryException
auth - the authorizablejavax.jcr.RepositoryException - 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 occurrs@CheckForNull protected <T extends org.apache.jackrabbit.api.security.user.Authorizable> T getAuthorizable(@Nonnull ExternalIdentity external, @Nonnull Class<T> type) throws javax.jcr.RepositoryException, SyncException
external - the external identitytype - the authorizable typenull if not found.javax.jcr.RepositoryException - if an error occurs.SyncException - if the repository contains a colliding authorizable with the same name.@Nonnull protected org.apache.jackrabbit.api.security.user.User createUser(@Nonnull ExternalUser externalUser) throws javax.jcr.RepositoryException
externalUser - the external userjavax.jcr.RepositoryException - if an error occurs@Nonnull protected org.apache.jackrabbit.api.security.user.Group createGroup(@Nonnull ExternalGroup externalGroup) throws javax.jcr.RepositoryException
externalGroup - the external groupjavax.jcr.RepositoryException - if an error occurs@Nonnull protected DefaultSyncResultImpl syncUser(@Nonnull ExternalUser external, @Nonnull org.apache.jackrabbit.api.security.user.User user) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException@Nonnull protected DefaultSyncResultImpl syncGroup(@Nonnull ExternalGroup external, @Nonnull org.apache.jackrabbit.api.security.user.Group group) throws javax.jcr.RepositoryException
javax.jcr.RepositoryExceptionprotected void syncMembership(@Nonnull ExternalIdentity external, @Nonnull org.apache.jackrabbit.api.security.user.Authorizable auth, long depth) throws javax.jcr.RepositoryException
external - the external identityauth - the authorizabledepth - recursion depth.javax.jcr.RepositoryExceptionprotected void applyMembership(@Nonnull org.apache.jackrabbit.api.security.user.Authorizable member, @Nonnull Set<String> groups) throws javax.jcr.RepositoryException
member - the authorizablegroups - set of groups.javax.jcr.RepositoryExceptionprotected void syncProperties(@Nonnull ExternalIdentity ext, @Nonnull org.apache.jackrabbit.api.security.user.Authorizable auth, @Nonnull Map<String,String> mapping) throws javax.jcr.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 mappingjavax.jcr.RepositoryException - if an error occursprotected boolean isExpired(@Nonnull org.apache.jackrabbit.api.security.user.Authorizable auth, long expirationTime, @Nonnull String type) throws javax.jcr.RepositoryException
REP_LAST_SYNCED property.auth - the authorizable to checkexpirationTime - the expiration time to compare to.type - debug message typetrue if the authorizable needs syncjavax.jcr.RepositoryException@CheckForNull protected javax.jcr.Value createValue(@Nullable Object v) throws javax.jcr.RepositoryException
v - the valuejavax.jcr.RepositoryException - if an error occurs@CheckForNull protected javax.jcr.Value[] createValues(@Nonnull Collection<?> propValues) throws javax.jcr.RepositoryException
propValues - the given valuesjavax.jcr.RepositoryException - if an error occursprotected boolean isSameIDP(@Nullable org.apache.jackrabbit.api.security.user.Authorizable auth) throws javax.jcr.RepositoryException
auth - the authorizable.true if same IDP.javax.jcr.RepositoryExceptionCopyright © 2012-2016 The Apache Software Foundation. All Rights Reserved.