@Override
    public void ensureUserIdentity(final UserDesc userDesc) {
        if (!securityContext.hasAppPermission(AppPermission.MANAGE_USERS_PERMISSION)) {
            throw new PermissionException(securityContext.getUserRef(),
                    "You are not authorised to ensure a stroom user.");
        }
        NullSafe.requireNonNull(userDesc, UserDesc::getSubjectId, () -> "subjectId required");
        final UserService userService = userServiceProvider.get();
        final String newDisplayName = userDesc.getDisplayName();
        final String newFullName = userDesc.getFullName();

        final User user = userService.getOrCreateUser(userDesc);

        if (!Objects.equals(newDisplayName, user.getDisplayName())
            || !Objects.equals(newFullName, user.getFullName())) {

            LOGGER.debug("Updating user {} with displayName: '{}' and fullName: '{}'",
                    user, newDisplayName, newFullName);
            user.setDisplayName(newDisplayName);
            user.setFullName(newFullName);
            userService.update(user);
        }
    }
Gets a user from the cache and if it doesn't exist creates it in the database.

@param subjectId This is the unique identifier for the user that links the stroom user
                 to an IDP user, e.g. may be the 'sub' on the IDP depending on stroom config.
stroom-security/stroom-security-impl/src/main/java/stroom/security/impl/StroomUserIdentityFactory.java