Metadata 优化

This commit is contained in:
Crystal.Sea 2020-11-22 18:55:12 +08:00
parent 0d55e1a4c2
commit 4f34978336
2 changed files with 6 additions and 8 deletions

View File

@ -47,7 +47,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.bind.annotation.ResponseBody;
@Controller @Controller
@ -73,7 +73,8 @@ public class MetadataEndpoint {
public static String IDP_METADATA_PREFIX = "Idp_Metadata_"; public static String IDP_METADATA_PREFIX = "Idp_Metadata_";
@RequestMapping(value = "/{appid}.xml",produces = "application/xml") @RequestMapping(value = "/{appid}.xml",produces = "application/xml")
public ModelAndView metadata(HttpServletRequest request, @ResponseBody
public String metadata(HttpServletRequest request,
HttpServletResponse response, @PathVariable("appid") String appId) { HttpServletResponse response, @PathVariable("appid") String appId) {
response.setContentType(ContentType.APPLICATION_XML_UTF8); response.setContentType(ContentType.APPLICATION_XML_UTF8);
appId = appId.substring(IDP_METADATA_PREFIX.length(), appId.length()); appId = appId.substring(IDP_METADATA_PREFIX.length(), appId.length());
@ -158,15 +159,13 @@ public class MetadataEndpoint {
logger.trace("EntityDescriptor element XML : \\n"); logger.trace("EntityDescriptor element XML : \\n");
logger.trace(entityDescriptorXml); logger.trace(entityDescriptorXml);
ModelAndView mv = new ModelAndView("trusts/saml_v20_metadata"); return entityDescriptorXml;
mv.addObject("metadata", entityDescriptorXml);
return mv;
}catch (Exception e) { }catch (Exception e) {
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
} }
return null; return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
} }
/** /**