package org.keycloak.protocol.cas.utils; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.util.DefaultIndenter; import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBException; import jakarta.xml.bind.Marshaller; import org.keycloak.protocol.cas.representations.CASServiceResponse; import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; /** * Helper methods to marshal service response object to XML/JSON
casModel = new HashMap<>(); casModel.put("serviceResponse", serviceResponse); try { return mapper.writer(printer).writeValueAsString(casModel); } catch (JsonProcessingException e) { throw new RuntimeException(e); } } }