Module com.zerodeplibs.webpush
Package com.zerodeplibs.webpush
Class UserAgentMessageEncryptionKeyInfo
- java.lang.Object
-
- com.zerodeplibs.webpush.UserAgentMessageEncryptionKeyInfo
-
public class UserAgentMessageEncryptionKeyInfo extends Object
This class represents keys of a user agent used for encrypting push messages.
Typically, an instance of this class is created from a 'keys' field of a push subscription.
Thread Safety:Instances of this class are thread-safe.
- Author:
- Tomoki Sato
- See Also:
PushSubscription
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Compares the given object with this object based on their public keys and secrets.static UserAgentMessageEncryptionKeyInfofrom(PushSubscription.Keys subscriptionKeys)Creates a newUserAgentMessageEncryptionKeyInfofrom aPushSubscription's 'keys' field.inthashCode()Returns the hash code value for this object based on its public key and secret.static UserAgentMessageEncryptionKeyInfoof(byte[] p256dh, byte[] auth)Creates a newUserAgentMessageEncryptionKeyInfowith the given p256dh and the auth.static UserAgentMessageEncryptionKeyInfoof(String p256dh, String auth)Creates a newUserAgentMessageEncryptionKeyInfowith the given p256dh and auth.StringtoString()
-
-
-
Method Detail
-
from
public static UserAgentMessageEncryptionKeyInfo from(PushSubscription.Keys subscriptionKeys)
Creates a newUserAgentMessageEncryptionKeyInfofrom aPushSubscription's 'keys' field.- Parameters:
subscriptionKeys- a PushSubscription's 'keys' field.- Returns:
- a new
UserAgentMessageEncryptionKeyInfo. - Throws:
IllegalArgumentException- if the 'keys.p256dh' is invalid as a base64url string or the 'keys.auth' is invalid as a base64url string.MalformedUncompressedBytesException- if the given p256dh doesn't start with 0x04 or the length isn't 65 bytes.InvalidECPublicKeyException- if the public key extracted from the give p256dh is invalid.- See Also:
PushSubscription
-
of
public static UserAgentMessageEncryptionKeyInfo of(String p256dh, String auth)
Creates a new
UserAgentMessageEncryptionKeyInfowith the given p256dh and auth.It is assumed that the p256dh and the auth are base64-url encoded (Typically, these are the values obtained from a 'keys' field of a push subscription).
- Parameters:
p256dh- a p256dh.auth- an auth.- Returns:
- a new
UserAgentMessageEncryptionKeyInfo. - Throws:
IllegalArgumentException- if the 'keys.p256dh' is invalid as a base64url string or the 'keys.auth' is invalid as a base64url string.MalformedUncompressedBytesException- if the given p256dh doesn't start with 0x04 or the length isn't 65 bytes.InvalidECPublicKeyException- if the public key extracted from the give p256dh is invalid.
-
of
public static UserAgentMessageEncryptionKeyInfo of(byte[] p256dh, byte[] auth)
Creates a new
UserAgentMessageEncryptionKeyInfowith the given p256dh and the auth.This method is a byte array version of
of(String, String).- Parameters:
p256dh- a p256dh.auth- an auth.- Returns:
- a new
UserAgentMessageEncryptionKeyInfo. - Throws:
MalformedUncompressedBytesException- if the given p256dh doesn't start with 0x04 or the length isn't 65 bytes.InvalidECPublicKeyException- if the public key extracted from the give p256dh is invalid.
-
equals
public boolean equals(Object o)
Compares the given object with this object based on their public keys and secrets.
-
hashCode
public int hashCode()
Returns the hash code value for this object based on its public key and secret.
-
-