// Path: src/main/java/com/google/enterprise/cloudsearch/sharepoint/SharePointUrl.java
// static String getCanonicalUrl(String url) {
//   if (!url.endsWith("/")) {
//     return url;
//   }
//   return url.substring(0, url.length() - 1);
// }


import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.enterprise.cloudsearch.sharepoint.SharePointUrl.Builder.getCanonicalUrl;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.enterprise.cloudsearch.sdk.InvalidConfigurationException;
import com.google.enterprise.cloudsearch.sdk.config.Configuration;
import com.google.enterprise.cloudsearch.sdk.identity.IdentitySourceConfiguration;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
 * Copyright 2018 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.enterprise.cloudsearch.sharepoint;



class SharePointConfiguration {
  private static final Logger log = Logger.getLogger(SharePointRepository.class.getName());
  private static final String DEFAULT_USER_NAME = isCredentialOptional() ? "" : null;
  private static final String DEFAULT_PASSWORD = isCredentialOptional() ? "" : null;

  private final SharePointUrl sharePointUrl;
  private final String virtualServerUrl;
  private final boolean siteCollectionOnly;
  private final ImmutableSet<String> siteCollectionsToInclude;
  private final String userName;
  private final String password;
  private final String sharePointUserAgent;
  private final int webservicesSocketTimeoutMills;
  private final int webservicesReadTimeoutMills;
  private final boolean performXmlValidation;
  private final boolean performBrowserLeniency;
  private final ImmutableMap<String, IdentitySourceConfiguration>
      referenceIdentitySourceConfiguration;
  private final boolean stripDomainInUserPrincipals;

  private static boolean isCredentialOptional() {
    return System.getProperty("os.name", "").contains("Windows");
  }

  enum SharePointDeploymentType {
    ONLINE,
    ON_PREMISES;
  }

  private final SharePointDeploymentType sharePointDeploymentType;

  public boolean isSiteCollectionIncluded(String siteCollectionUrl) {
    Preconditions.checkNotNull(siteCollectionUrl, "Site Collection URL may not be null");
// Path: src/main/java/com/google/enterprise/cloudsearch/sharepoint/SharePointUrl.java
// static String getCanonicalUrl(String url) {
//   if (!url.endsWith("/")) {
//     return url;
//   }
//   return url.substring(0, url.length() - 1);
// }


// Path: src/main/java/com/google/enterprise/cloudsearch/sharepoint/SharePointConfiguration.java
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.enterprise.cloudsearch.sharepoint.SharePointUrl.Builder.getCanonicalUrl;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.enterprise.cloudsearch.sdk.InvalidConfigurationException;
import com.google.enterprise.cloudsearch.sdk.config.Configuration;
import com.google.enterprise.cloudsearch.sdk.identity.IdentitySourceConfiguration;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * Copyright 2018 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.enterprise.cloudsearch.sharepoint;



class SharePointConfiguration {
  private static final Logger log = Logger.getLogger(SharePointRepository.class.getName());
  private static final String DEFAULT_USER_NAME = isCredentialOptional() ? "" : null;
  private static final String DEFAULT_PASSWORD = isCredentialOptional() ? "" : null;

  private final SharePointUrl sharePointUrl;
  private final String virtualServerUrl;
  private final boolean siteCollectionOnly;
  private final ImmutableSet<String> siteCollectionsToInclude;
  private final String userName;
  private final String password;
  private final String sharePointUserAgent;
  private final int webservicesSocketTimeoutMills;
  private final int webservicesReadTimeoutMills;
  private final boolean performXmlValidation;
  private final boolean performBrowserLeniency;
  private final ImmutableMap<String, IdentitySourceConfiguration>
      referenceIdentitySourceConfiguration;
  private final boolean stripDomainInUserPrincipals;

  private static boolean isCredentialOptional() {
    return System.getProperty("os.name", "").contains("Windows");
  }

  enum SharePointDeploymentType {
    ONLINE,
    ON_PREMISES;
  }

  private final SharePointDeploymentType sharePointDeploymentType;

  public boolean isSiteCollectionIncluded(String siteCollectionUrl) {
    Preconditions.checkNotNull(siteCollectionUrl, "Site Collection URL may not be null");
    String url = getCanonicalUrl(siteCollectionUrl);