Skip to content

Commit def5758

Browse files
AbhinabKanrarpivovarit
authored andcommitted
easy code added for simplicity (eugenp#2473)
* moving jmh into libraries module * refactoring jmh * Update pom.xml * manual algorightm * with BM result * fix for space issue * Fixed indentation * change as per suggestion * vavr either * adding unit test and othe rutilities * adding concurrent module * concurrent package description * concurrent package description * Update EitherUnitTest.java * introducing lambda expression * jooby project * jooby project * reducing employee bean content * bootique module * bootique * bootique * undertow module * undertow module * refactoring * using lambda * as per baeldung formatter * easy code added for simplicity
1 parent e6c2fd3 commit def5758

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎undertow/src/main/java/com/baeldung/undertow/secure/CustomIdentityManager.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88

99
import io.undertow.security.idm.Account;
1010
import io.undertow.security.idm.Credential;
11+
import io.undertow.security.idm.IdentityManager;
1112
import io.undertow.security.idm.PasswordCredential;
1213

13-
public class CustomIdentityManager implements io.undertow.security.idm.IdentityManager {
14+
public class CustomIdentityManager implements IdentityManager {
1415

1516
private final Map<String, char[]> users;
1617

‎undertow/src/main/java/com/baeldung/undertow/secure/SecureServer.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ public static void main(String[] args) {
2929
final IdentityManager idm = new CustomIdentityManager(users);
3030

3131
Undertow server = Undertow.builder().addHttpListener(8080, "localhost").setHandler(addSecurity((exchange) -> {
32-
final SecurityContext context = exchange.getSecurityContext();
33-
exchange.getResponseSender().send("Hello " + context.getAuthenticatedAccount().getPrincipal().getName(),
34-
IoCallback.END_EXCHANGE);
32+
setExchange(exchange);
3533
}, idm)).build();
3634

3735
server.start();
36+
}
3837

38+
private static void setExchange(HttpServerExchange exchange) {
39+
final SecurityContext context = exchange.getSecurityContext();
40+
exchange.getResponseSender().send("Hello " + context.getAuthenticatedAccount().getPrincipal().getName(),IoCallback.END_EXCHANGE);
3941
}
4042

4143
private static HttpHandler addSecurity(final HttpHandler toWrap, final IdentityManager identityManager) {

0 commit comments

Comments
 (0)