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

import java.io.Serializable;

import javax.enterprise.event.Event;
import javax.inject.Inject;

import de.ivu.elect.business.benutzerverwaltung.entity.BenutzerPK;
import de.ivu.elect.jee.security.IpHostname;

public class NlAirGapStatusEvent implements Serializable {

  private static final long serialVersionUID = 1L;

  private Boolean systemAirGapFailed;

  private Boolean clientAirgapFailed;

  private IpHostname clientIp;

  private BenutzerPK clientUser;

  private String sessionId;

  protected NlAirGapStatusEvent() {
  }

  public NlAirGapStatusEvent(Boolean systemAirGapFailed) {
    this.systemAirGapFailed = systemAirGapFailed;
  }

  public NlAirGapStatusEvent(Boolean clientAirgapFailed, IpHostname clientIp, BenutzerPK clientUser, String sessionId) {
    this.clientAirgapFailed = clientAirgapFailed;
    this.clientIp = clientIp;
    this.clientUser = clientUser;
    this.sessionId = sessionId;
  }

  @Inject
  private transient Event<NlAirGapStatusEvent> event;

  public void sendServerAirGapEvent(boolean systemAirGapFailed) {
    event.fire(new NlAirGapStatusEvent(systemAirGapFailed));
  }

  public void sendClientAirGapEvent(IpHostname clientIp, BenutzerPK clientUser, String sessionId) {
    event.fire(new NlAirGapStatusEvent(true, clientIp, clientUser, sessionId));
  }

  public Boolean getSystemAirGapFailed() {
    return systemAirGapFailed;
  }

  public Boolean getClientAirgapFailed() {
    return clientAirgapFailed;
  }

  public IpHostname getClientIp() {
    return clientIp;
  }

  public BenutzerPK getClientUser() {
    return clientUser;
  }

  public String getSessionId() {
    return sessionId;
  }
}
