updated library de.srsoftware.tools.http

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-03-27 12:57:56 +01:00
parent 20f5d0efcf
commit c12bbb65b3
14 changed files with 66 additions and 69 deletions

View File

@@ -1,7 +1,7 @@
description = "SRSoftware OIDC: web module"
dependencies{
implementation("de.srsoftware:tools.http:1.3.0")
implementation("de.srsoftware:tools.http:1.5.4")
implementation(project(":de.srsoftware.oidc.api"))
}

View File

@@ -4,6 +4,7 @@ package de.srsoftware.oidc.web;
import static java.lang.System.Logger.Level.INFO;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.tools.Path;
import de.srsoftware.tools.PathHandler;
import java.io.IOException;
@@ -16,7 +17,7 @@ public class Forward extends PathHandler {
}
@Override
public boolean doGet(String path, HttpExchange ex) throws IOException {
public boolean doGet(Path path, HttpExchange ex) throws IOException {
LOG.log(INFO, "Forwarding ({0}}) {1} to {2}…", CODE, path, toPath);
return sendRedirect(ex, toPath);
}

View File

@@ -26,22 +26,20 @@ public class StaticPages extends PathHandler implements ResourceLoader {
}
private static final String INDEX = "en/index.html";
private static final String INDEX = "index.html";
@Override
public boolean doGet(String relativePath, HttpExchange ex) throws IOException {
public boolean doGet(de.srsoftware.tools.Path relativePath, HttpExchange ex) throws IOException {
var relPath = relativePath.toString();
String lang = language(ex);
if (relativePath.startsWith("/")) relativePath = relativePath.substring(1);
if (relativePath.isBlank()) {
relativePath = ex.getRequestURI().toString().endsWith(FAVICON) ? FAVICON : INDEX;
}
if (relPath.isBlank()) relPath = ex.getRequestURI().toString().endsWith(FAVICON) ? FAVICON : INDEX;
try {
Resource resource = loadFile(lang, relativePath).orElseThrow(() -> new FileNotFoundException());
Resource resource = loadFile(lang, relPath).orElseThrow(() -> new FileNotFoundException());
ex.getResponseHeaders().add(CONTENT_TYPE, resource.contentType());
LOG.log(DEBUG, "Loaded {0} for language {1}…success.", relativePath, lang);
LOG.log(DEBUG, "Loaded {0} for language {1}…success.", relPath, lang);
return sendContent(ex, resource.content());
} catch (FileNotFoundException fnf) {
LOG.log(WARNING, "Loaded {0} for language {1}…failed.", relativePath, lang);
LOG.log(WARNING, "Loaded {0} for language {1}…failed.", relPath, lang);
return notFound(ex);
}
}

View File

@@ -45,7 +45,7 @@
</tr>
</table>
<span class="hidden" id="message">Really remove client "{}"?</span>
<span class="hidden" id="message">Benutzer "{}" wirklich löschen?</span>
<span class="error" style="display: none" id="missing_user_id">Server did not receive a valid user_id for removal!</span>
<span class="error" style="display: none" id="missing_confirmation">Server did not receive confirmation for this request!</span>
<span class="error" style="display: none" id="unknown_user">The backend does not know this user!</span>

View File

@@ -45,7 +45,7 @@
</tr>
</table>
<span class="hidden" id="message">Really remove client "{}"?</span>
<span class="hidden" id="message">Really remove user "{}"?</span>
<span class="error" style="display: none" id="missing_user_id">Server did not receive a valid user_id for removal!</span>
<span class="error" style="display: none" id="missing_confirmation">Server did not receive confirmation for this request!</span>
<span class="error" style="display: none" id="unknown_user">The backend does not know this user!</span>