
com.zerodeplibs.webpush.ext.jwt.vertx.VertxVAPIDJWTGeneratorFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zerodep-web-push-java-ext-jwt-vertx Show documentation
Show all versions of zerodep-web-push-java-ext-jwt-vertx Show documentation
A sub-module for zerodep-web-push-java. This module provides the JSON Web Token(JWT) generator
used for VAPID utilizing [JWT Auth - Vert.x].
The newest version!
package com.zerodeplibs.webpush.ext.jwt.vertx;
import com.zerodeplibs.webpush.jwt.VAPIDJWTGenerator;
import com.zerodeplibs.webpush.jwt.VAPIDJWTGeneratorFactory;
import io.vertx.core.Vertx;
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.auth.jwt.JWTAuthOptions;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.util.function.BiFunction;
import java.util.function.Supplier;
/**
* The factory class for {@link VAPIDJWTGenerator}.
* {@link VAPIDJWTGenerator}s generated by this class utilizes JWT Auth - Vert.x.
*
* @author Tomoki Sato
*/
public class VertxVAPIDJWTGeneratorFactory
implements VAPIDJWTGeneratorFactory, BiFunction {
private final Supplier vertxObtainStrategy;
/**
* Creates a new {@link VertxVAPIDJWTGeneratorFactory}.
*
*
* The returned generator invokes vertxObtainStrategy#get
each time
* its 'generate' method is called in order to get an instance of Vertx.
*
*
*
* this instance is passed to the JWT authentication provider
* and used to generate the JWT.
*
*
* @param vertxObtainStrategy a strategy used to obtain a Vertx instance.
* @see JWTAuth#create(Vertx, JWTAuthOptions)
*/
public VertxVAPIDJWTGeneratorFactory(Supplier vertxObtainStrategy) {
this.vertxObtainStrategy = vertxObtainStrategy;
}
@Override
public VAPIDJWTGenerator create(ECPrivateKey privateKey,
ECPublicKey publicKey) {
return new VertxVAPIDJWTGenerator(this.vertxObtainStrategy, privateKey);
}
@Override
public VAPIDJWTGenerator apply(ECPrivateKey privateKey,
ECPublicKey publicKey) {
return create(privateKey, publicKey);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy