use of org.apache.cxf.rs.security.jose.jwe.JweJsonConsumer in project cxf by apache.
the class BookStore method echoTextJweJsonIn.
@POST
@Path("/books")
@Produces({ "text/plain" })
@Consumes("application/jose+json")
public String echoTextJweJsonIn(String jweJson) {
JweJsonConsumer consumer = new JweJsonConsumer(jweJson);
// Recipient 1
final String recipient1PropLoc = "org/apache/cxf/systest/jaxrs/security/jwejson1.properties";
final String recipient1Kid = "AesWrapKey";
String recipient1DecryptedText = getRecipientText(consumer, recipient1PropLoc, recipient1Kid);
// Recipient 2
final String recipient2PropLoc = "org/apache/cxf/systest/jaxrs/security/jwejson2.properties";
final String recipient2Kid = "AesWrapKey2";
String recipient2DecryptedText = getRecipientText(consumer, recipient2PropLoc, recipient2Kid);
return recipient1DecryptedText + recipient2DecryptedText;
}
use of org.apache.cxf.rs.security.jose.jwe.JweJsonConsumer in project cxf by apache.
the class AbstractJweJsonDecryptingFilter method decrypt.
protected JweDecryptionOutput decrypt(InputStream is) throws IOException {
JweJsonConsumer c = new JweJsonConsumer(new String(IOUtils.readBytesFromStream(is), StandardCharsets.UTF_8));
JweDecryptionProvider theProvider = getInitializedDecryptionProvider(c.getProtectedHeader());
JweJsonEncryptionEntry entry = c.getJweDecryptionEntry(theProvider, recipientProperties);
if (entry == null) {
throw new JweException(JweException.Error.INVALID_JSON_JWE);
}
JweDecryptionOutput out = c.decryptWith(theProvider, entry);
JAXRSUtils.getCurrentMessage().put(JweJsonConsumer.class, c);
JAXRSUtils.getCurrentMessage().put(JweJsonEncryptionEntry.class, entry);
return out;
}
Aggregations