Code Monkey home page Code Monkey logo

spring-web-service's Introduction

Demo Spring Boot Project

Demo project of a secure RESTful web service with a CRUD architecture.

Getting Started

Send a POST request to http://localhost:8080/api/auth/authenticate to get a token.

Administrator token.

{
    "login": "[email protected]",
    "password": "administrator"
}

Regular user token token.

{
    "login": "[email protected]",
    "password": "user0"
}

Test your permissions at http://localhost:8080/api/private/users

Build

Maven: mvn clean install

Run

Maven: spring-boot:run
Java: Application.java

Architecture

main
    ├───java
    │   └───com
    │       └───springwebservice
    │           │   Application.java
    │           │   ApplicationDataBaseLoader.java
    │           │   
    │           ├───controller
    │           │       HomeController.java
    │           │       UserController.java
    │           │       
    │           ├───core
    │           │   ├───abstraction
    │           │   │   │   CrudControllerAbstraction.java
    │           │   │   │   CrudCustomRepositoryAbstraction.java
    │           │   │   │   CrudServiceAbstraction.java
    │           │   │   │   SecurityControllerAbstraction.java
    │           │   │   │   
    │           │   │   └───interfaces
    │           │   │           CrudServiceInterface.java
    │           │   │           
    │           │   ├───exception
    │           │   │       BusinessException.java
    │           │   │       SecurityException.java
    │           │   │       
    │           │   ├───handler
    │           │   │       GenericExceptionHandler.java
    │           │   │       
    │           │   └───utils
    │           │           ApiUtils.java
    │           │           PropertyUtils.java
    │           │           SecurityUtils.java
    │           │           
    │           ├───entity
    │           │       PermissionEntity.java
    │           │       RoleEntity.java
    │           │       RolePermissionEntity.java
    │           │       UserEntity.java
    │           │       UserRoleEntity.java
    │           │       
    │           ├───repository
    │           │   │   PermissionRepository.java
    │           │   │   RolePermissionRepository.java
    │           │   │   RoleRepository.java
    │           │   │   UserRepository.java
    │           │   │   UserRoleRepository.java
    │           │   │   
    │           │   └───custom
    │           │       │   UserRepositoryCustomImpl.java
    │           │       │   
    │           │       └───interfaces
    │           │               UserRepositoryCustom.java
    │           │               
    │           ├───security
    │           │   │   AuthenticationLoginFilter.java
    │           │   │   AuthenticationValidatorFilter.java
    │           │   │   JwtAuthenticationService.java
    │           │   │   WebSecurityConfig.java
    │           │   │   
    │           │   └───model
    │           │           LoginModel.java
    │           │           UserAuthenticationModel.java
    │           │           
    │           └───service
    │               │   AuthenticationServiceImpl.java
    │               │   PermissionServiceImpl.java
    │               │   RolePermissionServiceImpl.java
    │               │   RoleServiceImpl.java
    │               │   UserRoleServiceImpl.java
    │               │   UserServiceImpl.java
    │               │   
    │               └───interfaces
    │                       AuthenticationService.java
    │                       PermissionService.java
    │                       RolePermissionService.java
    │                       RoleService.java
    │                       UserRoleService.java
    │                       UserService.java
    │                       
    └───resources
            application.properties

Generating Asymmetric Private Key

  • For this demo project the AsymmetricPrivateKey.pem is inside the resource folders, but for real projects it should not be.
openssl genrsa -aes256 -out AsymmetricKey.pem 2048

openssl pkcs8 -topk8 -inform PEM -outform PEM -in AsymmetricKey.pem -out AsymmetricPrivateKey.pem -nocrypt

Built With

  • Spring - Web Framework.
  • Spring Boot - Spring project to create spring-powered applications.
  • Project Lombok - Project Lombok is a java library to generate java code.
  • Apache Commons Lang - Lang provides a host of helper utilities for the java.lang API.
  • H2 Database - In-memory database.
  • JJWT - JSON Web Token for Java and Android.
  • Maven - Dependency Management.

spring-web-service's People

Contributors

italosvieira avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.