How to call Rest webservice in Spring Security -
i have @restcontroller in web application, want make use of service in authentication provider security purpose .could please advise how achieve this? ( fyi : using spring boot)
for example rest service url : http://localhost:8080/authentication.json
login page url : http://localhost:8080/login
my question similar following question, difference is, rest service available in same application . hope rest template or httpurl connection not required ? please advise.
spring security login rest web service.
given below sample code snippet.
@restcontroller @requestmapping("authorize") public authorizecontroller{ @requestmapping(method = requestmethod.put, produces = "application/json") public employee authorize(@requestparam string username) { return employee; } } @configuration @enablewebmvcsecurity public class websecurityconfig extends websecurityconfigureradapter { @autowired customauthenticationprovider provider; @override protected void configure(httpsecurity http) throws exception { } @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth.authenticationprovider(provider); } } public class customauthenticationprovider implements authenticationprovider { @override public authentication authenticate(authentication authentication) throws authenticationexception { // here need call rest service . present in same application. } @override public boolean supports(class<?> authentication) { return authentication.equals(usernamepasswordauthenticationtoken.class); } }
thanks.
Comments
Post a Comment