use of io.helidon.security.Subject in project helidon by oracle.
the class GoogleConfigMain method start.
static int start(int port) {
Config config = buildConfig();
Routing.Builder routing = Routing.builder().register(WebSecurity.create(config.get("security"))).get("/rest/profile", (req, res) -> {
Optional<SecurityContext> securityContext = req.context().get(SecurityContext.class);
res.headers().contentType(MediaType.TEXT_PLAIN.withCharset("UTF-8"));
res.send("Response from config based service, you are: \n" + securityContext.flatMap(SecurityContext::user).map(Subject::toString).orElse("Security context is null"));
}).register(StaticContentSupport.create("/WEB"));
theServer = GoogleUtil.startIt(port, routing);
return theServer.port();
}
Aggregations