gpki 활성화 여부, xml 콘트롤러 추가

master
mjkhan21 2 months ago
parent 58aefd3959
commit 971cd4402d

@ -57,6 +57,17 @@
<version>23.04.01-SNAPSHOT</version> <version>23.04.01-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-javadoc</artifactId>
<version>1.7.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>

@ -11,7 +11,7 @@ public class SaeolMessenger {
public void send(SaeolMessage msg) { public void send(SaeolMessage msg) {
String interfaceID = msg.interfaceID(), String interfaceID = msg.interfaceID(),
xml = xmlSupport.stringify(msg.getRequest(), true); xml = xmlSupport.stringify(msg.getRequest());
HttpResponse<String> hresp = webClient.post(req -> HttpResponse<String> hresp = webClient.post(req ->
req.uri(Configuration.target().getUrl(interfaceID)) req.uri(Configuration.target().getUrl(interfaceID))
@ -26,6 +26,6 @@ public class SaeolMessenger {
.bodyData(xml) .bodyData(xml)
); );
xmlSupport.parse(msg, hresp.body(), true); xmlSupport.parse(msg, hresp.body());
} }
} }

@ -7,8 +7,6 @@ import cokr.xit.foundation.AbstractComponent;
import cokr.xit.foundation.data.XML; import cokr.xit.foundation.data.XML;
import cokr.xit.interfaces.gpki.GPKI; import cokr.xit.interfaces.gpki.GPKI;
import cokr.xit.interfaces.saeol.SaeolMessage; import cokr.xit.interfaces.saeol.SaeolMessage;
import cokr.xit.interfaces.saeol.SaeolMessage.Header;
import cokr.xit.interfaces.saeol.SaeolMessage.Request;
import cokr.xit.interfaces.saeol.SaeolMessage.Response; import cokr.xit.interfaces.saeol.SaeolMessage.Response;
public class XmlSupport extends AbstractComponent { public class XmlSupport extends AbstractComponent {
@ -49,10 +47,10 @@ public class XmlSupport extends AbstractComponent {
return str.substring(start, end); return str.substring(start, end);
} }
public String stringify(SaeolMessage.Request request, boolean encrypt) { public String stringify(SaeolMessage.Request request) {
return ENVELOPE return ENVELOPE
.replace("{header}", stringify(request.header())) .replace("{header}", stringify(request.header()))
.replace("{message-body}", toString(request, encrypt)); .replace("{message-body}", toString(request));
} }
private String stringify(SaeolMessage.Header header) { private String stringify(SaeolMessage.Header header) {
@ -61,7 +59,7 @@ public class XmlSupport extends AbstractComponent {
.replace("\n</Header>", ""); .replace("\n</Header>", "");
} }
private String toString(SaeolMessage.Request request, boolean encrypt) { private String toString(SaeolMessage.Request request) {
String className = request.getClass().getSimpleName(), String className = request.getClass().getSimpleName(),
messageBody = xml.stringify(request, true); messageBody = xml.stringify(request, true);
@ -73,15 +71,14 @@ public class XmlSupport extends AbstractComponent {
messageBody = "<message>\n <body>\n " + messageBody; messageBody = "<message>\n <body>\n " + messageBody;
messageBody += "\n </body>\n</message>"; messageBody += "\n </body>\n</message>";
if (encrypt)
messageBody = encrypt(messageBody); messageBody = encrypt(messageBody);
return messageBody; return messageBody;
} }
public void parse(SaeolMessage msg, String resp, boolean decrypt) { public void parse(SaeolMessage msg, String resp) {
SaeolMessage.Header header = parseHeader(resp); SaeolMessage.Header header = parseHeader(resp);
parseBody(msg, resp, decrypt); parseBody(msg, resp);
msg.getResponse().setHeader(header); msg.getResponse().setHeader(header);
} }
@ -91,10 +88,8 @@ public class XmlSupport extends AbstractComponent {
return xml.parse(head, SaeolMessage.Header.class); return xml.parse(head, SaeolMessage.Header.class);
} }
private void parseBody(SaeolMessage msg, String resp, boolean decrypt) { private void parseBody(SaeolMessage msg, String resp) {
String body = textBetween(resp, "<DATA>", "</DATA>"); String body = decrypt(textBetween(resp, "<DATA>", "</DATA>"));
if (decrypt)
body = decrypt(body);
Class<? extends Response> klass = msg.responseType(); Class<? extends Response> klass = msg.responseType();
String className = klass.getSimpleName(); String className = klass.getSimpleName();

@ -2,36 +2,35 @@ package cokr.xit.interfaces.saeol.web;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import cokr.xit.foundation.web.AbstractController; import cokr.xit.foundation.web.AbstractController;
import cokr.xit.interfaces.saeol.SOHNN00004; import cokr.xit.interfaces.saeol.SOHNN00004;
import cokr.xit.interfaces.saeol.SOHNN00011; import cokr.xit.interfaces.saeol.SOHNN00011;
import cokr.xit.interfaces.saeol.service.SaeolService; import cokr.xit.interfaces.saeol.service.SaeolService;
import io.swagger.v3.oas.annotations.Operation;
@RestController @RestController("saeolJsonApi")
@RequestMapping(value = {"/intf/saeol", "/intf/saeol/xml"}, name = "새올 연계") @RequestMapping(value = "/intf/saeol", name = "새올 JSON 연계", produces = MediaType.APPLICATION_JSON_VALUE)
public class SaeolController extends AbstractController { public class SaeolController extends AbstractController {
@Resource(name = "saeolService") @Resource(name = "saeolService")
private SaeolService saeolService; private SaeolService saeolService;
@PostMapping("/sohnn00004") @PostMapping("/sohnn00004")
public ModelAndView getSOHNN00004(@RequestBody SOHNN00004.Request req) { @Operation(summary = "민원목록 조회", tags = "SOHNN00004")
return new ModelAndView(viewName()) public SOHNN00004.Response getSOHNN00004(@RequestBody SOHNN00004.Request req) {
.addObject(saeolService.getSOHNN00004(req)); req.setHeader(null);
} return saeolService.getSOHNN00004(req);
private String viewName() {
return !currentAccess().getAction().contains("/xml") ? "jsonView" : "xmlView";
} }
@PostMapping("/sohnn00011") @PostMapping("/sohnn00011")
public ModelAndView getSOHNN00011(@RequestBody SOHNN00011.Request req) { @Operation(summary = "민원상세 조회", tags = "SOHNN00011")
return new ModelAndView(viewName()) public SOHNN00011.Response getSOHNN00011(@RequestBody SOHNN00011.Request req) {
.addObject(saeolService.getSOHNN00011(req)); req.setHeader(null);
return saeolService.getSOHNN00011(req);
} }
} }

@ -0,0 +1,9 @@
package cokr.xit.interfaces.saeol.web;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController("saeolXmlApi")
@RequestMapping(value = "/intf/saeol/xml", name = "새올 XML 연계", produces = MediaType.APPLICATION_XML_VALUE)
public class SaeolXmlController extends SaeolController {}

@ -1,6 +1,6 @@
{ {
"enabled": true, /* 활성화(사용) 여부 */
"license": "C:\\GPKI\\Lic", /* 이용기관 GPKI API 라이센스 디렉토리 */ "license": "C:\\GPKI\\Lic", /* 이용기관 GPKI API 라이센스 디렉토리 */
"charset": "UTF-8", /* 문자셋 */ "charset": "UTF-8", /* 문자셋 */
"server": { "server": {

@ -24,7 +24,7 @@ public class SaeolMessageTest {
@Test @Test
void request() { void request() {
List.of(new SOHNN00004(), new SOHNN00011()).forEach(msg -> List.of(new SOHNN00004(), new SOHNN00011()).forEach(msg ->
System.out.println("req msg:\n" + xmlSupport.stringify(msg.getRequest(), false)) System.out.println("req msg:\n" + xmlSupport.stringify(msg.getRequest()))
); );
} }
@ -32,10 +32,10 @@ public class SaeolMessageTest {
void response() { void response() {
List.of(new SOHNN00004(), new SOHNN00011()).forEach(msg -> { List.of(new SOHNN00004(), new SOHNN00011()).forEach(msg -> {
SaeolMessage.Request req = msg.getRequest(); SaeolMessage.Request req = msg.getRequest();
String body = xmlSupport.stringify(req, false); String body = xmlSupport.stringify(req);
xmlSupport.parse(msg, body, false); xmlSupport.parse(msg, body);
System.out.println("req msg:\n" + xmlSupport.stringify(req, false)); System.out.println("req msg:\n" + xmlSupport.stringify(req));
}); });
} }
} }
Loading…
Cancel
Save