Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Produce and Consume JOSE data

If you need to produce and consumer some non-JWT JOSE properties- extend or delegate to JoseProducerConsumer:

Code Block
languagejava
import org.apache.cxf.rs.security.jose.common.JoseProducerConsumer;
@Path("service")
public class SecureService extends JoseProducerConsumer {
    @POST
    public String echoProtectedValue(String joseValue) {
        // decrypt the value first if needed, verify the signature
        String data = super.getData(joseValue);
        // sign and/or encrypt the data
        return super.processData(data); 
    }
}

// or

@Path("service")
public class SecureService extends AbstractSecureService {
    
    private JoseProducerConsumer jose = new JoseProducerConsumer();
    @POST
    public String echoProtectedValue(String joseValue) {
        // decrypt the value first if needed, verify the signature
        String data = jose.getData(joseValue);
        // sign and/or encrypt the data
        return jose.processData(data); 
    }
}

If you need to decrypt and/or verify some JWT property then extend or delegate to JoseJwtProducerConsumer:

Code Block
languagejava
import org.apache.cxf.rs.security.jose.jwt.JoseJwtProducerConsumer;
@Path("service")
public class SecureService extends JoseJwtProducerConsumer {
    @POST
    public String echoProtectedToken(String joseValue) {
        // decrypt the value first if needed, verify the signature
        JwtToken data = super.getJwtToken(joseValue);
        // sign and/or encrypt the data
        return super.processJwt(data);
    }
}

// or

@Path("service")
public class SecureService extends AbstractSecureService {
    
    private JoseJwtProducerConsumer jose = new JoseJwtProducerConsumer();
    @POST
    public String echoProtectedToken(String joseValue) {
        // decrypt the value first if needed, verify the signature
        JwtToken data = jose.getJwtToken(joseValue);
        // sign and/or encrypt the data
        return jose.processJwt(data);
    }
}

In both cases this composite producer-consumer will use the internal producer and/or consumer helpers which will detect the endpoint specific configuration but which can also be injected with some specific JWE and/or JWS handlers.

Configure the endpoint

These properties will contain a location of the key store, signature and/or encryption algorithm properties, etc. See the Configuration section for all the available configuration options.

...