This commit is contained in:
Magi1053 2024-04-21 16:45:07 -05:00 committed by GitHub
commit b82aec0da2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.util.Base64;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@ -67,6 +68,15 @@ public class OauthHttpHandler {
response = "Unable to fetch resource login.html".getBytes(Charsets.UTF_8);
}
InputStream iconStream = Launcher.class.getResourceAsStream("icon.png");
if (iconStream != null) {
byte[] iconBytes = IOUtils.toByteArray(iconStream);
String encodedIcon = Base64.getEncoder().encodeToString(iconBytes);
response = String.format(new String(response), encodedIcon).getBytes();
} else {
log.warning("Unable to fetch resource icon.png");
}
httpExchange.sendResponseHeaders(200, response.length);
httpExchange.getResponseBody().write(response);
httpExchange.getResponseBody().flush();

View File

@ -1 +1,24 @@
<p>OK: you can close the browser now</p>
<html>
<head>
<meta charset="UTF-8"/>
<title>You can now close your browser</title>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: nowrap;
text-align: center;
font-family: system-ui;
background-color: #0e0e0e;
color: #eee;
}
</style>
</head>
<body>
<main>
<img src="data:image/png;base64,%s" alt="icon.png" onerror="this.style.display='none'">
<h2>You can now close your browser</h2>
</main>
</body>
</html>