Package com.eatthepath.pushy.apns.auth
Class ApnsSigningKey
- java.lang.Object
-
- com.eatthepath.pushy.apns.auth.ApnsSigningKey
-
- All Implemented Interfaces:
Serializable,ECKey,ECPrivateKey,Key,PrivateKey,Destroyable
public class ApnsSigningKey extends Object implements ECPrivateKey
A private key used to sign 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. Signing key instances are immutable and thread-safe.- Since:
- 0.10
- Author:
- Jon Chambers
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPNS_SIGNATURE_ALGORITHM
-
Constructor Summary
Constructors Constructor Description ApnsSigningKey(String keyId, String teamId, ECPrivateKey key)Constructs a new signing key with the given key identifier, team identifier, and elliptic curve private key.
-
Method Summary
Modifier and Type Method Description StringgetAlgorithm()byte[]getEncoded()StringgetFormat()StringgetKeyId()Returns the Apple-issued identifier for this key.ECParameterSpecgetParams()BigIntegergetS()StringgetTeamId()Returns the Apple-issued identifier for the team that owns this key.static ApnsSigningKeyloadFromInputStream(InputStream inputStream, String teamId, String keyId)Loads a signing key from the given input stream.static ApnsSigningKeyloadFromPkcs8File(File pkcs8File, String teamId, String keyId)Loads a signing key from the given PKCS#8 file.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.security.auth.Destroyable
destroy, isDestroyed
-
-
-
-
Field Detail
-
APNS_SIGNATURE_ALGORITHM
public static final String APNS_SIGNATURE_ALGORITHM
- See Also:
- Constant Field Values
-
-
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 itselfteamId- the ten-character, Apple-issued identifier for the team to which the key belongskey- the elliptic curve public key underpinning this verification 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 Detail
-
getAlgorithm
public String getAlgorithm()
- Specified by:
getAlgorithmin interfaceKey
-
getEncoded
public byte[] getEncoded()
- Specified by:
getEncodedin interfaceKey
-
getS
public BigInteger getS()
- Specified by:
getSin interfaceECPrivateKey
-
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 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 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 reasonNoSuchAlgorithmException- if the JVM does not support elliptic curve keysInvalidKeyException- 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 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 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 reasonNoSuchAlgorithmException- if the JVM does not support elliptic curve keysInvalidKeyException- 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
-
getParams
public ECParameterSpec getParams()
-
-