Package com.eatthepath.pushy.apns.auth
Class ApnsVerificationKey
java.lang.Object
com.eatthepath.pushy.apns.auth.ApnsVerificationKey
- All Implemented Interfaces:
Serializable
,ECKey
,ECPublicKey
,Key
,PublicKey
A public key used to verify authentication tokens. Signing keys are associated with a developer team (in Apple's parlance), and can be used to sign authentication tokens for any topic associated with that team.
Callers generally won't need to use this class outside of the context of integration tests. In almost all cases,
callers will want to use an ApnsSigningKey
to provide signing credentials to an
ApnsClient
.
Verification keys are immutable and thread-safe.
- Since:
- 0.10
- Author:
- Jon Chambers
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionApnsVerificationKey
(String keyId, String teamId, ECPublicKey key) Constructs a new verification key with the given key identifier, team identifier, and elliptic curve private key. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getKey()
getKeyId()
Returns the Apple-issued identifier for this key.Returns the Apple-issued identifier for the team that owns this key.getW()
static ApnsVerificationKey
loadFromInputStream
(InputStream inputStream, String teamId, String keyId) Loads a verification key from the given input stream.static ApnsVerificationKey
loadFromPkcs8File
(File pkcs8File, String teamId, String keyId) Loads a verification key from the given PKCS#8 file.
-
Field Details
-
APNS_SIGNATURE_ALGORITHM
- See Also:
-
-
Constructor Details
-
ApnsVerificationKey
public ApnsVerificationKey(String keyId, String teamId, ECPublicKey key) throws NoSuchAlgorithmException, InvalidKeyException Constructs a new verification key with the given key identifier, team identifier, and elliptic curve private key.- Parameters:
keyId
- the ten-character, Apple-issued identifier for the key itselfteamId
- the ten-character, Apple-issued identifier for the team to which the key belongskey
- the elliptic curve private key underpinning this signing key- Throws:
NoSuchAlgorithmException
- if the "SHA256withECDSA" algorith is not supported by the JVMInvalidKeyException
- if the given elliptic curve private key is invalid for any reason
-
-
Method Details
-
getKey
-
getAlgorithm
- Specified by:
getAlgorithm
in interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()- Specified by:
getEncoded
in interfaceKey
-
getW
- Specified by:
getW
in interfaceECPublicKey
-
loadFromPkcs8File
public static ApnsVerificationKey loadFromPkcs8File(File pkcs8File, String teamId, String keyId) throws IOException, NoSuchAlgorithmException, InvalidKeyException Loads a verification key from the given PKCS#8 file.- Parameters:
pkcs8File
- the file from which to load the keyteamId
- the ten-character, Apple-issued identifier for the team to which the key belongskeyId
- the ten-character, Apple-issued identitifier for the key itself- Returns:
- an APNs verification 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 reasonNoSuchAlgorithmException
- if the JVM does not support elliptic curve keysInvalidKeyException
- if the loaded key is invalid for any reason
-
loadFromInputStream
public static ApnsVerificationKey loadFromInputStream(InputStream inputStream, String teamId, String keyId) throws IOException, NoSuchAlgorithmException, InvalidKeyException Loads a verification key from the given input stream.- Parameters:
inputStream
- the input stream from which to load the keyteamId
- the ten-character, Apple-issued identifier for the team to which the key belongskeyId
- the ten-character, Apple-issued identitifier for the key itself- Returns:
- an APNs verification 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 reasonNoSuchAlgorithmException
- if the JVM does not support elliptic curve keysInvalidKeyException
- if the loaded key is invalid for any reason
-
getKeyId
Returns the Apple-issued identifier for this key.- Returns:
- the Apple-issued identifier for this key
-
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
-
getParams
-