1111
1212import com .artech .base .services .AndroidContext ;
1313import com .genexus .util .Codecs ;
14- import com .genexus .util .Encryption ;
1514
1615import org .json .JSONArray ;
1716import org .json .JSONException ;
1817import org .json .JSONObject ;
1918
2019public 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 }
0 commit comments