Class ApnsSigningKey

    • Constructor Detail

      • ApnsSigningKey

        public ApnsSigningKey​(String keyId,
                              String teamId,
                              ECPrivateKey key)
                       throws NoSuchAlgorithmException,
                              InvalidKeyException
        Constructs a new signing key with the given key identifier, team identifier, and elliptic curve private key.
        Parameters:
        keyId - the ten-character, Apple-issued identifier for the key itself
        teamId - the ten-character, Apple-issued identifier for the team to which the key belongs
        key - the elliptic curve public key underpinning this verification key
        Throws:
        NoSuchAlgorithmException - if the "SHA256withECDSA" algorith is not supported by the JVM
        InvalidKeyException - if the given elliptic curve private key is invalid for any reason
    • Method Detail

      • getEncoded

        public byte[] getEncoded()
        Specified by:
        getEncoded in interface Key
      • loadFromPkcs8File

        public static ApnsSigningKey loadFromPkcs8File​(File pkcs8File,
                                                       String teamId,
                                                       String keyId)
                                                throws IOException,
                                                       NoSuchAlgorithmException,
                                                       InvalidKeyException
        Loads a signing key from the given PKCS#8 file.
        Parameters:
        pkcs8File - the file from which to load the key
        teamId - the ten-character, Apple-issued identifier for the team to which the key belongs
        keyId - the ten-character, Apple-issued identitifier for the key itself
        Returns:
        an APNs signing key with the given key ID and associated with the given team
        Throws:
        IOException - if a key could not be loaded from the given file for any reason
        NoSuchAlgorithmException - if the JVM does not support elliptic curve keys
        InvalidKeyException - if the loaded key is invalid for any reason
      • loadFromInputStream

        public static ApnsSigningKey loadFromInputStream​(InputStream inputStream,
                                                         String teamId,
                                                         String keyId)
                                                  throws IOException,
                                                         NoSuchAlgorithmException,
                                                         InvalidKeyException
        Loads a signing key from the given input stream.
        Parameters:
        inputStream - the input stream from which to load the key
        teamId - the ten-character, Apple-issued identifier for the team to which the key belongs
        keyId - the ten-character, Apple-issued identitifier for the key itself
        Returns:
        an APNs signing key with the given key ID and associated with the given team
        Throws:
        IOException - if a key could not be loaded from the given file for any reason
        NoSuchAlgorithmException - if the JVM does not support elliptic curve keys
        InvalidKeyException - if the loaded key is invalid for any reason
      • getKeyId

        public String getKeyId()
        Returns the Apple-issued identifier for this key.
        Returns:
        the Apple-issued identifier for this key
      • getTeamId

        public String getTeamId()
        Returns the Apple-issued identifier for the team that owns this key.
        Returns:
        the Apple-issued identifier for the team that owns this key