source: src/main/java/com/example/eatys_app/config/CustomUsernamePasswordAuthenticationProvider.java

Last change on this file was b3f2adb, checked in by Aleksandar Siljanoski <acewow3@…>, 14 months ago

Adding project to repo

  • Property mode set to 100644
File size: 2.0 KB
Line 
1//package com.example.eatys_app.config;
2//
3//import com.example.eatys_app.service.KorisnikService;
4//import org.springframework.security.authentication.AuthenticationProvider;
5//import org.springframework.security.authentication.BadCredentialsException;
6//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
7//import org.springframework.security.core.Authentication;
8//import org.springframework.security.core.AuthenticationException;
9//import org.springframework.security.core.userdetails.UserDetails;
10//import org.springframework.security.crypto.password.PasswordEncoder;
11//import org.springframework.stereotype.Component;
12//
13//@Component
14//public class CustomUsernamePasswordAuthenticationProvider implements AuthenticationProvider {
15//
16// private final KorisnikService korisnikService;
17// private final PasswordEncoder passwordEncoder;
18//
19// public CustomUsernamePasswordAuthenticationProvider(KorisnikService korisnikService, PasswordEncoder passwordEncoder) {
20// this.korisnikService = korisnikService;
21// this.passwordEncoder = passwordEncoder;
22// }
23//
24// @Override
25// public Authentication authenticate(Authentication authentication) throws AuthenticationException {
26// String username = authentication.getName();
27// String password = authentication.getCredentials().toString();
28//
29// if ("".equals(username) || "".equals(password)) {
30// throw new BadCredentialsException("Invalid Credentials");
31// }
32//
33// UserDetails userDetails = this.korisnikService.loadUserByUsername(username);
34//
35// if (!passwordEncoder.matches(password, userDetails.getPassword())) {
36// throw new BadCredentialsException("Password is incorrect!");
37// }
38// return new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
39//
40// }
41//
42// @Override
43// public boolean supports(Class<?> aClass) {
44// return aClass.equals(UsernamePasswordAuthenticationToken.class);
45// }
46//}
Note: See TracBrowser for help on using the repository browser.