code: private void updatePrincipal() {
  
          principal = new JsonObject();
          profiles.forEach((name, profile) -> {
              final JsonObject jsonProfile = new JsonObject();
              profile.getAttributes()
                      .forEach((attributeName, attributeValue) ->
                              jsonProfile.put(attributeName, attributeValue.toString()));
              principal.put(name, jsonProfile);
          });
      }
docs: Update the principal, to be called on any modification of the profiles map internally.