1import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;
2
3public class APIKeyAuthFilter extends AbstractPreAuthenticatedProcessingFilter {
4
5 private String principalRequestHeader;
6
7 public APIKeyAuthFilter(String principalRequestHeader) {
8 this.principalRequestHeader = principalRequestHeader;
9 }
10
11 @Override
12 protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
13 return request.getHeader(principalRequestHeader);
14 }
15
16 @Override
17 protected Object getPreAuthenticatedCredentials(HttpServletRequest request) {
18 return "N/A";
19 }
20
21}