Search in sources :

Example 1 with JweJsonConsumer

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;
}
Also used : JweJsonConsumer(org.apache.cxf.rs.security.jose.jwe.JweJsonConsumer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes)

Example 2 with JweJsonConsumer

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;
}
Also used : JweDecryptionOutput(org.apache.cxf.rs.security.jose.jwe.JweDecryptionOutput) JweException(org.apache.cxf.rs.security.jose.jwe.JweException) JweJsonConsumer(org.apache.cxf.rs.security.jose.jwe.JweJsonConsumer) JweDecryptionProvider(org.apache.cxf.rs.security.jose.jwe.JweDecryptionProvider) JweJsonEncryptionEntry(org.apache.cxf.rs.security.jose.jwe.JweJsonEncryptionEntry)

Aggregations

JweJsonConsumer (org.apache.cxf.rs.security.jose.jwe.JweJsonConsumer)2 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 JweDecryptionOutput (org.apache.cxf.rs.security.jose.jwe.JweDecryptionOutput)1 JweDecryptionProvider (org.apache.cxf.rs.security.jose.jwe.JweDecryptionProvider)1 JweException (org.apache.cxf.rs.security.jose.jwe.JweException)1 JweJsonEncryptionEntry (org.apache.cxf.rs.security.jose.jwe.JweJsonEncryptionEntry)1