code: public static CommonProfile restoreOrBuildProfile(final ProfileDefinition<? extends CommonProfile> profileDefinition,
              final String typedId, final Map<String, Object> profileAttributes, final Map<String, Object> authenticationAttributes,
              final Object... parameters) {
          if (CommonHelper.isBlank(typedId)) {
              return null;
          }
  
          logger.info("Building user profile based on typedId: {}", typedId);
          final CommonProfile profile;
          if (typedId.contains(CommonProfile.SEPARATOR)) {
              final String className = CommonHelper.substringBefore(typedId, CommonProfile.SEPARATOR);
              try {
                  profile = buildUserProfileByClassCompleteName(className);
              } catch (final TechnicalException e) {
                  logger.error("Cannot build instance for class name: {}", className, e);
                  return null;
              }
              profile.addAttributes(profileAttributes);
              profile.addAuthenticationAttributes(authenticationAttributes);
          } else {
              profile = profileDefinition.newProfile(parameters);
              profileDefinition.convertAndAdd(profile, profileAttributes, authenticationAttributes);
          }
          profile.setId(ProfileHelper.sanitizeIdentifier(profile, typedId));
          return profile;
      }
docs: Restore or build a profile.
  
  @param profileDefinition the profile definition
  @param typedId the typed identifier
  @param profileAttributes The profile attributes. May be {@code null}.
  @param authenticationAttributes The authentication attributes. May be {@code null}.
  @param parameters additional parameters for the profile definition
  @return the restored or built profile