code: protected Map<String, Object> convertProfileAndPasswordToAttributes(final U profile, final String password) {
          final Map<String, Object> storageAttributes = new HashMap<>();
          storageAttributes.put(getIdAttribute(), profile.getId());
          storageAttributes.put(LINKEDID, profile.getLinkedId());
          storageAttributes.put(getUsernameAttribute(), profile.getUsername());
          // if a password has been provided, encode it
          if (isNotBlank(password)) {
              final String encodedPassword;
              // encode password if we have a passwordEncoder (MongoDB, SQL but not for LDAP)
              if (passwordEncoder != null) {
                  encodedPassword = passwordEncoder.encode(password);
              } else {
                  encodedPassword = password;
              }
              storageAttributes.put(getPasswordAttribute(), encodedPassword);
          }
          // legacy mode: save the defined attributes
          if (isLegacyMode()) {
              for (final String attributeName : attributeNames) {
                  storageAttributes.put(attributeName, profile.getAttribute(attributeName));
              }
          } else {
              // new behaviour (>= v2.0): save the serialized profile
              storageAttributes.put(SERIALIZED_PROFILE, javaSerializationHelper.serializeToBase64(profile));
          }
          return storageAttributes;
      }
docs: Convert a profile and a password into a map of attributes for the storage.
  
  @param profile the profile
  @param password the password
  @return the attributes