|
|
|
@ -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);
|
|
|
|
|
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();
|
|
|
|
|