Package com.iizix.push.vapid
Class AbstractPushService<T extends AbstractPushService<T>>
java.lang.Object
com.iizix.push.vapid.AbstractPushService<T>
- Direct Known Subclasses:
PushAsyncService
,PushService
Field Summary
Constructor Summary
ConstructorDescriptionAbstractPushService
(String gcmApiKey) AbstractPushService
(String publicKey, String privateKey) AbstractPushService
(String publicKey, String privateKey, String subject) AbstractPushService
(KeyPair keyPair) AbstractPushService
(KeyPair keyPair, String subject) Method Summary
Modifier and TypeMethodDescriptionstatic Encrypted
encrypt
(byte[] payload, ECPublicKey userPublicKey, byte[] userAuth, Encoding encoding) Encrypt the payload.protected final HttpRequest
prepareRequest
(Notification notification, Encoding encoding) setGcmApiKey
(String gcmApiKey) Set the Google Cloud Messaging (GCM) API keysetKeyPair
(KeyPair keyPair) Set the public and private key (for VAPID).setPrivateKey
(String privateKey) Set the public key using a base64url-encoded string.setPrivateKey
(PrivateKey privateKey) Set the private key (for VAPID)setPublicKey
(String publicKey) Set the public key using a base64url-encoded string.setPublicKey
(PublicKey publicKey) Set the public key (for VAPID)setSubject
(String subject) Set the JWT subject (for VAPID)protected boolean
Check if VAPID is enabled
Field Details
SERVER_KEY_ID
- See Also:
SERVER_KEY_CURVE
- See Also:
Constructor Details
AbstractPushService
public AbstractPushService()AbstractPushService
AbstractPushService
AbstractPushService
AbstractPushService
- Throws:
GeneralSecurityException
AbstractPushService
public AbstractPushService(String publicKey, String privateKey, String subject) throws GeneralSecurityException - Throws:
GeneralSecurityException
Method Details
encrypt
public static Encrypted encrypt(byte[] payload, ECPublicKey userPublicKey, byte[] userAuth, Encoding encoding) throws GeneralSecurityException Encrypt the payload. Encryption uses Elliptic curve Diffie-Hellman (ECDH) cryptography over the prime256v1 curve.- Parameters:
payload
- Payload to encrypt.userPublicKey
- The user agent's public key (keys.p256dh).userAuth
- The user agent's authentication secret (keys.auth).encoding
-- Returns:
- An Encrypted object containing the public key, salt, and ciphertext.
- Throws:
GeneralSecurityException
prepareRequest
protected final HttpRequest prepareRequest(Notification notification, Encoding encoding) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException - Throws:
GeneralSecurityException
IOException
org.jose4j.lang.JoseException
setGcmApiKey
Set the Google Cloud Messaging (GCM) API key- Parameters:
gcmApiKey
-- Returns:
getGcmApiKey
getSubject
setSubject
Set the JWT subject (for VAPID)- Parameters:
subject
-- Returns:
setKeyPair
Set the public and private key (for VAPID).- Parameters:
keyPair
-- Returns:
getPublicKey
setPublicKey
public T setPublicKey(String publicKey) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException Set the public key using a base64url-encoded string.- Parameters:
publicKey
-- Returns:
- Throws:
NoSuchAlgorithmException
NoSuchProviderException
InvalidKeySpecException
getPrivateKey
getKeyPair
setPublicKey
Set the public key (for VAPID)- Parameters:
publicKey
-- Returns:
setPrivateKey
public T setPrivateKey(String privateKey) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException Set the public key using a base64url-encoded string.- Parameters:
privateKey
-- Returns:
- Throws:
NoSuchAlgorithmException
NoSuchProviderException
InvalidKeySpecException
setPrivateKey
Set the private key (for VAPID)- Parameters:
privateKey
-- Returns:
vapidEnabled
protected boolean vapidEnabled()Check if VAPID is enabled- Returns: