This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AuthenticationTokenFilter extends UsernamePasswordAuthenticationFilter { | |
| @Override | |
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | |
| HttpServletRequest httpRequest = (HttpServletRequest) request; | |
| String authorizationToken = httpRequest.getHeader(HttpHeaders.AUTHORIZATION); | |
| if (authorizationToken != null && authorizationToken.equals("winteriscoming")) { | |
| SecurityContextHolder.getContext() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RestController | |
| public class LoginController { | |
| @Autowired | |
| private AuthenticationManager authenticationManager; | |
| @PostMapping("/token") | |
| public ResponseEntity<?> authenticate(@RequestBody LoginDto loginDto) { | |
| // Perform the authentication | |
| UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class JwtUtils { | |
| private static String SECRET = "winteriscoming"; | |
| private static int EXPIRATION = 60 * 60 * 1000; // 1 hour | |
| public static String generateToken(final JwtDto jwtDto) { | |
| Claims claims = Jwts.claims().setSubject(jwtDto.getUsername()); | |
| claims.put("userId", jwtDto.getUserId() + ""); | |
| claims.put("role", jwtDto.getRole()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <header class="header clearfix"> | |
| <nav> | |
| <ul class="nav nav-pills float-right"> | |
| <li class="nav-item"> | |
| <a class="nav-link" href="/">Home</a> | |
| </li> | |
| <li class="nav-item"> | |
| <a class="nav-link" href="/employees">Employees</a> | |
| </li> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
| <meta name="description" content=""> | |
| <meta name="author" content=""> | |
| <title>EMS</title> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #logging.level.root = WARN | |
| logging.level.org.springframework.web = ERROR | |
| logging.level.com.manjula = DEBUG | |
| # Logging pattern for the console | |
| logging.pattern.console = %yellow(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %magenta(%logger{36}) - %green(%.-100msg) %n | |
| # Logging pattern for file | |
| logging.pattern.file = %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <configuration> | |
| <property name="LOG_HOME" value="${user.home}/logs"/> | |
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| <encoder> | |
| <pattern>%yellow(%d{yyyy-MM-dd HH:mm:ss}) %highlight(%-5level) %magenta(%logger{36}) - %green(%.-100msg) %n</pattern> | |
| </encoder> | |
| </appender> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <configuration> | |
| <springprofile name="dev"> | |
| <root level="info"> | |
| <appender-ref ref="STDOUT"> | |
| <appender-ref ref="SAVE-TO-FILE"> | |
| </appender-ref></appender-ref></root> | |
| <logger additivity="false" level="debug" name="com.manjula.service"> | |
| <appender-ref ref="STDOUT"> | |
| <appender-ref ref="SAVE-TO-FILE"> | |
| </appender-ref></appender-ref></logger> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
| <meta name="description" content=""> | |
| <meta name="author" content=""> | |
| <title>EMS</title> |