You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.1 KiB
51 lines
2.1 KiB
8 months ago
|
package com.fanruan.hihidata.sso.controller;
|
||
8 months ago
|
|
||
8 months ago
|
import com.fanruan.hihidata.sso.service.SSOService;
|
||
|
import com.fanruan.hihidata.sso.utils.OpenSAMLUtils;
|
||
8 months ago
|
import org.apache.commons.lang3.StringUtils;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.http.MediaType;
|
||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
||
|
@RestController
|
||
|
public class SSOController {
|
||
|
|
||
|
@Autowired
|
||
|
private SSOService ssoService;
|
||
|
|
||
|
@ResponseBody
|
||
|
@GetMapping(value = "/sso/saml/{registrationId}/sp/metadata", produces = MediaType.APPLICATION_XML_VALUE)
|
||
|
public void getSpMetadata(@PathVariable("registrationId") String registrationId, HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||
|
String SpMetadata = ssoService.generateSpMetadata(registrationId);
|
||
|
OpenSAMLUtils.downloadByStringContent(req, res, "sp-metadata.xml", SpMetadata);
|
||
|
}
|
||
|
|
||
|
@ResponseBody
|
||
|
@GetMapping(value = "/sso/saml/{registrationId}/iss", produces = MediaType.TEXT_HTML_VALUE)
|
||
|
public String iss(@PathVariable("registrationId") String registrationId, HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||
|
ssoService.iss(registrationId, req, res);
|
||
|
return StringUtils.EMPTY;
|
||
|
}
|
||
|
|
||
|
@ResponseBody
|
||
|
@PostMapping(value = "/sso/saml/{registrationId}/acs")
|
||
|
public String acs(@PathVariable("registrationId") String registrationId, HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||
|
return ssoService.acs(registrationId, req, res);
|
||
|
}
|
||
|
|
||
|
@ResponseBody
|
||
|
@GetMapping(value = "/sso/saml/{registrationId}/slo")
|
||
|
public String slo(@PathVariable("registrationId") String registrationId, HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||
|
ssoService.slo(registrationId, req, res);
|
||
|
return StringUtils.EMPTY;
|
||
|
}
|
||
|
|
||
|
}
|