
package de.ivu.elect.business.system.control;

import java.util.Collection;

import de.ivu.elect.business.konfiguration.control.AbstractKonfigurationInit;
import de.ivu.elect.business.konfiguration.entity.ElectKonfigurationWerte;
import de.ivu.elect.business.konfiguration.entity.Konfiguration;
import de.ivu.elect.business.konfiguration.entity.KonfigurationInitContext;
import de.ivu.elect.business.konfiguration.entity.MandantKonfigurationWerte;
import de.ivu.elect.business.system.entity.HttpSessionTracking;


import static java.util.Arrays.asList;

public class HttpSessionKonfigurationInit extends AbstractKonfigurationInit {

  public static final int DEFAULT_SESSION_TIMEOUT_IN_MINUTES = 30;

  public HttpSessionKonfigurationInit() {
    super();
  }

  @Override
  protected Collection<Konfiguration> createDefaultParameters(KonfigurationInitContext konfigurationInitContext) {
    return asList( //
        create(MandantKonfigurationWerte.HTTP_SESSION_TIMEOUT_IN_MINUTEN, getDefaultSessionTimeoutInMinutes()), //
        create(ElectKonfigurationWerte.HTTP_SESSION_TRACKING_MODE, getDefaultSessionTrackingMode().name()), //
        create(ElectKonfigurationWerte.HTTP_LOGGING_LOGIN_ACCESS, getDefaultLoggingLoginAccess()), //
        create(ElectKonfigurationWerte.HTTP_SESSION_COOKIE_CONFIG_HTTP_ONLY, getDefaultCookieConfigHttpOnly()), //
        create(ElectKonfigurationWerte.HTTP_SESSION_COOKIE_CONFIG_SECURE, getDefaultCookieSecureOnly()) //
    );
  }

  protected Boolean getDefaultLoggingLoginAccess() {
    return Boolean.FALSE;
  }

  protected int getDefaultSessionTimeoutInMinutes() {
    return DEFAULT_SESSION_TIMEOUT_IN_MINUTES;
  }

  protected HttpSessionTracking getDefaultSessionTrackingMode() {
    return HttpSessionTracking.DEFAULT;
  }

  protected Boolean getDefaultCookieConfigHttpOnly() {
    return Boolean.TRUE;
  }

  protected Boolean getDefaultCookieSecureOnly() {
    return Boolean.FALSE;
  }
}
