Skip to content

Commit 096fcb6

Browse files
authored
Merge branch 'master' into gamutils_eo
2 parents a2e0259 + eaa8c96 commit 096fcb6

File tree

28 files changed

+700
-614
lines changed

28 files changed

+700
-614
lines changed

android/pom.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
<groupId>commons-io</groupId>
2424
<artifactId>commons-io</artifactId>
2525
</exclusion>
26-
<exclusion> <!-- exclude bouncycastle from android -->
27-
<groupId>org.bouncycastle</groupId>
28-
<artifactId>bcprov-jdk18on</artifactId>
29-
</exclusion>
3026
</exclusions>
3127
</dependency>
3228
<dependency>
@@ -38,10 +34,6 @@
3834
<groupId>commons-io</groupId>
3935
<artifactId>commons-io</artifactId>
4036
</exclusion>
41-
<exclusion> <!-- exclude bouncycastle from android -->
42-
<groupId>org.bouncycastle</groupId>
43-
<artifactId>bcprov-jdk18on</artifactId>
44-
</exclusion>
4537
</exclusions>
4638
</dependency>
4739
<dependency>
@@ -66,14 +58,6 @@
6658
<artifactId>commons-io</artifactId>
6759
<version>2.2</version>
6860
</dependency>
69-
<!-- add explicit bouncycastle in Android, version used in Android Flexible client -->
70-
<!-- keep in sync version here and in Android Flexible client -->
71-
<dependency>
72-
<groupId>org.bouncycastle</groupId>
73-
<artifactId>bcprov-jdk15on</artifactId>
74-
<version>1.65</version>
75-
</dependency>
76-
7761
</dependencies>
7862

7963
<build>

android/src/main/java/com/genexus/internet/HttpContext.java

Lines changed: 2 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,22 @@
1111

1212
import com.artech.base.services.AndroidContext;
1313
import com.genexus.util.Codecs;
14-
import com.genexus.util.Encryption;
1514

1615
import org.json.JSONArray;
1716
import org.json.JSONException;
1817
import org.json.JSONObject;
1918

