@Override
    public HttpResponse serve(ServiceRequestContext ctx, AggregatedHttpRequest req,
                              String defaultHostname, SamlPortConfig portConfig) {
        try {
            final MessageContext<LogoutRequest> messageContext;
            if (endpoint.bindingProtocol() == SamlBindingProtocol.HTTP_REDIRECT) {
                messageContext = HttpRedirectBindingUtil.toSamlObject(req, SAML_REQUEST,
                                                                      idpConfigs, defaultIdpConfig,
                                                                      signatureRequired);
            } else {
                messageContext = HttpPostBindingUtil.toSamlObject(req, SAML_REQUEST);
            }

            final String endpointUri = endpoint.toUriString(portConfig.scheme().uriText(),
                                                            defaultHostname, portConfig.port());
            final LogoutRequest logoutRequest = messageContext.getMessage();
            final SamlIdentityProviderConfig idp = validateAndGetIdPConfig(logoutRequest, endpointUri);

            if (endpoint.bindingProtocol() != SamlBindingProtocol.HTTP_REDIRECT) {
                validateSignature(idp.signingCredential(), logoutRequest, signatureRequired);
            } else {
                // The above `HttpRedirectBindingUtil.toSamlObject()` call performed the validation already.
            }

            final SamlEndpoint sloResEndpoint = idp.sloResEndpoint();
            if (sloResEndpoint == null) {
                // No response URL. Just return 200 OK.
                return HttpResponse.of(sloHandler.logoutSucceeded(ctx, req, messageContext)
                                                 .thenApply(unused -> HttpResponse.of(HttpStatus.OK)));
            }

            final LogoutResponse logoutResponse = createLogoutResponse(logoutRequest, StatusCode.SUCCESS);
            try {
                final HttpResponse response = respond(logoutResponse, sloResEndpoint);
                return HttpResponse.of(sloHandler.logoutSucceeded(ctx, req, messageContext)
                                                 .thenApply(unused -> response));
            } catch (SamlException e) {
                logger.warn("{} Cannot respond a logout response in response to {}",
                            ctx, logoutRequest.getID(), e);
                final HttpResponse response = fail(ctx, logoutRequest, sloResEndpoint);
                return HttpResponse.of(sloHandler.logoutFailed(ctx, req, e)
                                                 .thenApply(unused -> response));
            }
        } catch (SamlException e) {
            return fail(ctx, e);
        }
    }
A service which receives a single logout request from an identity provider in order to perform a global
logout.
saml/src/main/java/com/linecorp/armeria/server/saml/SamlSingleLogoutFunction.java