use of org.apache.cxf.rs.security.jose.jwe.JweJwtCompactProducer in project cxf by apache.
the class JoseJwtProducer method processJwt.
public String processJwt(JwtToken jwt, JweEncryptionProvider theEncProvider, JwsSignatureProvider theSigProvider) {
super.checkProcessRequirements();
String data = null;
if (isJweRequired() && theEncProvider == null) {
theEncProvider = getInitializedEncryptionProvider(jwt.getJweHeaders());
if (theEncProvider == null) {
throw new JwtException("Unable to encrypt JWT");
}
}
if (isJwsRequired()) {
JwsJwtCompactProducer jws = new JwsJwtCompactProducer(jwt);
if (jws.isPlainText()) {
data = jws.getSignedEncodedJws();
} else {
if (theSigProvider == null) {
theSigProvider = getInitializedSignatureProvider(jws.getJwsHeaders());
}
if (theSigProvider == null) {
throw new JwtException("Unable to sign JWT");
}
data = jws.signWith(theSigProvider);
}
if (theEncProvider != null) {
data = theEncProvider.encrypt(StringUtils.toBytesUTF8(data), jwt.getJweHeaders());
}
} else {
JweJwtCompactProducer jwe = new JweJwtCompactProducer(jwt.getJweHeaders(), jwt.getClaims());
data = jwe.encryptWith(theEncProvider);
}
return data;
}
Aggregations