// Path: src/main/java/javapns/communication/exceptions/InvalidKeystoreReferenceException.java
// public class InvalidKeystoreReferenceException extends KeystoreException {
// 
//   private static final long serialVersionUID = 3144387163593035745L;
// 
//   /**
//    * Constructor
//    */
//   public InvalidKeystoreReferenceException() {
//     super("Invalid keystore parameter.  Must be InputStream, File, String (as a file path), or byte[].");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param keystore
//    */
//   public InvalidKeystoreReferenceException(final Object keystore) {
//     super("Invalid keystore parameter (" + keystore + ").  Must be InputStream, File, String (as a file path), or byte[].");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public InvalidKeystoreReferenceException(final String message) {
//     super(message);
//   }
// }
// 
// Path: src/main/java/javapns/communication/exceptions/KeystoreException.java
// public class KeystoreException extends Exception {
// 
//   private static final long serialVersionUID = 2549063865160633139L;
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public KeystoreException(final String message) {
//     super(message);
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public KeystoreException(final String message, final Exception cause) {
//     super(message, cause);
//   }
// 
// }


import javapns.communication.exceptions.InvalidKeystoreReferenceException;
import javapns.communication.exceptions.KeystoreException;
import java.io.InputStream;
package javapns.communication;



/**
 * A basic and abstract implementation of the AppleServer interface
 * intended to facilitate rapid deployment.
 *
 * @author Sylvain Pedneault
 */
public abstract class AppleServerBasicImpl implements AppleServer {
  private final String password;
  private final String type;
  private Object keystore;
  private String proxyHost;
  private int proxyPort;

  /**
   * Constructs a AppleServerBasicImpl object.
   *
   * @param keystore The keystore to use (can be a File, an InputStream, a String for a file path, or a byte[] array)
   * @param password The keystore's password
   * @param type     The keystore type (typically PKCS12)
   * @throws KeystoreException thrown if an error occurs when loading the keystore
   */
  protected AppleServerBasicImpl(final Object keystore, final String password, final String type) throws KeystoreException {
    KeystoreManager.validateKeystoreParameter(keystore);
    this.keystore = keystore;
    this.password = password;
    this.type = type;

    /* Make sure that the keystore reference is reusable. */
    this.keystore = KeystoreManager.ensureReusableKeystore(this, this.keystore);
  }

// Path: src/main/java/javapns/communication/exceptions/InvalidKeystoreReferenceException.java
// public class InvalidKeystoreReferenceException extends KeystoreException {
// 
//   private static final long serialVersionUID = 3144387163593035745L;
// 
//   /**
//    * Constructor
//    */
//   public InvalidKeystoreReferenceException() {
//     super("Invalid keystore parameter.  Must be InputStream, File, String (as a file path), or byte[].");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param keystore
//    */
//   public InvalidKeystoreReferenceException(final Object keystore) {
//     super("Invalid keystore parameter (" + keystore + ").  Must be InputStream, File, String (as a file path), or byte[].");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public InvalidKeystoreReferenceException(final String message) {
//     super(message);
//   }
// }
// 
// Path: src/main/java/javapns/communication/exceptions/KeystoreException.java
// public class KeystoreException extends Exception {
// 
//   private static final long serialVersionUID = 2549063865160633139L;
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public KeystoreException(final String message) {
//     super(message);
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public KeystoreException(final String message, final Exception cause) {
//     super(message, cause);
//   }
// 
// }


// Path: src/main/java/javapns/communication/AppleServerBasicImpl.java
import javapns.communication.exceptions.InvalidKeystoreReferenceException;
import javapns.communication.exceptions.KeystoreException;
import java.io.InputStream;

package javapns.communication;



/**
 * A basic and abstract implementation of the AppleServer interface
 * intended to facilitate rapid deployment.
 *
 * @author Sylvain Pedneault
 */
public abstract class AppleServerBasicImpl implements AppleServer {
  private final String password;
  private final String type;
  private Object keystore;
  private String proxyHost;
  private int proxyPort;

  /**
   * Constructs a AppleServerBasicImpl object.
   *
   * @param keystore The keystore to use (can be a File, an InputStream, a String for a file path, or a byte[] array)
   * @param password The keystore's password
   * @param type     The keystore type (typically PKCS12)
   * @throws KeystoreException thrown if an error occurs when loading the keystore
   */
  protected AppleServerBasicImpl(final Object keystore, final String password, final String type) throws KeystoreException {
    KeystoreManager.validateKeystoreParameter(keystore);
    this.keystore = keystore;
    this.password = password;
    this.type = type;

    /* Make sure that the keystore reference is reusable. */
    this.keystore = KeystoreManager.ensureReusableKeystore(this, this.keystore);
  }

  public InputStream getKeystoreStream() throws InvalidKeystoreReferenceException {