2019
public abstract class HttpContext extends HttpAjaxContext implements IHttpContext
2120
{
22-
private static String GX_AJAX_REQUEST_HEADER = "GxAjaxRequest";
23-
2421
protected boolean PortletMode = false;
25-
protected boolean AjaxCallMode = false;
26-
protected boolean AjaxEventMode = false;
27-
protected boolean FullAjaxMode = false;
2822
public boolean drawingGrid = false;
2923

3024
public void setPortletMode()
3125
{ PortletMode = true; }
3226

33-
public void setAjaxCallMode()
34-
{ AjaxCallMode = true; }
35-
36-
public void setFullAjaxMode()
37-
{ FullAjaxMode = true; }
38-
39-
public void setAjaxEventMode()
40-
{ AjaxEventMode = true; }
41-
4227
public boolean isPortletMode()
4328
{ return PortletMode; }
4429

45-
public boolean isAjaxCallMode()
46-
{ return AjaxCallMode; }
47-
48-
public boolean isAjaxEventMode()
49-
{ return AjaxEventMode; }
50-
51-
public boolean isFullAjaxMode()
52-
{ return FullAjaxMode; }
53-
54-
public boolean isAjaxRequest()
55-
{ return isAjaxCallMode() || isAjaxEventMode() || isPortletMode() || isFullAjaxMode(); }
56-
57-
5830
public byte wbGlbDoneStart = 0;
5931
//nSOAPErr
6032
public HttpResponse GX_webresponse;
@@ -385,7 +357,7 @@ public void windowClosed()
385357

386358
public void pushCurrentUrl()
387359
{
388-
if (getRequestMethod().equals("GET") && !isAjaxRequest())
360+
if (getRequestMethod().equals("GET"))
389361
{
390362
String sUrl = getRequestNavUrl().trim();
391363
String topUrl = getNavigationHelper().peekUrl(sUrl);
@@ -409,106 +381,9 @@ public void printReportAtClient(String reportFile, String printerRule)
409381
{
410382
addPrintReportCommand(getResource(reportFile), printerRule);
411383
}
412-
413-
public boolean isGxAjaxRequest()
414-
{
415-
if (this.isMultipartContent())
416-
{
417-
return true;
418-
}
419-
// String gxHeader = getRequest().getHeader(GX_AJAX_REQUEST_HEADER);
420-
// if (gxHeader != null && gxHeader.trim().length() > 0)
421-
// {
422-
// return true;
423-
// }
424-
return false;
425-
}
426-
427-
private String getAjaxEncryptionKey()
428-
{
429-
if(getSessionValue(Encryption.AJAX_ENCRYPTION_KEY) == null)
430-
{
431-
if (!recoverEncryptionKey())
432-
{
433-
webPutSessionValue(Encryption.AJAX_ENCRYPTION_KEY, Encryption.getRijndaelKey());
434-
}
435-
}
436-
return (String)getSessionValue(Encryption.AJAX_ENCRYPTION_KEY);
437-
}
438-
439-
private boolean recoverEncryptionKey()
440-
{
441-
if (getSessionValue(Encryption.AJAX_ENCRYPTION_KEY) == null)
442-
{
443-
// String clientKey = getRequest().getHeader(Encryption.AJAX_SECURITY_TOKEN);
444-
// if (clientKey != null && clientKey.trim().length() > 0)
445-
// {
446-
// boolean candecrypt[]=new boolean[1];
447-
// clientKey = Encryption.decryptRijndael(clientKey, Encryption.GX_AJAX_PRIVATE_KEY, candecrypt);
448-
// if (candecrypt[0])
449-
// {
450-
// webPutSessionValue(Encryption.AJAX_ENCRYPTION_KEY, clientKey);
451-
// return true;
452-
// }else
453-
// {
454-
// return false;
455-
// }
456-
// }
457-
}
458-
return false;
459-
}
460-
461-
public String DecryptAjaxCall(String encrypted)
462-
{
463-
validEncryptedParm = false;
464-
if (isGxAjaxRequest())
465-
{
466-
String key = getAjaxEncryptionKey();
467-
boolean candecrypt[] = new boolean[1];
468-
String decrypted = Encryption.decryptRijndael(encrypted, key, candecrypt);
469-
validEncryptedParm = candecrypt[0];
470-
if (!validEncryptedParm)
471-
{
472-
sendResponseStatus(403, "Forbidden action");
473-
return "";
474-
}
475-
if (validEncryptedParm && !getRequestMethod().equalsIgnoreCase("post"))
476-
{
477-
setQueryString(decrypted);
478-
decrypted = GetNextPar();
479-
}
480-
return decrypted;
481-
}
482-
return encrypted;
483-
}
484-
485-
public boolean IsValidAjaxCall()
486-
{
487-
return IsValidAjaxCall(true);
488-
}
489-
490-
public boolean IsValidAjaxCall(boolean insideAjaxCall)
491-
{
492-
if (insideAjaxCall && !validEncryptedParm)
493-
{
494-
sendResponseStatus(403, "Forbidden action");
495-
return false;
496-
}
497-
else if (!insideAjaxCall && isGxAjaxRequest())
498-
{
499-
sendResponseStatus(440, "Session timeout");
500-
return false;
501-
}
502-
return true;
503-
}
504384

505385
public void sendResponseStatus(int statusCode, String statusDescription)
506386
{
507-
//getResponse().setStatus(statusCode);
508-
//try { getResponse().sendError(statusCode, statusDescription); }
509-
//catch(Exception e) {}
510-
//setAjaxCallMode();
511-
//disableOutput();
512387
}
513388

514389
private void sendReferer()
@@ -578,28 +453,11 @@ public String decrypt64(String value, String key)
578453
}
579454
return sRet;
580455
}
581-
582-
public void SendAjaxEncryptionKey()
583-
{
584-
if(!encryptionKeySended)
585-
{
586-
String key = getAjaxEncryptionKey();
587-
ajax_rsp_assign_hidden(Encryption.AJAX_ENCRYPTION_KEY, key);
588-
ajax_rsp_assign_hidden(Encryption.AJAX_ENCRYPTION_IV, Encryption.GX_AJAX_PRIVATE_IV);
589-
590-
try
591-
{
592-
ajax_rsp_assign_hidden(Encryption.AJAX_SECURITY_TOKEN, Encryption.encryptRijndael(key, Encryption.GX_AJAX_PRIVATE_KEY));
593-
}
594-
catch(Exception exc) {}
595-
encryptionKeySended = true;
596-
}
597-
}
598456

599457
public void SendServerCommands()
600458
{
601459
try {
602-
if (!isAjaxRequest() && commands.getCount() > 0)
460+
if (commands.getCount() > 0)
603461
{
604462
HiddenValues.put("GX_SRV_COMMANDS", commands.getJSONArray());
605463
}

android/src/main/java/com/genexus/specific/android/AndroidJSONSerialization.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.genexus.common.interfaces.IExtensionJSONSerialization;
44
import com.genexus.json.JSONObjectWrapper;
5+
import org.json.JSONTokener;
56

67
import java.util.Iterator;
78
import java.util.LinkedHashMap;
@@ -18,4 +19,9 @@ public Iterator<Map.Entry<String, Object>> getJSONObjectIterator(JSONObjectWrapp
1819

1920
return map.entrySet().iterator();
2021
}
22+
23+
@Override
24+
public JSONTokener getJSONTokener(String s) {
25+
return new AndroidJSONTokenerWrapper(s);
26+
}
2127
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.genexus.specific.android;
2+
3+
import org.json.JSONException;
4+
import org.json.JSONObject;
5+
import org.json.JSONTokener;
6+
7+
import com.genexus.json.JSONObjectWrapper;
8+
9+
public class AndroidJSONTokenerWrapper extends JSONTokener {
10+
public AndroidJSONTokenerWrapper(String string) {
11+
super(string);
12+
}
13+
14+
public Object nextValue() throws JSONException {
15+
char c = this.nextClean();
16+
this.back();
17+
if (c == '{') {
18+
try {
19+
return new JSONObjectWrapper((JSONObject) super.nextValue());
20+
} catch (StackOverflowError e) {
21+
throw new JSONException("JSON Array or Object depth too large to process.", e);
22+
}
23+
}
24+
else
25+
return super.nextValue();
26+
}
27+
}

common/src/main/java/com/genexus/URLRouter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static String convertParmsToQueryString(boolean useNamedParameters, Stri
115115
for (int i = 0; i < parms.length; i++)
116116
{
117117
if (!useNamedParameters || parms.length != parmsName.length)
118-
queryString = queryString + parms[i] + ((i < parms.length -1)? "," : "");
118+
queryString = queryString + parms[i] + ((i < parms.length -1 || (i == parms.length -1 && parms[i].isEmpty()) ) ? "," : "");
119119
else
120120
queryString = queryString + parmsName[i] + "=" + parms[i] + ((i < parms.length -1)? "&" : "");
121121
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.genexus.common.interfaces;
22

33
import com.genexus.json.JSONObjectWrapper;
4+
import org.json.JSONTokener;
45

56
import java.util.Iterator;
67
import java.util.Map;
78

89
public interface IExtensionJSONSerialization {
910
Iterator<Map.Entry<String, Object>> getJSONObjectIterator(JSONObjectWrapper obj);
11+
JSONTokener getJSONTokener(String s);
1012
}

common/src/main/java/com/genexus/internet/GXHttpClient.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,22 @@ protected String setPathUrl(String url) {
568568
return url;
569569
}
570570

571+
boolean firstMultiPart;
571572
@SuppressWarnings("unchecked")
572573
protected byte[] getData()
573574
{
574575
byte[] out = new byte[0];
575576

577+
firstMultiPart = false;
578+
int variablesCount = getVariablesToSend().size();
579+
int count = 1;
576580
for (Object key: getVariablesToSend().keySet())
577581
{
582+
if (count == variablesCount)
583+
firstMultiPart = true;
578584
String value = getMultipartTemplate().getFormDataTemplate((String)key, (String)getVariablesToSend().get(key));
579585
getContentToSend().add(0, value); //Variables al principio
586+
count++;
580587
}
581588

582589
for (int idx = 0; idx < getContentToSend().size(); idx++)
@@ -792,7 +799,10 @@ String getHeaderTemplate(String name, String fileName, String mimeType){
792799
}
793800
String getFormDataTemplate(String varName, String value){
794801
String contentType = getContentTypeFromString(value);
795-
return "\r\n--" + boundary + "\r\nContent-Disposition: form-data; name=\"" + varName + "\"\r\n" + ((contentType != null)? "Content-Type: " + contentType + "\r\n" : "") + "\r\n" + value;
802+
String beginformDataTemplate = "\r\n--";
803+
if (firstMultiPart)
804+
beginformDataTemplate = "--";
805+
return beginformDataTemplate + boundary + "\r\nContent-Disposition: form-data; name=\"" + varName + "\"\r\n" + ((contentType != null)? "Content-Type: " + contentType + "\r\n" : "") + "\r\n" + value;
796806
}
797807

798808
private String getContentTypeFromString(String value){

common/src/main/java/com/genexus/json/JSONObjectWrapper.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
import java.util.*;
44

55
import java.util.Map.Entry;
6+
7+
import com.genexus.common.interfaces.SpecificImplementation;
68
import org.json.JSONException;
79
import org.json.JSONObject;
10+
811
public class JSONObjectWrapper extends JSONObject implements java.io.Serializable{
912
private Map<String, Object> map;
1013

@@ -15,7 +18,11 @@ public JSONObjectWrapper() {
1518
}
1619

1720
public JSONObjectWrapper(String string) {
18-
super(new JSONTokenerWrapper(string));
21+
super(SpecificImplementation.JsonSerialization != null
22+
? SpecificImplementation.JsonSerialization.getJSONTokener(string)
23+
: new JSONTokenerWrapper(string)
24+
);
25+
1926
if (map == null)
2027
map = new LinkedHashMap<String, Object>();
2128
}

common/src/main/java/com/genexus/properties/GXObjectProperties.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ public class GXObjectProperties
88
private String errorMessage = "";
99
private int errorCode = 0;
1010
private int statusCode = 0;
11+
private String statusMessage = "";
1112
private int protocol = 1;
1213

14+
1315
public Location getLocation()
1416
{
1517
return location;
@@ -45,7 +47,14 @@ public void setErrorMessage(String value)
4547
{
4648
errorMessage = value;
4749
}
48-
50+
public String getStatusMessage()
51+
{
52+
return statusMessage;
53+
}
54+
public void setStatusMessage(String value)
55+
{
56+
statusMessage = value;
57+
}
4958
public int getProtocol()
5059
{
5160
return protocol;

0 commit comments

Comments
 (0)