// Path: ocpp-common/src/main/java/eu/chargetime/ocpp/model/SessionInformation.java
// public class SessionInformation {
// 
//   private String identifier;
//   private InetSocketAddress address;
//   private String SOAPtoURL;
//   private String proxiedAddress;
// 
//   public String getIdentifier() {
//     return identifier;
//   }
// 
//   public InetSocketAddress getAddress() {
//     return address;
//   }
// 
//   public String getSOAPtoURL() {
//     return SOAPtoURL;
//   }
// 
//   public String getProxiedAddress() {
//     return proxiedAddress;
//   }
// 
//   public static class Builder {
// 
//     private String identifier;
//     private InetSocketAddress address;
//     private String SOAPtoURL;
//     private String proxiedAddress;
// 
//     public Builder Identifier(String identifier) {
//       this.identifier = identifier;
//       return this;
//     }
// 
//     public Builder InternetAddress(InetSocketAddress address) {
//       this.address = address;
//       return this;
//     }
// 
//     public Builder ProxiedAddress(String proxiedAddress) {
//       this.proxiedAddress = proxiedAddress;
//       return this;
//     }
// 
//     public SessionInformation build() {
//       SessionInformation sessionInformation = new SessionInformation();
//       sessionInformation.identifier = this.identifier;
//       sessionInformation.address = this.address;
//       sessionInformation.SOAPtoURL = this.SOAPtoURL;
//       sessionInformation.proxiedAddress = this.proxiedAddress;
//       return sessionInformation;
//     }
// 
//     public Builder SOAPtoURL(String toUrl) {
//       this.SOAPtoURL = toUrl;
//       return this;
//     }
//   }
// }


import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.chargetime.ocpp.feature.Feature;
import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;
import eu.chargetime.ocpp.model.SessionInformation;
import java.util.Map;
package eu.chargetime.ocpp;
/*
   ChargeTime.eu - Java-OCA-OCPP

   MIT License

   Copyright (C) 2016-2018 Thomas Volden <tv@chargetime.eu>

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all
   copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE.
*/


/**
 * Handles basic server logic: Holds a list of supported features. Keeps track of outgoing requests.
 * Calls back when a confirmation is received.
 */
public class Server {

  private static final Logger logger = LoggerFactory.getLogger(Server.class);

  public static final int INITIAL_SESSIONS_NUMBER = 1000;

  private Map<UUID, ISession> sessions;
  private Listener listener;
  private final IFeatureRepository featureRepository;
  private final IPromiseRepository promiseRepository;

  /**
   * Constructor. Handles the required injections.
   *
   * @param listener injected listener.
   */
  public Server(
      Listener listener,
      IFeatureRepository featureRepository,
      IPromiseRepository promiseRepository) {
    this.listener = listener;
    this.featureRepository = featureRepository;
    this.promiseRepository = promiseRepository;
    this.sessions = new ConcurrentHashMap<>(INITIAL_SESSIONS_NUMBER);
  }

  /**
   * Start listening for clients.
   *
   * @param hostname Url or IP of the server as String.
   * @param port the port number of the server.
   * @param serverEvents Callback handler for server specific events.
   */
  public void open(String hostname, int port, ServerEvents serverEvents) {

    listener.open(
        hostname,
        port,
        new ListenerEvents() {

          @Override
          public void authenticateSession(
// Path: ocpp-common/src/main/java/eu/chargetime/ocpp/model/SessionInformation.java
// public class SessionInformation {
// 
//   private String identifier;
//   private InetSocketAddress address;
//   private String SOAPtoURL;
//   private String proxiedAddress;
// 
//   public String getIdentifier() {
//     return identifier;
//   }
// 
//   public InetSocketAddress getAddress() {
//     return address;
//   }
// 
//   public String getSOAPtoURL() {
//     return SOAPtoURL;
//   }
// 
//   public String getProxiedAddress() {
//     return proxiedAddress;
//   }
// 
//   public static class Builder {
// 
//     private String identifier;
//     private InetSocketAddress address;
//     private String SOAPtoURL;
//     private String proxiedAddress;
// 
//     public Builder Identifier(String identifier) {
//       this.identifier = identifier;
//       return this;
//     }
// 
//     public Builder InternetAddress(InetSocketAddress address) {
//       this.address = address;
//       return this;
//     }
// 
//     public Builder ProxiedAddress(String proxiedAddress) {
//       this.proxiedAddress = proxiedAddress;
//       return this;
//     }
// 
//     public SessionInformation build() {
//       SessionInformation sessionInformation = new SessionInformation();
//       sessionInformation.identifier = this.identifier;
//       sessionInformation.address = this.address;
//       sessionInformation.SOAPtoURL = this.SOAPtoURL;
//       sessionInformation.proxiedAddress = this.proxiedAddress;
//       return sessionInformation;
//     }
// 
//     public Builder SOAPtoURL(String toUrl) {
//       this.SOAPtoURL = toUrl;
//       return this;
//     }
//   }
// }


// Path: ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.chargetime.ocpp.feature.Feature;
import eu.chargetime.ocpp.model.Confirmation;
import eu.chargetime.ocpp.model.Request;
import eu.chargetime.ocpp.model.SessionInformation;
import java.util.Map;

package eu.chargetime.ocpp;
/*
   ChargeTime.eu - Java-OCA-OCPP

   MIT License

   Copyright (C) 2016-2018 Thomas Volden <tv@chargetime.eu>

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all
   copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE.
*/


/**
 * Handles basic server logic: Holds a list of supported features. Keeps track of outgoing requests.
 * Calls back when a confirmation is received.
 */
public class Server {

  private static final Logger logger = LoggerFactory.getLogger(Server.class);

  public static final int INITIAL_SESSIONS_NUMBER = 1000;

  private Map<UUID, ISession> sessions;
  private Listener listener;
  private final IFeatureRepository featureRepository;
  private final IPromiseRepository promiseRepository;

  /**
   * Constructor. Handles the required injections.
   *
   * @param listener injected listener.
   */
  public Server(
      Listener listener,
      IFeatureRepository featureRepository,
      IPromiseRepository promiseRepository) {
    this.listener = listener;
    this.featureRepository = featureRepository;
    this.promiseRepository = promiseRepository;
    this.sessions = new ConcurrentHashMap<>(INITIAL_SESSIONS_NUMBER);
  }

  /**
   * Start listening for clients.
   *
   * @param hostname Url or IP of the server as String.
   * @param port the port number of the server.
   * @param serverEvents Callback handler for server specific events.
   */
  public void open(String hostname, int port, ServerEvents serverEvents) {

    listener.open(
        hostname,
        port,
        new ListenerEvents() {

          @Override
          public void authenticateSession(
              SessionInformation information, String username, byte[] password)