Package com.Server.controller
Class AuthenticationController
java.lang.Object
com.Server.controller.AuthenticationController
@CrossOrigin(origins="*",
maxAge=3600L)
@RestController
public class AuthenticationController
extends java.lang.Object
AuthenticationController is use to authentication and register user.
- Since:
- 2020-04-27.
- Version:
- 2.0.
- Author:
- Krystian Cwioro Kamil Bieniasz Damian Mierzynski.
-
Field Summary
Fields Modifier and Type Field Description private org.springframework.security.authentication.AuthenticationManagerauthenticationManagerAuthenticationManager us to authenticationprivate CarServicecarServiceImplCarService operation on database table Carprivate org.springframework.security.crypto.password.PasswordEncoderencoderPasswordEncoder encoder passwordprivate JwtUtilsjwtUtilsJwtUtils generate tokenprivate LocalizationServicelocalizationServiceImplLocationSercive operation on database table Localizationprivate static org.slf4j.LoggerloggerLogger use to logger on server.private RoleServiceroleServiceImplRoleService operation on database table Roleprivate SendMailImplsendMailImplSendMail use to send mailprivate UserServiceuserServiceImplUserService operation on database table User -
Constructor Summary
Constructors Constructor Description AuthenticationController(org.springframework.security.authentication.AuthenticationManager authenticationManager, JwtUtils jwtUtils, UserService userServiceImpl, LocalizationService localizationServiceImpl, RoleService roleServiceImpl, org.springframework.security.crypto.password.PasswordEncoder encoder, CarService carServiceImpl, SendMailImpl sendMailImpl)Constructor -
Method Summary
Modifier and Type Method Description org.springframework.http.ResponseEntity<?>authenticateUser(LoginRequest loginRequest)This method is use to login / authentication user.org.springframework.http.ResponseEntity<?>registerUser(UserRequest userRequest)This method is use to register user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
logger
private static final org.slf4j.Logger loggerLogger use to logger on server. -
authenticationManager
private final org.springframework.security.authentication.AuthenticationManager authenticationManagerAuthenticationManager us to authentication -
jwtUtils
JwtUtils generate token -
userServiceImpl
UserService operation on database table User -
localizationServiceImpl
LocationSercive operation on database table Localization -
roleServiceImpl
RoleService operation on database table Role -
encoder
private final org.springframework.security.crypto.password.PasswordEncoder encoderPasswordEncoder encoder password -
carServiceImpl
CarService operation on database table Car -
sendMailImpl
SendMail use to send mail
-
-
Constructor Details
-
AuthenticationController
@Autowired public AuthenticationController(org.springframework.security.authentication.AuthenticationManager authenticationManager, JwtUtils jwtUtils, UserService userServiceImpl, LocalizationService localizationServiceImpl, RoleService roleServiceImpl, org.springframework.security.crypto.password.PasswordEncoder encoder, CarService carServiceImpl, SendMailImpl sendMailImpl)Constructor
-
-
Method Details
-
authenticateUser
@ResponseBody @PostMapping("/authentication") public org.springframework.http.ResponseEntity<?> authenticateUser(@RequestBody LoginRequest loginRequest)This method is use to login / authentication user. This method use endpoint /authentication.- Parameters:
loginRequest- Data witch login user (username,password).- Returns:
- JwtResponse witch token number and user data Http.Status 200.
-
registerUser
@ResponseBody @PostMapping("/register") public org.springframework.http.ResponseEntity<?> registerUser(@RequestBody UserRequest userRequest)This method is use to register user. This method use endpoint /register.- Parameters:
userRequest- user data.- Returns:
- user data Http.Status 200 or 400.
- Throws:
WrongDataException- when user not exist
-