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
 - public abstract class AbstractPushService<T extends AbstractPushService<T>> extends java.lang.Object
- Field Summary- Fields - Modifier and Type - Field - Description - static java.lang.String- SERVER_KEY_CURVE- static java.lang.String- SERVER_KEY_ID
 - Constructor Summary- Constructors - Constructor - Description - AbstractPushService()- AbstractPushService(java.lang.String gcmApiKey)- AbstractPushService(java.lang.String publicKey, java.lang.String privateKey)- AbstractPushService(java.lang.String publicKey, java.lang.String privateKey, java.lang.String subject)- AbstractPushService(java.security.KeyPair keyPair)- AbstractPushService(java.security.KeyPair keyPair, java.lang.String subject)
 - Method Summary- All Methods Static Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - static Encrypted- encrypt(byte[] payload, org.bouncycastle.jce.interfaces.ECPublicKey userPublicKey, byte[] userAuth, Encoding encoding)Encrypt the payload.- java.lang.String- getGcmApiKey()- java.security.KeyPair- getKeyPair()- java.security.PrivateKey- getPrivateKey()- java.security.PublicKey- getPublicKey()- java.lang.String- getSubject()- protected HttpRequest- prepareRequest(Notification notification, Encoding encoding)- T- setGcmApiKey(java.lang.String gcmApiKey)Set the Google Cloud Messaging (GCM) API key- T- setKeyPair(java.security.KeyPair keyPair)Set the public and private key (for VAPID).- T- setPrivateKey(java.lang.String privateKey)Set the public key using a base64url-encoded string.- T- setPrivateKey(java.security.PrivateKey privateKey)Set the private key (for VAPID)- T- setPublicKey(java.lang.String publicKey)Set the public key using a base64url-encoded string.- T- setPublicKey(java.security.PublicKey publicKey)Set the public key (for VAPID)- T- setSubject(java.lang.String subject)Set the JWT subject (for VAPID)- protected boolean- vapidEnabled()Check if VAPID is enabled
 
- Field Detail- SERVER_KEY_ID- public static final java.lang.String SERVER_KEY_ID - See Also:
- Constant Field Values
 
 - SERVER_KEY_CURVE- public static final java.lang.String SERVER_KEY_CURVE - See Also:
- Constant Field Values
 
 
 - Constructor Detail- AbstractPushService- public AbstractPushService() 
 - AbstractPushService- public AbstractPushService(java.lang.String gcmApiKey) 
 - AbstractPushService- public AbstractPushService(java.security.KeyPair keyPair) 
 - AbstractPushService- public AbstractPushService(java.security.KeyPair keyPair, java.lang.String subject)
 - AbstractPushService- public AbstractPushService(java.lang.String publicKey, java.lang.String privateKey) throws java.security.GeneralSecurityException- Throws:
- java.security.GeneralSecurityException
 
 - AbstractPushService- public AbstractPushService(java.lang.String publicKey, java.lang.String privateKey, java.lang.String subject) throws java.security.GeneralSecurityException- Throws:
- java.security.GeneralSecurityException
 
 
 - Method Detail- encrypt- public static Encrypted encrypt(byte[] payload, org.bouncycastle.jce.interfaces.ECPublicKey userPublicKey, byte[] userAuth, Encoding encoding) throws java.security.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:
- java.security.GeneralSecurityException
 
 - prepareRequest- protected final HttpRequest prepareRequest(Notification notification, Encoding encoding) throws java.security.GeneralSecurityException, java.io.IOException, org.jose4j.lang.JoseException - Throws:
- java.security.GeneralSecurityException
- java.io.IOException
- org.jose4j.lang.JoseException
 
 - setGcmApiKey- public T setGcmApiKey(java.lang.String gcmApiKey) Set the Google Cloud Messaging (GCM) API key- Parameters:
- gcmApiKey-
- Returns:
 
 - getGcmApiKey- public java.lang.String getGcmApiKey() 
 - getSubject- public java.lang.String getSubject() 
 - setSubject- public T setSubject(java.lang.String subject) Set the JWT subject (for VAPID)- Parameters:
- subject-
- Returns:
 
 - setKeyPair- public T setKeyPair(java.security.KeyPair keyPair) Set the public and private key (for VAPID).- Parameters:
- keyPair-
- Returns:
 
 - getPublicKey- public java.security.PublicKey getPublicKey() 
 - setPublicKey- public T setPublicKey(java.lang.String publicKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.spec.InvalidKeySpecException Set the public key using a base64url-encoded string.- Parameters:
- publicKey-
- Returns:
- Throws:
- java.security.NoSuchAlgorithmException
- java.security.NoSuchProviderException
- java.security.spec.InvalidKeySpecException
 
 - getPrivateKey- public java.security.PrivateKey getPrivateKey() 
 - getKeyPair- public java.security.KeyPair getKeyPair() 
 - setPublicKey- public T setPublicKey(java.security.PublicKey publicKey) Set the public key (for VAPID)- Parameters:
- publicKey-
- Returns:
 
 - setPrivateKey- public T setPrivateKey(java.lang.String privateKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.spec.InvalidKeySpecException Set the public key using a base64url-encoded string.- Parameters:
- privateKey-
- Returns:
- Throws:
- java.security.NoSuchAlgorithmException
- java.security.NoSuchProviderException
- java.security.spec.InvalidKeySpecException
 
 - setPrivateKey- public T setPrivateKey(java.security.PrivateKey privateKey) Set the private key (for VAPID)- Parameters:
- privateKey-
- Returns:
 
 - vapidEnabled- protected boolean vapidEnabled() Check if VAPID is enabled- Returns: