All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.robertomanfreda.java.jwt.JWTEEncryptor Maven / Gradle / Ivy

package com.github.robertomanfreda.java.jwt;

import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.RSAEncrypter;
import com.nimbusds.jwt.SignedJWT;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
class JWTEEncryptor {

    private final RSAEncrypter rsaEncrypter;

    String encryptSigned(SignedJWT signedJWT) throws JOSEException {
        JWEObject jweObject = new JWEObject(
                new JWEHeader.Builder(JWEAlgorithm.RSA_OAEP_256, EncryptionMethod.A256GCM)
                        .contentType("JWT")
                        .build(),
                new Payload(signedJWT)
        );

        jweObject.encrypt(rsaEncrypter);

        return jweObject.serialize();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy