Adding a custom authorization filter
diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/filters/AuthFilter.java b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/filters/AuthFilter.java
new file mode 100644
index 0000000..b080142
--- /dev/null
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/filters/AuthFilter.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.custos.credential.api.filters;
+
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Enumeration;
+
+@Component
+@Order(Ordered.HIGHEST_PRECEDENCE)
+public class AuthFilter implements Filter{
+
+ public AuthFilter() {}
+
+
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+ HttpServletResponse response = (HttpServletResponse) servletResponse;
+ HttpServletRequest request = (HttpServletRequest) servletRequest;
+
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
+ Enumeration<String> headerNames = httpRequest.getHeaderNames();
+
+ if (headerNames != null) {
+ while (headerNames.hasMoreElements()) {
+ String name = headerNames.nextElement();
+ if ("authorization".equals(name)) {
+ String headerValue = httpRequest.getHeader(name);
+ // TODO Validate the authorization header
+ }
+ }
+ }
+
+
+ filterChain.doFilter(request, response);
+ }
+}