net.loginbuddy.common/src/main/java/net/loginbuddy/common/util/Jwt.java
/**
     * Generate a JWT based on a private key. Nothing fancy, using the example implementation of jose4j
     *
     * @return JWT compact URL-safe serialization
     * @see <a href="https://bitbucket.org/b_c/jose4j/wiki/JWT%20Examples#markdown-header-producing-and-consuming-a-signed-jwt"></a>
     */
Generate a JWT based on a private key. Nothing fancy, using the example implementation of jose4j
@return JWT compact URL-safe serialization
@see 
Generate a JWT based on a private key . Nothing fancy using the example implementation of jose4j @return JWT compact URL - safe serialization @see
public JsonWebSignature createSignedJwt(String payload, String alg) {
        RsaJsonWebKey rsaJsonWebKey = (RsaJsonWebKey) DEFAULT.getJwksForSigning().getJsonWebKeys().get(0);
        JsonWebSignature jws = new JsonWebSignature();
        jws.setPayload(payload);
        jws.setKey(rsaJsonWebKey.getPrivateKey());
        jws.setKeyIdHeaderValue(rsaJsonWebKey.getKeyId());
        jws.setAlgorithmHeaderValue(AlgorithmIdentifiers.RSA_USING_SHA256);
        return jws;
    }
public JsonWebSignature createSignedJwt ( String payload , String alg ) { RsaJsonWebKey rsaJsonWebKey = ( RsaJsonWebKey ) DEFAULT . getJwksForSigning ( ) . getJsonWebKeys ( ) . get ( 0 ) ; JsonWebSignature jws = new JsonWebSignature ( ) ; jws . setPayload ( payload ) ; jws . setKey ( rsaJsonWebKey . getPrivateKey ( ) ) ; jws . setKeyIdHeaderValue ( rsaJsonWebKey . getKeyId ( ) ) ; jws . setAlgorithmHeaderValue ( AlgorithmIdentifiers . RSA_USING_SHA256 ) ; return jws ; }
Generate a JWT based on a private key.
Generate a JWT based on a private key .
// TODO algorithm is currently ignored // Generate an RSA key pair, which will be used for signing and verification of the JWT, wrapped in a JWK