Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

spring boot api key authentication example

import org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter;

public class APIKeyAuthFilter extends AbstractPreAuthenticatedProcessingFilter {

    private String principalRequestHeader;

    public APIKeyAuthFilter(String principalRequestHeader) {
        this.principalRequestHeader = principalRequestHeader;
    }

    @Override
    protected Object getPreAuthenticatedPrincipal(HttpServletRequest request) {
        return request.getHeader(principalRequestHeader);
    }

    @Override
    protected Object getPreAuthenticatedCredentials(HttpServletRequest request) {
        return "N/A";
    }

}
Comment

PREVIOUS NEXT
Code Example
Java :: arraylist in java 
Java :: java list tostring 
Java :: onclick listview javafx 
Java :: android get app build name 
Java :: can a java class have more than 108 constructors 
Java :: jhow to check if a string is a punctuation java 
Java :: /setblock 
Java :: java string 
Java :: Retrieve User information in Spring Security 
Java :: java jre 
Java :: jdk jre jvm 
Java :: javadoc commands 
Java :: difference between synchronized block and synchronized method example 
Java :: java double to string fixed precision 
Java :: java wrapper classes 
Java :: while loops java 
Java :: how to create a node in java 
Java :: long java 
Java :: java int 0/0 
Java :: java check prime number 
Java :: java linked list swap elements 
Java :: edittext editable false android java 
Java :: java data structure 
Java :: Implementing the LinkedList Class in java list 
Java :: adding watermark to excel 
Java :: Java Queue Linked List Implementation 
Java :: why we use return method 
Java :: java interview questions for freshers 
Java :: java hashmap set value 
Java :: java truncate bigdecimal 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =