private void createUserAuthenticationSources(Set<UserAuthenticationSourceRequest> requests) throws AmbariException {
    for (UserAuthenticationSourceRequest request : requests) {
      String username = request.getUsername();
      if (StringUtils.isEmpty(username)) {
        throw new AmbariException("Username must be supplied.");
      }

      UserAuthenticationType authenticationType = request.getAuthenticationType();
      if (authenticationType == null) {
        throw new AmbariException("A value authentication type must be supplied.");
      }

      UserEntity userEntity = users.getUserEntity(username);
      if (userEntity == null) {
        throw new AmbariException("There is no user with the supplied username");
      }

      users.addAuthentication(userEntity, authenticationType, request.getKey());
    }
  }
Creates user authentication sources.

@param requests the request objects which define the user authentication source.
@throws AmbariException when the user authentication source cannot be created.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserAuthenticationSourceResourceProvider.java