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.AuthenticationManager authenticationManager
    AuthenticationManager us to authentication
    private CarService carServiceImpl
    CarService operation on database table Car
    private org.springframework.security.crypto.password.PasswordEncoder encoder
    PasswordEncoder encoder password
    private JwtUtils jwtUtils
    JwtUtils generate token
    private LocalizationService localizationServiceImpl
    LocationSercive operation on database table Localization
    private static org.slf4j.Logger logger
    Logger use to logger on server.
    private RoleService roleServiceImpl
    RoleService operation on database table Role
    private SendMailImpl sendMailImpl
    SendMail use to send mail
    private UserService userServiceImpl
    UserService 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 logger
      Logger use to logger on server.
    • authenticationManager

      private final org.springframework.security.authentication.AuthenticationManager authenticationManager
      AuthenticationManager us to authentication
    • jwtUtils

      private final JwtUtils jwtUtils
      JwtUtils generate token
    • userServiceImpl

      private final UserService userServiceImpl
      UserService operation on database table User
    • localizationServiceImpl

      private final LocalizationService localizationServiceImpl
      LocationSercive operation on database table Localization
    • roleServiceImpl

      private final RoleService roleServiceImpl
      RoleService operation on database table Role
    • encoder

      private final org.springframework.security.crypto.password.PasswordEncoder encoder
      PasswordEncoder encoder password
    • carServiceImpl

      private final CarService carServiceImpl
      CarService operation on database table Car
    • sendMailImpl

      private final SendMailImpl 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