DefaultSyncContext implements SyncContext { @NotNull protected User createUser(@NotNull ExternalUser externalUser) throws RepositoryException { Principal principal = new PrincipalImpl(externalUser.getPrincipalName()); String authId = config.user().isApplyRFC7613UsernameCaseMapped() ? normalize(externalUser.getId().toLowerCase(), NFKC) : externalUser.getId(); User user = userManager.createUser( authId, null, principal, PathUtils.concatRelativePaths(config.user().getPathPrefix(), externalUser.getIntermediatePath()) ); setExternalId(user, externalUser); return user; } DefaultSyncContext(@NotNull DefaultSyncConfig config, @NotNull ExternalIdentityProvider idp, @NotNull UserManager userManager, @NotNull ValueFactory valueFactory); @Nullable static DefaultSyncedIdentity createSyncedIdentity(@Nullable Authorizable auth); @Nullable static ExternalIdentityRef getIdentityRef(@Nullable Authorizable auth); static String joinPaths(String... paths); @Override void close(); @Override boolean isKeepMissing(); @NotNull @Override SyncContext setKeepMissing(boolean keepMissing); @Override boolean isForceUserSync(); @NotNull @Override SyncContext setForceUserSync(boolean forceUserSync); @Override boolean isForceGroupSync(); @Override @NotNull SyncContext setForceGroupSync(boolean forceGroupSync); @NotNull @Override SyncResult sync(@NotNull ExternalIdentity identity); @NotNull @Override SyncResult sync(@NotNull String id); static final String REP_EXTERNAL_ID; static final String REP_LAST_SYNCED; }
@Test public void testCreateUserWithApplyRFC7613() throws Exception { syncCtx.config.user().setApplyRFC7613UsernameCaseMapped(true); String id = "\uff21\uff4d\uff41\uff4c\uff49\uff41\u017F"; User user = syncCtx.createUser(new TestIdentityProvider.TestUser(id, idp.getName())); assertEquals(Normalizer.normalize(id.toLowerCase(), Normalizer.Form.NFKC), user.getID()); }