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 SummaryFields
- Constructor SummaryConstructorsConstructorDescription- AbstractPushService- (String gcmApiKey) - AbstractPushService- (String publicKey, String privateKey) - AbstractPushService- (String publicKey, String privateKey, String subject) - AbstractPushService- (KeyPair keyPair) - AbstractPushService- (KeyPair keyPair, String subject) 
- Method SummaryModifier and TypeMethodDescription- static 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 key- setKeyPair- (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 booleanCheck if VAPID is enabled
- Field Details
- Constructor Details- AbstractPushServicepublic AbstractPushService()
- AbstractPushService
- AbstractPushService
- AbstractPushService
- AbstractPushService- Throws:
- GeneralSecurityException
 
- AbstractPushServicepublic AbstractPushService- (String publicKey, String privateKey, String subject) throws GeneralSecurityException - Throws:
- GeneralSecurityException
 
 
- Method Details- encryptpublic 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
 
- prepareRequestprotected final HttpRequest prepareRequest- (Notification notification, Encoding encoding) throws GeneralSecurityException, IOException, org.jose4j.lang.JoseException - Throws:
- GeneralSecurityException
- IOException
- org.jose4j.lang.JoseException
 
- setGcmApiKeySet the Google Cloud Messaging (GCM) API key- Parameters:
- gcmApiKey-
- Returns:
 
- getGcmApiKey
- getSubject
- setSubjectSet the JWT subject (for VAPID)- Parameters:
- subject-
- Returns:
 
- setKeyPairSet the public and private key (for VAPID).- Parameters:
- keyPair-
- Returns:
 
- getPublicKey
- setPublicKeypublic 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
- setPublicKeySet the public key (for VAPID)- Parameters:
- publicKey-
- Returns:
 
- setPrivateKeypublic T setPrivateKey- (String privateKey) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException Set the public key using a base64url-encoded string.- Parameters:
- privateKey-
- Returns:
- Throws:
- NoSuchAlgorithmException
- NoSuchProviderException
- InvalidKeySpecException
 
- setPrivateKeySet the private key (for VAPID)- Parameters:
- privateKey-
- Returns:
 
- vapidEnabledprotected boolean vapidEnabled()Check if VAPID is enabled- Returns: