Browse Source
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>feature/brute_force_protection
11 changed files with 157 additions and 42 deletions
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
/* © SRSoftware 2025 */ |
||||
package de.srsoftware.umbrella.legacy; |
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.URI; |
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException; |
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable; |
||||
|
||||
import com.sun.net.httpserver.HttpExchange; |
||||
import de.srsoftware.configuration.Configuration; |
||||
import de.srsoftware.tools.Path; |
||||
import de.srsoftware.umbrella.core.BaseHandler; |
||||
import de.srsoftware.umbrella.core.ModuleRegistry; |
||||
import java.io.IOException; |
||||
|
||||
public class NotesLegacy extends BaseHandler { |
||||
private final ModuleRegistry registry; |
||||
private final Configuration config; |
||||
|
||||
public NotesLegacy(ModuleRegistry registry, Configuration config) { |
||||
this.registry = registry; |
||||
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules")); |
||||
} |
||||
|
||||
@Override |
||||
public boolean doDelete(Path path, HttpExchange ex) throws IOException { |
||||
return super.doDelete(path, ex); |
||||
} |
||||
|
||||
@Override |
||||
public boolean doGet(Path path, HttpExchange ex) throws IOException { |
||||
return super.doGet(path, ex); |
||||
} |
||||
|
||||
@Override |
||||
public boolean doOptions(Path path, HttpExchange ex) throws IOException { |
||||
return super.doOptions(path, ex); |
||||
} |
||||
|
||||
@Override |
||||
public boolean doPatch(Path path, HttpExchange ex) throws IOException { |
||||
return super.doPatch(path, ex); |
||||
} |
||||
|
||||
@Override |
||||
public boolean doPost(Path path, HttpExchange ex) throws IOException { |
||||
addCors(ex); |
||||
var data = formData(ex); |
||||
var noteService = registry.noteService(); |
||||
if (!(data.get(URI) instanceof String uri)) throw missingFieldException(URI); |
||||
var parts = uri.split(":",2); |
||||
if (parts.length<2) throw unprocessable("Expected URI to contain colon (:)!"); |
||||
String module = parts[0]; |
||||
String entityId = parts[1]; |
||||
var notes = noteService.getNotes(module,entityId); |
||||
return super.doPost(path, ex); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue