code: @Override
      public HttpResponse loginSucceeded(ServiceRequestContext ctx, AggregatedHttpMessage req,
                                         MessageContext<Response> message, @Nullable String sessionIndex,
                                         @Nullable String relayState) {
          final String username =
                  getNameId(message.getMessage(), SamlNameIdFormat.EMAIL).map(NameIDType::getValue)
                                                                         .orElse(null);
          if (username == null) {
              return HttpResponse.of(HttpStatus.UNAUTHORIZED, MediaType.HTML_UTF_8,
                                     "<html><body>Username is not found.</body></html>");
          }
  
          logger.info("{} user '{}' has been logged in.", ctx, username);
  
          final Cookie cookie = new DefaultCookie("username", username);
          cookie.setHttpOnly(true);
          cookie.setDomain("localhost");
          cookie.setMaxAge(60);
          cookie.setPath("/");
          return HttpResponse.of(
                  HttpHeaders.of(HttpStatus.OK)
                             .contentType(MediaType.HTML_UTF_8)
                             .add(HttpHeaderNames.SET_COOKIE, ServerCookieEncoder.LAX.encode(cookie)),
                  HttpData.ofUtf8("<html><body onLoad=\"window.location.href='/welcome'\"></body></html>"));
      }
docs: Invoked when the SAML authentication process is finished and a user is authenticated. You can get
  information about the authenticated user from the {@link Response}, especially his or her login name.
  In this example, an email address is used as a login name. The login name is transferred to a web
  browser via {@code Set-Cookie} header.