Code Monkey home page Code Monkey logo

jsecureapi's Introduction

JSecureAPI - Simple API for work with a JWT Token

-> Example: https://github.com/Ingur-5967/ExampleSecureAPI

=NEED A SPRING BOOT=

Request Address (URL) Answer
GET http://localhost:8080/api/token Optional[Any value]
POST http://localhost:8080/api/token Optional[Any value]

Features

  • Get value from properties file:
        ConfigurationImpl configuration = new ConfigurationImpl(Main.class);

        String parameter = String.valueOf(configuration.getValue("application.properties", "jwt.secret"));

        // ...
  • Generate a JWT token:
	ConfigurationImpl configuration = new ConfigurationImpl(Main.class);

        String parameter = String.valueOf(configuration.getValue("application.properties", "jwt.secret"));

        SecureManager secureManager = new SecureManager(parameter);

        String key = secureManager.generateSecureKey(new SecureEntity() {
            @Override
            public String getId() {
                return "TestId";
            }

            @Override
            public Map<String, Object> getParameters() {
                return Map.of("name", "Plotter", "email", "[email protected]");
            }
        }, 900000);

        // ...
  • Validate JWT Token
        ConfigurationImpl configuration = new ConfigurationImpl(Main.class);
        String parameter = String.valueOf(configuration.getValue("application.properties", "jwt.secret"));

        SecureManager secureManager = new SecureManager(parameter);

        Optional<Jws<Claims>> claims = secureManager.validator().validateKey("joined_jwt_token");

        // ...

HTTP/HTTPS Requests

  • Get and Post (HTTP)
        ServerConnection serverConnection = new ServerConnection("http://localhost:8080/.../...");
        ServerHandler serverHandler = new ServerHandler(serverConnection);

        Optional<Object> answerGet = serverHandler.http().getOfNullBody();
	Optional<Object> answerPost = serverHandler.http().sendWithBody("any_value");

        // ...
  • Get and Post (HTTPS)
        ServerConnection serverConnection = new ServerConnection("https://localhost:8080/.../...");
        ServerHandler serverHandler = new ServerHandler(serverConnection);

        Optional<Object> answerSecureGet = serverHandler.https("your_ssl_path").getWithSecure();
	Optional<Object> answerSecurePost = serverHandler.https("your_ssl_path").sendWithSecure("any_value");

        // ...

Maven/Gradle

Maven

<repositories>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
</repositories>

<dependencies>
	<dependency>
	    <groupId>com.github.Ingur-5967</groupId>
	    <artifactId>JSecureAPI</artifactId>
	    <version>1.0.9</version>
	</dependency>
</dependencies>

Gradle

dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

dependencies {
	implementation 'com.github.Ingur-5967:JSecureAPI:1.0.9'
}

jsecureapi's People

Contributors

ingur-5967 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.