// Path: src/main/java/javapns/communication/exceptions/InvalidKeystoreFormatException.java
// public class InvalidKeystoreFormatException extends KeystoreException {
// 
//   private static final long serialVersionUID = 8822634206752412121L;
// 
//   /**
//    * Constructor
//    */
//   public InvalidKeystoreFormatException() {
//     super("Invalid keystore format!  Make sure it is PKCS12...");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public InvalidKeystoreFormatException(final String message) {
//     super(message);
//   }
// 
// }
// 
// Path: src/main/java/javapns/communication/exceptions/InvalidKeystorePasswordException.java
// public class InvalidKeystorePasswordException extends KeystoreException {
// 
//   private static final long serialVersionUID = 5973743951334025887L;
// 
//   /**
//    * Constructor
//    */
//   public InvalidKeystorePasswordException() {
//     super("Invalid keystore password!  Verify settings for connecting to Apple...");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public InvalidKeystorePasswordException(final String message) {
//     super(message);
//   }
// 
// }
// 
// 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.InvalidKeystoreFormatException;
import javapns.communication.exceptions.InvalidKeystorePasswordException;
import javapns.communication.exceptions.InvalidKeystoreReferenceException;
import javapns.communication.exceptions.KeystoreException;
import java.io.*;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509Certificate;
import java.util.Enumeration;
        return new ByteArrayInputStream((byte[]) keystore);
      } else {
        return null; // we should not get here since validateKeystore ensures that the reference is valid
      }
    } catch (final Exception e) {
      throw new InvalidKeystoreReferenceException("Invalid keystore reference: " + e.getMessage());
    }
  }

  /**
   * Ensures that a keystore parameter is actually supported by the KeystoreManager.
   *
   * @param keystore a keystore containing your private key and the certificate signed by Apple (File, InputStream, byte[], KeyStore or String for a file path)
   * @throws InvalidKeystoreReferenceException thrown if the provided keystore parameter is not supported
   */
  public static void validateKeystoreParameter(Object keystore) throws InvalidKeystoreReferenceException {
    if (keystore == null) {
      throw new InvalidKeystoreReferenceException((Object) null);
    }
    if (keystore instanceof KeyStore) {
      return;
    }
    if (keystore instanceof InputStream) {
      return;
    }
    if (keystore instanceof String) {
      validateFileKeystore(new File((String) keystore));
      return;
    }
    if (keystore instanceof File) {
// Path: src/main/java/javapns/communication/exceptions/InvalidKeystoreFormatException.java
// public class InvalidKeystoreFormatException extends KeystoreException {
// 
//   private static final long serialVersionUID = 8822634206752412121L;
// 
//   /**
//    * Constructor
//    */
//   public InvalidKeystoreFormatException() {
//     super("Invalid keystore format!  Make sure it is PKCS12...");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public InvalidKeystoreFormatException(final String message) {
//     super(message);
//   }
// 
// }
// 
// Path: src/main/java/javapns/communication/exceptions/InvalidKeystorePasswordException.java
// public class InvalidKeystorePasswordException extends KeystoreException {
// 
//   private static final long serialVersionUID = 5973743951334025887L;
// 
//   /**
//    * Constructor
//    */
//   public InvalidKeystorePasswordException() {
//     super("Invalid keystore password!  Verify settings for connecting to Apple...");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public InvalidKeystorePasswordException(final String message) {
//     super(message);
//   }
// 
// }
// 
// 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/KeystoreManager.java
import javapns.communication.exceptions.InvalidKeystoreFormatException;
import javapns.communication.exceptions.InvalidKeystorePasswordException;
import javapns.communication.exceptions.InvalidKeystoreReferenceException;
import javapns.communication.exceptions.KeystoreException;
import java.io.*;
import java.security.KeyStore;
import java.security.cert.Certificate;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509Certificate;
import java.util.Enumeration;

        return new ByteArrayInputStream((byte[]) keystore);
      } else {
        return null; // we should not get here since validateKeystore ensures that the reference is valid
      }
    } catch (final Exception e) {
      throw new InvalidKeystoreReferenceException("Invalid keystore reference: " + e.getMessage());
    }
  }

  /**
   * Ensures that a keystore parameter is actually supported by the KeystoreManager.
   *
   * @param keystore a keystore containing your private key and the certificate signed by Apple (File, InputStream, byte[], KeyStore or String for a file path)
   * @throws InvalidKeystoreReferenceException thrown if the provided keystore parameter is not supported
   */
  public static void validateKeystoreParameter(Object keystore) throws InvalidKeystoreReferenceException {
    if (keystore == null) {
      throw new InvalidKeystoreReferenceException((Object) null);
    }
    if (keystore instanceof KeyStore) {
      return;
    }
    if (keystore instanceof InputStream) {
      return;
    }
    if (keystore instanceof String) {
      validateFileKeystore(new File((String) keystore));
      return;
    }
    if (keystore instanceof File) {
      validateFileKeystore((File) keystore);