public class PushService
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
SERVER_KEY_CURVE |
static java.lang.String |
SERVER_KEY_ID |
| Constructor and Description |
|---|
PushService() |
PushService(java.security.KeyPair keyPair) |
PushService(java.security.KeyPair keyPair,
java.lang.String subject) |
PushService(java.lang.String gcmApiKey) |
PushService(java.lang.String publicKey,
java.lang.String privateKey) |
PushService(java.lang.String publicKey,
java.lang.String privateKey,
java.lang.String subject) |
| Modifier and Type | Method and Description |
|---|---|
static Encrypted |
encrypt(byte[] payload,
org.bouncycastle.jce.interfaces.ECPublicKey userPublicKey,
byte[] userAuth,
Encoding encoding)
Encrypt the payload.
|
java.security.KeyPair |
getKeyPair() |
java.security.PrivateKey |
getPrivateKey() |
java.security.PublicKey |
getPublicKey() |
org.apache.http.client.methods.HttpPost |
preparePost(Notification notification,
Encoding encoding)
Prepare a HttpPost for Apache async http client
|
org.apache.http.HttpResponse |
send(Notification notification) |
org.apache.http.HttpResponse |
send(Notification notification,
Encoding encoding)
Send a notification and wait for the response.
|
java.util.concurrent.Future<org.apache.http.HttpResponse> |
sendAsync(Notification notification) |
java.util.concurrent.Future<org.apache.http.HttpResponse> |
sendAsync(Notification notification,
Encoding encoding)
Send a notification, but don't wait for the response.
|
PushService |
setGcmApiKey(java.lang.String gcmApiKey)
Set the Google Cloud Messaging (GCM) API key
|
PushService |
setKeyPair(java.security.KeyPair keyPair)
Set the public and private key (for VAPID).
|
PushService |
setPrivateKey(java.security.PrivateKey privateKey)
Set the private key (for VAPID)
|
PushService |
setPrivateKey(java.lang.String privateKey)
Set the public key using a base64url-encoded string.
|
PushService |
setPublicKey(java.security.PublicKey publicKey)
Set the public key (for VAPID)
|
PushService |
setPublicKey(java.lang.String publicKey)
Set the public key using a base64url-encoded string.
|
PushService |
setSubject(java.lang.String subject)
Set the JWT subject (for VAPID)
|
protected boolean |
vapidEnabled()
Check if VAPID is enabled
|
public static final java.lang.String SERVER_KEY_ID
public static final java.lang.String SERVER_KEY_CURVE
public PushService()
public PushService(java.lang.String gcmApiKey)
public PushService(java.security.KeyPair keyPair)
public PushService(java.security.KeyPair keyPair,
java.lang.String subject)
public PushService(java.lang.String publicKey,
java.lang.String privateKey)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic PushService(java.lang.String publicKey,
java.lang.String privateKey,
java.lang.String subject)
throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic static Encrypted encrypt(byte[] payload, org.bouncycastle.jce.interfaces.ECPublicKey userPublicKey, byte[] userAuth, Encoding encoding) throws java.security.GeneralSecurityException
payload - Payload to encrypt.userPublicKey - The user agent's public key (keys.p256dh).userAuth - The user agent's authentication secret (keys.auth).encoding - java.security.GeneralSecurityExceptionpublic org.apache.http.HttpResponse send(Notification notification, Encoding encoding) throws java.security.GeneralSecurityException, java.io.IOException, org.jose4j.lang.JoseException, java.util.concurrent.ExecutionException, java.lang.InterruptedException
notification - encoding - java.security.GeneralSecurityExceptionjava.io.IOExceptionorg.jose4j.lang.JoseExceptionjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic org.apache.http.HttpResponse send(Notification notification) throws java.security.GeneralSecurityException, java.io.IOException, org.jose4j.lang.JoseException, java.util.concurrent.ExecutionException, java.lang.InterruptedException
java.security.GeneralSecurityExceptionjava.io.IOExceptionorg.jose4j.lang.JoseExceptionjava.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic java.util.concurrent.Future<org.apache.http.HttpResponse> sendAsync(Notification notification, Encoding encoding) throws java.security.GeneralSecurityException, java.io.IOException, org.jose4j.lang.JoseException
notification - encoding - java.security.GeneralSecurityExceptionjava.io.IOExceptionorg.jose4j.lang.JoseExceptionpublic java.util.concurrent.Future<org.apache.http.HttpResponse> sendAsync(Notification notification) throws java.security.GeneralSecurityException, java.io.IOException, org.jose4j.lang.JoseException
java.security.GeneralSecurityExceptionjava.io.IOExceptionorg.jose4j.lang.JoseExceptionpublic org.apache.http.client.methods.HttpPost preparePost(Notification notification, Encoding encoding) throws java.security.GeneralSecurityException, java.io.IOException, org.jose4j.lang.JoseException
notification - encoding - java.security.GeneralSecurityExceptionjava.io.IOExceptionorg.jose4j.lang.JoseExceptionpublic PushService setGcmApiKey(java.lang.String gcmApiKey)
gcmApiKey - public PushService setSubject(java.lang.String subject)
subject - public PushService setKeyPair(java.security.KeyPair keyPair)
keyPair - public java.security.PublicKey getPublicKey()
public PushService setPublicKey(java.lang.String publicKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.spec.InvalidKeySpecException
publicKey - java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionjava.security.spec.InvalidKeySpecExceptionpublic java.security.PrivateKey getPrivateKey()
public java.security.KeyPair getKeyPair()
public PushService setPublicKey(java.security.PublicKey publicKey)
publicKey - public PushService setPrivateKey(java.lang.String privateKey) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.spec.InvalidKeySpecException
privateKey - java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionjava.security.spec.InvalidKeySpecExceptionpublic PushService setPrivateKey(java.security.PrivateKey privateKey)
privateKey - protected boolean vapidEnabled()