Browse Source

Repo adjustments

master
RENOX 5 months ago
parent
commit
94c70155dd
6 changed files with 50 additions and 7 deletions
  1. +6
    -0
      pom.xml
  2. +9
    -4
      src/main/java/planetrenox/controller/FormController.java
  3. +31
    -0
      src/main/java/planetrenox/controller/RequestValidation.java
  4. +1
    -3
      src/main/java/planetrenox/mongodb/Dungeon.java
  5. +2
    -0
      src/main/java/planetrenox/mongodb/DungeonRepository.java
  6. +1
    -0
      src/main/resources/static/index.html

+ 6
- 0
pom.xml View File

@@ -45,6 +45,12 @@
<version>1.18.10</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.12.1</version>
</dependency>
</dependencies>

<build>


+ 9
- 4
src/main/java/planetrenox/controller/FormController.java View File

@@ -6,6 +6,8 @@ import planetrenox.encryption.AES256_GCM;
import planetrenox.mongodb.Dungeon;
import planetrenox.mongodb.DungeonRepository;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.Map;

@@ -17,9 +19,12 @@ public class FormController
@PostMapping(path = "/", params = {"name", "password"})
public String login(@RequestParam("name") String name, @RequestParam("password") String password)
{
Map<String, String> meta = new HashMap<>();
meta.put("sda", "Asda");
repository.save(new Dungeon("dasda", AES256_GCM.encrypt("asda", "asdas"), meta));
return "!";






return "str";
}
}

+ 31
- 0
src/main/java/planetrenox/controller/RequestValidation.java View File

@@ -0,0 +1,31 @@
package planetrenox.controller;

import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;

import java.util.Map;


public class RequestValidation
{
private static final Map<String, Boolean> LOGIN_REQ = Map.of(
"INVALID", false,
"EMPTY", false,
"NAME_LENGTH>60", false,
"PASS_LENGTH>128", false,
"ILLEGAL_NAME", false,
"ILLEGAL_PASS", false
);


public static Map<String, Boolean> validateLogin(String name, String password)
{
name = Jsoup.clean(name, Whitelist.basic());
password = Jsoup.clean(password, Whitelist.basic());


return null;
}


}

+ 1
- 3
src/main/java/planetrenox/mongodb/Dungeon.java View File

@@ -10,7 +10,6 @@ import java.util.Map;
/* This object will contain user data to be stored in db */
public class Dungeon
{

@Id @Getter @Setter private String id;
@Getter @Setter private String name;
@Getter @Setter private Date creationDate;
@@ -24,5 +23,4 @@ public class Dungeon
this.encryptionData = encryptionData;
this.meta = meta;
}

}
}

+ 2
- 0
src/main/java/planetrenox/mongodb/DungeonRepository.java View File

@@ -1,6 +1,8 @@
package planetrenox.mongodb;

import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

public interface DungeonRepository extends MongoRepository<Dungeon, String>
{


+ 1
- 0
src/main/resources/static/index.html View File

@@ -4,6 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
<title>Text Dungeon</title>
</head>



Loading…
Cancel
Save