I want to sign JWT token from a local jwk file containing keys in JWKSet. I'm trying to achieve this by loading json file in JWTSet object and then sign the token with it but it through an exception that signer need to have private key. Is there a way to sign jwt from JWKSet? Here is the code snippet:
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.JWSSigner;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import com.nimbusds.jose.crypto.RSASSASigner;
public class testJWK {
public static void main(String[] args) throws IOException, ParseException {
JWKSet jwks = JWKSet.load(new File("./jwkset.json"));
JWSSigner signer = new RSASSASigner(jwks);
}
}