use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity 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()]);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity 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);
}
Aggregations