minor code improvements

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2024-08-03 10:58:15 +02:00
parent 93f6c2d603
commit 2752d80222
13 changed files with 42 additions and 45 deletions

View File

@@ -13,6 +13,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
implementation 'org.json:json:20240303'
implementation 'org.bitbucket.b_c:jose4j:0.9.6'
implementation project(':de.srsoftware.utils')
}
test {

View File

@@ -1,7 +1,9 @@
/* © SRSoftware 2024 */
package de.srsoftware.oidc.api;
import static de.srsoftware.oidc.api.Constants.*;
import static de.srsoftware.utils.Optionals.nullable;
import java.util.*;
@@ -38,7 +40,7 @@ public final class Client {
}
public Optional nonce() {
return Optional.ofNullable(nonce);
return nullable(nonce);
}
public String secret() {

View File

@@ -2,6 +2,7 @@
package de.srsoftware.oidc.api;
import static de.srsoftware.oidc.api.Constants.AUTHORIZATION;
import static de.srsoftware.utils.Optionals.nullable;
import static java.lang.System.Logger.Level.*;
import static java.net.HttpURLConnection.*;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -98,7 +99,7 @@ public abstract class PathHandler implements HttpHandler {
}
public static Optional<String> getHeader(HttpExchange ex, String key) {
return Optional.ofNullable(ex.getRequestHeaders().get(key)).map(List::stream).flatMap(Stream::findFirst);
return nullable(ex.getRequestHeaders().get(key)).map(List::stream).flatMap(Stream::findFirst);
}
public static String hostname(HttpExchange ex) {