Browse Source

Repo adjustments

master
RENOX 2 months ago
parent
commit
6dfdfc9a21
3 changed files with 20 additions and 3 deletions
  1. +7
    -1
      src/main/java/planetrenox/controller/FormController.java
  2. +5
    -1
      src/main/java/planetrenox/mongodb/Dungeon.java
  3. +8
    -1
      src/main/resources/application.properties

+ 7
- 1
src/main/java/planetrenox/controller/FormController.java View File

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

import java.util.HashMap;
import java.util.Map;

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

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

@@ -13,12 +13,16 @@ public class Dungeon

@Id @Getter @Setter private String id;
@Getter @Setter private String name;
@Getter @Setter private Date creationDate;
@Getter @Setter private byte[] encryptionData;
@Getter @Setter private Map<String, String> meta = new HashMap<>();

public Dungeon(String name, byte[] encryptionData)
public Dungeon(String name, byte[] encryptionData, Map<String, String> meta)
{
this.name = name;
this.creationDate = new Date();
this.encryptionData = encryptionData;
this.meta = meta;
}

}

+ 8
- 1
src/main/resources/application.properties View File

@@ -1 +1,8 @@

# https://docs.mongodb.com/manual/tutorial/enable-authentication/
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.database=textdungeondb
spring.data.mongodb.port=27017
spring.data.mongodb.host=127.0.0.1
#----------Temp----------#
spring.data.mongodb.username=mongouser
spring.data.mongodb.password=abc123

Loading…
Cancel
Save