reta commented on a change in pull request #462: Httpsig
URL: https://github.com/apache/cxf/pull/462#discussion_r228386006
 
 

 ##########
 File path: 
rt/rs/security/http-signature/src/main/java/org/apache/cxf/rs/security/httpsignature/VerifySignatureReaderInterceptor.java
 ##########
 @@ -0,0 +1,85 @@
+package org.apache.cxf.rs.security.httpsignature;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.ReaderInterceptor;
+import javax.ws.rs.ext.ReaderInterceptorContext;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import java.util.logging.Logger;
+
+/**
+ * RS CXF Reader Interceptor which extracts signature data from the message 
and sends it to the message verifier
+ *
+ */
+@Provider
+@Priority(Priorities.AUTHENTICATION)
+public class VerifySignatureReaderInterceptor implements ReaderInterceptor {
+    private static final Logger LOG = 
LogUtils.getL7dLogger(VerifySignatureReaderInterceptor.class);
+
+    private MessageVerifier messageVerifier;
+
+    private boolean enabled;
+
+    public VerifySignatureReaderInterceptor() {
+        setEnabled(true);
+        setMessageVerifier(new MessageVerifier(true));
+    }
+
+    @Override
+    public Object aroundReadFrom(ReaderInterceptorContext context) throws 
IOException, WebApplicationException {
+        if (!enabled) {
+            LOG.fine("Verify signature reader interceptor is disabled");
+            return context.proceed();
+        }
+        LOG.fine("Starting interceptor message verification process");
+
+        Map<String, List<String>> responseHeaders = context.getHeaders();
+
+        String messageBody = extractMessageBody(context);
 
 Review comment:
   Could be an issue for streaming use cases (when message body is large), no?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to