-
public interface VAPIDJWTGeneratorThe interface to a generator that generates JSON Web Token (JWT) used for the Voluntary Application Server Identification (VAPID).
Typically, you don't have to implement this interface by yourself. When you use
VAPIDKeyPairs.of(PrivateKeySource, PublicKeySource)without any sub-module for this interface, the default implementation is automatically provided throughDefaultVAPIDJWTGeneratorFactory.If you have dependencies on one or more sub-modules for
VAPIDJWTGenerator(zerodep-web-push-java-ext-jwt), the implementation can be provided by the sub-module(s).Of course, you can use arbitrary 3rd party libraries to make your own implementation. For example, if you want to make your own implementation by utilizing Auth0 Java JWT library, The implementation will be something like below.
class MyAuth0VAPIDJWTGenerator implements VAPIDJWTGenerator { private final Algorithm jwtAlgorithm; MyAuth0VAPIDJWTGenerator(ECPrivateKey privateKey, ECPublicKey publicKey) { this.jwtAlgorithm = Algorithm.ECDSA256(publicKey, privateKey); } public String generate(VAPIDJWTParam param) { return JWT.create() .withAudience(param.getOrigin()) .withExpiresAt(param.getExpiresAt()) .withSubject(param.getSubject().orElse("mailto:example@example.com")) .sign(this.jwtAlgorithm); } }Thread Safety:Depends on implementations. The implementation provided through
DefaultVAPIDJWTGeneratorFactoryis thread-safe. Most of the implementations provided by zerodep-web-push-java-ext-jwt are thread-safe. For more information, see its README.- Author:
- Tomoki Sato
- See Also:
VAPIDJWTGeneratorFactory,DefaultVAPIDJWTGeneratorFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Stringgenerate(VAPIDJWTParam param)Generates a JWT used for VAPID.
-
-
-
Method Detail
-
generate
String generate(VAPIDJWTParam param)
Generates a JWT used for VAPID.- Parameters:
param- parameters used to build the JWT.- Returns:
- a JWT.
-
-