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