private ArrayList<String> activeSocialStrategies() {
   Configuration configuration = lock.getConfiguration();
   ArrayList<String> strategies = new ArrayList<>(configuration.getSocialStrategies().size());
   for (Strategy strategy : configuration.getSocialStrategies()) {
     strategies.add(strategy.getName());
   }
   return strategies;
 }
  public Fragment root() {
    Configuration configuration = lock.getConfiguration();
    if (lock.getConfiguration() == null) {
      return login();
    }

    if (signUpMode) {
      return SocialSignUpFragment.newFragment(activeSocialStrategies());
    }

    final boolean hasEnterprise = !configuration.getEnterpriseStrategies().isEmpty();
    final boolean hasSocial = !configuration.getSocialStrategies().isEmpty();
    final boolean hasDB = configuration.getDefaultDatabaseConnection() != null;
    final boolean hasAD = configuration.getActiveDirectoryStrategy() != null;

    if (!hasDB && hasSocial && !hasEnterprise) {
      return social();
    }

    if (!hasDB && hasSocial && hasAD) {
      return enterpriseLoginWithSocial(configuration.getDefaultActiveDirectoryConnection());
    }

    if ((hasDB || hasEnterprise) && hasSocial) {
      return loginWithSocial();
    }

    if (!hasDB && hasAD) {
      return enterpriseLoginWithConnection(
          configuration.getDefaultActiveDirectoryConnection(), true);
    }

    return login();
  }