Search in sources :

Example 1 with DefaultSyncResultImpl

use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncResultImpl in project jackrabbit-oak by apache.

the class Delegatee method syncUser.

@Nonnull
private List<SyncResult> syncUser(@Nonnull ExternalIdentity id, @Nonnull List<SyncResult> results, @Nonnull List<String> list) {
    try {
        SyncResult r = context.sync(id);
        if (r.getIdentity() == null) {
            r = new DefaultSyncResultImpl(new DefaultSyncedIdentity(id.getId(), id.getExternalId(), false, -1), SyncResult.Status.NO_SUCH_IDENTITY);
            log.warn("sync failed. {}", r.getIdentity());
        } else {
            log.info("synced {}", r.getIdentity());
        }
        results.add(r);
    } catch (SyncException e) {
        log.error(ERROR_SYNC_USER, id, e);
        results.add(new ErrorSyncResult(id.getExternalId(), e));
    }
    return commit(list, results, batchSize);
}
Also used : DefaultSyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity) DefaultSyncResultImpl(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncResultImpl) SyncException(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncException) SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) Nonnull(javax.annotation.Nonnull)

Example 2 with DefaultSyncResultImpl

use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncResultImpl in project jackrabbit-oak by apache.

the class Delegatee method syncExternalUsers.

/**
 * @see SynchronizationMBean#syncExternalUsers(String[])
 */
@Nonnull
String[] syncExternalUsers(@Nonnull String[] externalIds) {
    List<String> list = new ArrayList<String>();
    context.setForceGroupSync(true).setForceUserSync(true);
    List<SyncResult> results = new ArrayList<SyncResult>(batchSize);
    for (String externalId : externalIds) {
        ExternalIdentityRef ref = ExternalIdentityRef.fromString(externalId);
        if (!idp.getName().equals(ref.getProviderName())) {
            results.add(new DefaultSyncResultImpl(new DefaultSyncedIdentity(ref.getId(), ref, false, -1), SyncResult.Status.FOREIGN));
        } else {
            try {
                ExternalIdentity id = idp.getIdentity(ref);
                if (id != null) {
                    results = syncUser(id, results, list);
                } else {
                    results.add(new DefaultSyncResultImpl(new DefaultSyncedIdentity("", ref, false, -1), SyncResult.Status.NO_SUCH_IDENTITY));
                }
            } catch (ExternalIdentityException e) {
                log.warn("error while fetching the external identity {}", externalId, e);
                results.add(new ErrorSyncResult(ref, e));
            }
        }
    }
    commit(list, results, NO_BATCH_SIZE);
    return list.toArray(new String[list.size()]);
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ArrayList(java.util.ArrayList) DefaultSyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) DefaultSyncResultImpl(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncResultImpl) SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) ExternalIdentityException(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)2 SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)2 DefaultSyncResultImpl (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncResultImpl)2 DefaultSyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity)2 ArrayList (java.util.ArrayList)1 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)1 ExternalIdentityException (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException)1 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)1 SyncException (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncException)1