1
2
3
4
5
6 package emissary.transform;
7
8 import emissary.core.Form;
9 import emissary.core.IBaseDataObject;
10 import emissary.place.ServiceProviderPlace;
11 import emissary.transform.decode.JavascriptEscape;
12 import emissary.util.DataUtil;
13
14 import org.apache.commons.lang3.ArrayUtils;
15
16 import java.io.IOException;
17
18 import static emissary.core.constants.Configurations.OUTPUT_FORM;
19
20 @Deprecated
21 public class JavascriptEscapePlace extends ServiceProviderPlace {
22
23
24
25
26 private String outputForm = Form.UNKNOWN;
27
28
29
30
31
32
33
34
35 public JavascriptEscapePlace(String cfgInfo, String dir, String placeLoc) throws IOException {
36 super(cfgInfo, dir, placeLoc);
37 configurePlace();
38 }
39
40
41
42
43
44
45 public JavascriptEscapePlace(String cfgInfo) throws IOException {
46 super(cfgInfo, "TestJavascriptEscapePlace.example.com:8001");
47 configurePlace();
48 }
49
50
51
52
53 public JavascriptEscapePlace() throws IOException {
54 super();
55 configurePlace();
56 }
57
58
59
60
61 protected void configurePlace() {
62 outputForm = configG.findStringEntry(OUTPUT_FORM, outputForm);
63 }
64
65
66
67
68 @Override
69 public void process(IBaseDataObject d) {
70 if (DataUtil.isEmpty(d)) {
71 logger.debug("empty data");
72 return;
73 }
74 String incomingForm = d.currentForm();
75
76 logger.debug("JavascriptEscapePlace just got a {}", incomingForm);
77
78 byte[] newData = JavascriptEscape.unescape(d.data());
79
80 if (ArrayUtils.isNotEmpty(newData)) {
81 d.setData(newData);
82
83 if (outputForm != null) {
84 d.setCurrentForm(outputForm);
85 }
86 } else {
87 logger.warn("error doing JavascriptEscape, unable to decode");
88 d.pushCurrentForm(Form.ERROR);
89 }
90 }
91
92
93 }