Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script>
- $( document ).ready(function() {
- var request = $.ajax({
- method: "POST",
- url: "http://localhost:8081/login",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: { username: "John", password: "Boston" }
- })
- .done(function( msg ) {
- alert( "Done: " + msg );
- })
- .fail(function( jqXHR, textStatus ) {
- alert( "Request failed: " + textStatus );
- });
- });
- </script>
- </head>
- <body>
- </body>
- </html>
- @Override
- public Authentication attemptAuthentication(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
- throws AuthenticationException, IOException, ServletException {
- String contentType = httpServletRequest.getContentType();
- String headerPart = httpServletRequest.getHeader("Accept");
- String body = httpServletRequest.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
- AccountCredentials credentials = new ObjectMapper().readValue(httpServletRequest.getInputStream(),AccountCredentials.class);
- UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(credentials.getUsername(), credentials.getPassword());
- return getAuthenticationManager().authenticate(token);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement