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

 ##########
 File path: 
rt/rs/security/http-signature/src/main/java/org/apache/cxf/rs/security/httpsignature/VerifySignatureFilter.java
 ##########
 @@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.rs.security.httpsignature;
+
+import java.util.Objects;
+import java.util.logging.Logger;
+
+import javax.annotation.Priority;
+import javax.ws.rs.Priorities;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.cxf.common.logging.LogUtils;
+
+/**
+ * RS CXF Filter which extracts signature data from the context and sends it 
to the message verifier
+ *
+ */
+@Provider
+@PreMatching
+@Priority(Priorities.AUTHENTICATION)
+public final class VerifySignatureFilter implements ContainerRequestFilter {
+    private static final Logger LOG = 
LogUtils.getL7dLogger(VerifySignatureFilter.class);
+
+    private MessageVerifier messageVerifier;
+
+    private boolean enabled;
+
+    public VerifySignatureFilter() {
+        setEnabled(true);
+        setMessageVerifier(new MessageVerifier(false));
+    }
+
+    @Override
+    public void filter(ContainerRequestContext requestCtx) {
+        if (!enabled) {
+            LOG.fine("Verify signature filter is disabled");
+            return;
+        }
+
+        LOG.fine("Starting filter message verification process");
+
+        MultivaluedMap<String, String> responseHeaders = 
requestCtx.getHeaders();
+
+        messageVerifier.verifyMessage(responseHeaders);
 
 Review comment:
   Why not give the option of verifying the body here as well in the filter?

----------------------------------------------------------------
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