private void addOrUpdateLocalAuthenticationSource(boolean asUserAdministrator, UserEntity subjectUserEntity, String password, String oldPassword)
      throws AuthorizationException, AmbariException {
    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(Resource.Type.UserAuthenticationSource,
        getManagementController());

    if (provider != null) {
      // Determine if the user already has an LOCAL authentication source setup...
      UserAuthenticationEntity userAuthenticationEntity = null;
      List<UserAuthenticationEntity> authenticationEntities = subjectUserEntity.getAuthenticationEntities();
      for (UserAuthenticationEntity authenticationEntity : authenticationEntities) {
        if (authenticationEntity.getAuthenticationType() == UserAuthenticationType.LOCAL) {
          userAuthenticationEntity = authenticationEntity;
          break;
        }
      }
      if (userAuthenticationEntity == null) {
        // a new authentication source needs to be create... only a privileged user can do this...
        if (!asUserAdministrator) {
          throw new AuthorizationException("The authenticated user is not authorized to create a local authentication source.");
        } else {
          Set<Map<String, Object>> propertiesSet = new HashSet<>();
          Map<String, Object> properties;
          properties = new LinkedHashMap<>();
          properties.put(UserAuthenticationSourceResourceProvider.AUTHENTICATION_USER_NAME_PROPERTY_ID, subjectUserEntity.getUserName());
          properties.put(UserAuthenticationSourceResourceProvider.AUTHENTICATION_AUTHENTICATION_TYPE_PROPERTY_ID, UserAuthenticationType.LOCAL.name());
          properties.put(UserAuthenticationSourceResourceProvider.AUTHENTICATION_KEY_PROPERTY_ID, password);
          propertiesSet.add(properties);

          try {
            provider.createResources(PropertyHelper.getCreateRequest(propertiesSet, null));
          } catch (Exception e) {
            throw new AmbariException(e.getMessage(), e);
          }
        }
      } else {
        Map<String, Object> properties = new LinkedHashMap<>();
        properties.put(UserAuthenticationSourceResourceProvider.AUTHENTICATION_OLD_KEY_PROPERTY_ID, oldPassword);
        properties.put(UserAuthenticationSourceResourceProvider.AUTHENTICATION_KEY_PROPERTY_ID, password);

        Predicate predicate1 = new PredicateBuilder()
            .property(UserAuthenticationSourceResourceProvider.AUTHENTICATION_USER_NAME_PROPERTY_ID)
            .equals(subjectUserEntity.getUserName())
            .toPredicate();
        Predicate predicate2 = new PredicateBuilder()
            .property(UserAuthenticationSourceResourceProvider.AUTHENTICATION_AUTHENTICATION_SOURCE_ID_PROPERTY_ID)
            .equals(convertIdToString(userAuthenticationEntity.getUserAuthenticationId()))
            .toPredicate();

        try {
          provider.updateResources(PropertyHelper.getUpdateRequest(properties, null), new AndPredicate(predicate1, predicate2));
        } catch (Exception e) {
          throw new AmbariException(e.getMessage(), e);
        }
      }
    }
  }
Adds to updates a user's local authentication source by issuing a call to the {@link UserAuthenticationSourceResourceProvider}.
<p>
This is for backward compatibility to maintain the contract for Ambari's REST API version V1.

@param asUserAdministrator true if the authenticated user have privs to manage user; false otherwise
@param subjectUserEntity   the user to update
@param password            the password to set, it is expected that this value is not <code>null</code>
@param oldPassword         the old/current password to use for verification is needed, this value may be <code>null</code>
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java