From 0b241bd8b53e51cb8e8b8d875bcb0dec07fba6ff Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 12 Apr 2022 17:51:34 +0200 Subject: [PATCH] Test users databse --- src/main/java/com/covas/TokenRessource.java | 9 +++++++-- src/main/java/com/covas/Users.java | 20 ++++++++++++++++++++ src/main/resources/application.properties | 11 +++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/covas/Users.java diff --git a/src/main/java/com/covas/TokenRessource.java b/src/main/java/com/covas/TokenRessource.java index 2ecd335..833d033 100644 --- a/src/main/java/com/covas/TokenRessource.java +++ b/src/main/java/com/covas/TokenRessource.java @@ -1,16 +1,20 @@ package com.covas; +import java.time.LocalDate; +import java.time.Month; import java.util.Arrays; import java.util.HashSet; +import javax.annotation.PostConstruct; import javax.annotation.security.PermitAll; import javax.annotation.security.RolesAllowed; import javax.inject.Inject; +import javax.transaction.TransactionScoped; +import javax.transaction.Transactional; import javax.ws.rs.CookieParam; import javax.ws.rs.GET; import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; @@ -32,8 +36,9 @@ public class TokenRessource { @Inject JsonWebToken jwt; + @Inject JWTParser parser; - + @GET @Path("authentificate") diff --git a/src/main/java/com/covas/Users.java b/src/main/java/com/covas/Users.java new file mode 100644 index 0000000..d6fcee2 --- /dev/null +++ b/src/main/java/com/covas/Users.java @@ -0,0 +1,20 @@ +package com.covas; + +import java.time.LocalDate; + +import javax.persistence.Entity; + +import io.quarkus.hibernate.orm.panache.PanacheEntity; + + +@Entity +public class Users extends PanacheEntity { + public String name; + public LocalDate birth; + public Boolean status; + + public static Users findByName(String name){ + return find("name", name).firstResult(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3e147b7..3af2412 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,13 @@ smallrye.jwt.sign.key.location=privateKey.pem - mp.jwt.verify.publickey.location=publicKey.pem -mp.jwt.verify.issuer=https://example.com/issuer \ No newline at end of file +mp.jwt.verify.issuer=https://example.com/issuer + +quarkus.datasource.db-kind = postgresql +quarkus.datasource.username = toto +quarkus.datasource.password = toto +quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/toto + +# drop and create the database at startup (use `update` to only update the schema) +quarkus.hibernate-orm.database.generation = drop-and-create \ No newline at end of file