{"id":22191671,"url":"https://github.com/leosimoes/udemy-java-spring-helpdesk","last_synced_at":"2026-05-09T01:10:36.728Z","repository":{"id":205623282,"uuid":"714057634","full_name":"leosimoes/Udemy-Java-Spring-HelpDesk","owner":"leosimoes","description":"Back-end project for the Udemy course \"Angular 5, JWT, Spring Boot, REST, Security, Data and MongoDB\".","archived":false,"fork":false,"pushed_at":"2023-12-30T20:27:35.000Z","size":1315,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T01:16:41.662Z","etag":null,"topics":["java","jwt","mongodb","restful-api","spring"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leosimoes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-03T20:26:44.000Z","updated_at":"2024-02-20T12:58:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb0caf7b-fc03-4703-bb3a-8932f714f27a","html_url":"https://github.com/leosimoes/Udemy-Java-Spring-HelpDesk","commit_stats":null,"previous_names":["leosimoes/udemy-java-spring-helpdesk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Spring-HelpDesk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Spring-HelpDesk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Spring-HelpDesk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leosimoes%2FUdemy-Java-Spring-HelpDesk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leosimoes","download_url":"https://codeload.github.com/leosimoes/Udemy-Java-Spring-HelpDesk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245351757,"owners_count":20601088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","jwt","mongodb","restful-api","spring"],"created_at":"2024-12-02T12:17:16.310Z","updated_at":"2026-05-09T01:10:31.697Z","avatar_url":"https://github.com/leosimoes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Udemy - Help Desk - Back-end with Spring\n\n## Project Starter\n![IntelliJ-Project-Configuration](imgs/IntelliJ-Spring-Initializr-1.jpg)\n\n![IntelliJ-Project-Dependencies](imgs/IntelliJ-Spring-Initializr-2.jpg)\n\n\n## MongoDB\n- Download MongoDB Community Server: https://www.mongodb.com/try/download/community\n- Install MongoDB Community Server with MongoDB Compass.\n- Run MongoDB Compass and connect:\n\n![Image-MongoDbCompass](imgs/MongoDbCompass.jpg)\n\n\n## Steps\n1. Install JDK, IDE (IntelliJ) and MongoDB.\n2. Create project with the specifications shown previously.\n3. Add MongoDB to the project:\n- Add dependency `implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'` in `build.grade`.\n- Configure `application.properties`:\n```properties\nspring.data.mongodb.host=localhost\nspring.data.mongodb.port=27017\nspring.data.mongodb.database=local\n```\n4. Add validator:\n- Add the dependency `implementation group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'` in `build.grade`.\n5. Create `ProfileEnum`, with 3 possible values, and in the `api.enums` package:\n\n![Image-UML-Diagram-Class-ProfileEnum](imgs/UML-Diagram-Class-ProfileEnum.jpg)\n\n6. Add User class:\n- with attributes `id`, `email`, `password` and `profile`;\n- in the `api.entities` package;\n- annotated with `@Document` for MongoDB;\n- annotated with `@Data`, `@NoArgsConstructor`, `@AllArgsConstructor` for Lombok.\n\n![Image-UML-Diagram-Class-User](imgs/UML-Diagram-Class-User.jpg)\n\n7. Create `PriorityEnum`, with 3 possible values, and in the `api.enums` package:\n\n![Image-UML-Diagram-Class-PriorityEnum](imgs/UML-Diagram-Class-PriorityEnum.jpg)\n\n8. Create `StatusEnum`, with 6 possible values, and in the `api.enums` package:\n   \n![Image-UML-Diagram-Class-StatusEnum](imgs/UML-Diagram-Class-StatusEnum.jpg)\n\n9. Add `Ticket` class:\n- with attributes `user`, `assignedUser`, `date`, `title`, `number`, `status`, `priority`, `description`, `image`;\n- in the `api.entities` package;\n- annotated with `@Document` for MongoDB;\n- annotated with `@Data`, `@NoArgsConstructor`, `@AllArgsConstructor` for Lombok.\n\n![Image-UML-Diagram-Class-Ticket](imgs/UML-Diagram-Class-Ticket.jpg)\n\n10. Add `ChangeStatus` class:\n- with attributes `id`, `ticket`, `userChange`, `dateChangeStatus`, `status`;\n- in the `api.entities` package;\n- annotated with `@Document` for MongoDB;\n- annotated with `@Data`, `@NoArgsConstructor`, `@AllArgsConstructor` for Lombok.\n- as a List attribute in the `Ticket` class and annotated with `@Transient`.\n\n![Image-UML-Diagram-Class-ChangeStatus](imgs/UML-Diagram-Class-ChangeStatus.jpg)\n\n11. Create UserRepository interface\n- in the `api.repositories` package;\n- extends `MongoRepository`;\n- annotated with `@Repository`;\n- with `findByEmail` method.\n\n![Image-UML-Diagram-Interface-UserRepository](imgs/UML-Diagram-Interface-UserRepository.jpg)\n\n12. Create `TicketRepository` interface:\n- in the `api.repositories` package;\n- extends `MongoRepository`;\n- annotated with `@Repository`;\n- with methods:\n    * `findByUserIdOrderByDateDesc`;\n    * `findByTitleIgnoreCaseContainingAndStatusAndPriorityOrderByDateDesc`;\n    * `findByTitleIgnoreCaseContainingAndStatusAndPriorityAndUserIdOrderByDateDesc`;\n    * `findByTitleIgnoreCaseContainingAndStatusAndPriorityAndAssignedUserIdOrderByDateDesc`;\n    * `findByNumber`.\n\n![Image-UML-Diagram-Interface-TicketRepository](imgs/UML-Diagram-Interface-TicketRepository.jpg)\n\n13. Create `ChangeStatusRepository` interface:\n- in the `api.repositories` package;\n- extends `MongoRepository`;\n- annotated with `@Repository`;\n- with `findByTicketIdOrderByDateChangeStatusDesc` method.\n\n![Image-UML-Diagram-Interface-ChangeStatusRepository](imgs/UML-Diagram-Interface-ChangeStatusRepository.jpg)\n\n14. Add `UserService` interface and `UserServiceImpl` class:\n- in the `api.services` package;\n- with methods `findByEmail`, `findById`, `createOrUpdate`, `delete`, `findAll`.\n\n![Image-UML-Diagram-Class-Interface-UserService](imgs/UML-Diagram-Class-Interface-UserService.jpg)\n\nNote: In stateless authentication (does not maintain states), which does not depend on session,\njwt contains user access data that must be stored somewhere\nto be shared between requests.\n\n15. Add jwt requirements for application security:\n- dependency on `build.gradle`:\n```\nimplementation 'io.jsonwebtoken:jjwt-api:0.12.3'\nruntimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'\nruntimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'\n```\n- settings to `application.properties`:\n```properties\njwt.secret=helpDeskLeo\njwt.expiration=604800\n```\n\n16. Create `JwtUser` class:\n- in the `api.security.jwt` package;\n- implements `UserDetais`;\n- with a `static final long serialVersionUID = -7471177486146141709L` attribute;\n- with other attributes `id`, `username`, `password`, `authorities`.\n\n![Image-UML-Diagram-Class-JwtUser](imgs/UML-Diagram-Class-JwtUser.jpg)\n\n17. Create `JwrUserFactory` class:\n- in the `api.security.jwt` package;\n- with `static JwtUser create(User user)` method;\n- with method `static List\u003cGrantedAuthority\u003e mapToGrantedAuthorities(ProfileEnum profileEnum)`.\n\n![Image-UML-Diagram-Class-JwtUserFactory](imgs/UML-Diagram-Class-JwtUserFactory.jpg)\n\n18. Create `JwtTokenUtil` class:\n- implements `Serializable`;\n- with the attributes:\n  * `private static final long serialVersionUID = 1L`;\n  * `static final String CLAIM_KEY_USERNAME = \"sub\"`;\n  * `static final String CLAIM_KEY_CREATED = \"create\"`;\n  * `static final String CLAIM_KEY_EXPIRED = \"exp\"`;\n  * `private String secret`;\n  * `private Long expiration`;\n- annotated with `@Component`.\n\n![Image-UML-Diagram-Class-JwtTokenUtil](imgs/UML-Diagram-Class-JwtTokenUtil.jpg)\n\n19. Create class `JwtUserDetailsServiceImpl`:\n- implement `UserDetailsService`;\n- has an attribute of the `UserService` class.\n\n![Image-UML-Diagram-Class-JwtUserDetailsServiceImpl](imgs/UML-Diagram-Class-JwtUserDetailsServiceImpl.jpg)\n\n20. Create `JwtAuthenticationEntryPoint` class:\n- implements `AuthenticationEntryPoint` and `Serializable`;\n- has a `private static final long serialVersionUID = 1L` attribute.\n\n![Image-UML-Diagram-Class-JwtAuthenticationEntryPoint](imgs/UML-Diagram-Class-JwtAuthenticationEntryPoint.jpg)\n\n21. Create `JwtAuthenticationTokenFilter` class:\n- extends `OncePerRequestFilter`;\n- has attributes from the `UserDetailsService` and `JwtTokenUtil` classes.\n- annotated with `@Component`.\n\n![Image-UML-Diagram-Class-JwtAuthenticationTokenFilter](imgs/UML-Diagram-Class-JwtAuthenticationTokenFilter.jpg)\n\n22. Add `WebSecurityConfiguration` class:\n- with attributes of the classes `JwtAuthenticationEntryPoint`, `UserDetailsService`, `JwtAuthenticationTokenFilter`;\n- has the methods `protected SecurityFilterChain filterChain(HttpSecurity http)` and `public PasswordEncoder encoder()`.\n- annotated with `@Configuration` and `@EnableWebSecurity`.\n\n![Image-UML-Diagram-Class-WebSecurityConfiguration](imgs/UML-Diagram-Class-WebSecurityConfiguration.jpg)\n\n23. Add `JwtAuthenticationRequest` class:\n- with attributes `private static final long serialVersionUID = 1L`, `private String email`, `private String password`;\n- with default constructor and constructor with parameters `String email`, `String password`.\n\n![Image-UML-Diagram-Class-JwtAuthenticationRequest](imgs/UML-Diagram-Class-JwtAuthenticationRequest.jpg)\n\n24. Add `CurrentUser` class:\n- in the `api.security.models` package;\n- with attributes `private String token`, `private User user`;\n- with default constructor and constructor with parameters `String token`, `User user`.\n\n![Image-UML-Diagram-Class-CurrentUser](imgs/UML-Diagram-Class-CurrentUser.jpg)\n\n25. Add `AuthenticationRestController` class:\n- in the `api.security.controllers` package;\n- with attributes of the classes `AuthenticationManager`, `JwtTokenUtil`, `UserDetailsService`, `UserService`;\n- with the constructor with all attributes as parameters;\n- annotated with `@RestController` and `@CrossOrigin(origins = \"*\")`.\n\n![Image-UML-Diagram-Class-AuthenticationRestController](imgs/UML-Diagram-Class-AuthenticationRestController.jpg)\n\n26. Change `UdemyJavaSpringHelpDeskApplication` class:\n- add method `void initUsers(UserRepository userRepository, PasswordEncoder passwordEncoder)`;\n- add method `CommandLineRunner init(UserRepository userRepository, PasswordEncoder passwordEncoder)` annotated with `@Bean`.\n\n![Image-UML-Diagram-Class-UdemyJavaSpringHelpDeskApplication](imgs/UML-Diagram-Class-UdemyJavaSpringHelpDeskApplication.jpg)\n\n27. Add `SimpleCORSFilter` class:\n- in the `api.security.filters` package;\n- implements `Filter`;\n- with attribute `private final Log logger = LogFactory.getLog(this.getClass())`;\n- annotated with `@@Component` and `@Order(Ordered.HIGHEST_PRECEDENCE)`.\n\n![Image-UML-Diagram-Class-SimpleCORSFilter](imgs/UML-Diagram-Class-SimpleCORSFilter.jpg)\n\n\n## References\nUdemy - Angular 5, JWT, Spring Boot,REST,Security,Data e MongoDB - Francis Klay Rocha:\nhttps://www.udemy.com/course/angular-5-jwt-spring-rest/\n\nMVN Repository - JJWT :: API » 0.12.3:\nhttps://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api/0.12.3\n\nMVN Repository - JJWT :: Impl » 0.12.3:\nhttps://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-impl/0.12.3\n\nMVN Repository - JJWT :: Extensions :: Jackson » 0.12.3\nhttps://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-jackson/0.12.3\n\nStack Overflow - Question 72381114:\nhttps://stackoverflow.com/questions/72381114/spring-security-upgrading-the-deprecated-websecurityconfigureradapter-in-spring\n\nAlura - Fórum - 228994:\nhttps://cursos.alura.com.br/forum/topico-springboot-2-7-injetar-authenticationmanager-sem-o-websecurityconfigureradapter-228994\n\nGitHub -  klayrocha - angular-spring-api:\nhttps://github.com/klayrocha/angular-spring-api/tree/master\n\nJava Doc - io.jsonwebtoken - jjwt-api - 0.12.3:\nhttps://javadoc.io/doc/io.jsonwebtoken/jjwt-api/latest/deprecated-list.html\n\nApps developer blog - Add and validate custom claims in jwt\nhttps://www.appsdeveloperblog.com/add-and-validate-custom-claims-in-jwt/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleosimoes%2Fudemy-java-spring-helpdesk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleosimoes%2Fudemy-java-spring-helpdesk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleosimoes%2Fudemy-java-spring-helpdesk/lists"}