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

master
mjkhan21 2 months ago
parent 58aefd3959
commit 971cd4402d

@ -57,6 +57,17 @@
<version>23.04.01-SNAPSHOT</version>
</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>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>

@ -11,7 +11,7 @@ public class SaeolMessenger {
public void send(SaeolMessage msg) {
String interfaceID = msg.interfaceID(),
xml = xmlSupport.stringify(msg.getRequest(), true);
xml = xmlSupport.stringify(msg.getRequest());
HttpResponse<String> hresp = webClient.post(req ->
req.uri(Configuration.target().getUrl(interfaceID))
@ -26,6 +26,6 @@ public class SaeolMessenger {
.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.interfaces.gpki.GPKI;
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;
public class XmlSupport extends AbstractComponent {
@ -49,10 +47,10 @@ public class XmlSupport extends AbstractComponent {
return str.substring(start, end);
}
public String stringify(SaeolMessage.Request request, boolean encrypt) {
public String stringify(SaeolMessage.Request request) {
return ENVELOPE
.replace("{header}", stringify(request.header()))
.replace("{message-body}", toString(request, encrypt));
.replace("{message-body}", toString(request));
}
private String stringify(SaeolMessage.Header header) {
@ -61,7 +59,7 @@ public class XmlSupport extends AbstractComponent {
.replace("\n</Header>", "");
}
private String toString(SaeolMessage.Request request, boolean encrypt) {
private String toString(SaeolMessage.Request request) {
String className = request.getClass().getSimpleName(),
messageBody = xml.stringify(request, true);
@ -73,15 +71,14 @@ public class XmlSupport extends AbstractComponent {
messageBody = "<message>\n <body>\n " + messageBody;
messageBody += "\n </body>\n</message>";
if (encrypt)
messageBody = encrypt(messageBody);
return messageBody;
}
public void parse(SaeolMessage msg, String resp, boolean decrypt) {
public void parse(SaeolMessage msg, String resp) {
SaeolMessage.Header header = parseHeader(resp);
parseBody(msg, resp, decrypt);
parseBody(msg, resp);
msg.getResponse().setHeader(header);
}
@ -91,10 +88,8 @@ public class XmlSupport extends AbstractComponent {
return xml.parse(head, SaeolMessage.Header.class);
}
private void parseBody(SaeolMessage msg, String resp, boolean decrypt) {
String body = textBetween(resp, "<DATA>", "</DATA>");
if (decrypt)
body = decrypt(body);
private void parseBody(SaeolMessage msg, String resp) {
String body = decrypt(textBetween(resp, "<DATA>", "</DATA>"));
Class<? extends Response> klass = msg.responseType();
String className = klass.getSimpleName();

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

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