Several questions migrating DA from java to cocoa

In each case i post java code and my try on cocoa code(not working)

How to setup a proxy service?

  {$IFDEF JAVA}
  fDataService := new NewLibrary.DataService_Proxy(java.net.URI.&create(adapter_serverUrl));
  //(fDataService.ProxyMessage as BinMessage).UseCompression       := true;
  (fDataService.ProxyClientChannel as HttpClientChannel).Timeout := 5000;
  (fDataService.ProxyMessage as BinMessage).Envelopes.put('AES', aesEnvelope);
   fDataService.ProxyClientChannel.ChannelCallback := new interface ClientChannel.IClientChannelCallback(
    clientChannelNeedsLogin := method(anException: Exception)
    begin
      System.out.println("SessionNotFoundException was thrown");
      exit true;
    end,
    requestFailWithException := method(anException: Exception)
    begin
      //Connected := False;
      doMessageShow('DataService requestFailWithException ' + anException.Message, false);
      System.out.println(anException.Message);
    end
  );
  {$ELSE}
  // ver si puedo usar directamente el adapter con cast
  fDataService := new NewLibrary.DataService_Proxy(adapter_serverUrl);
  {$ENDIF}

trying to get datatables in a call

var tableNames := new NSMutableArray<String>;
  tableNames.addObject(nme_tipoactividad);
  tableNames.addObject(nme_locaciones);
  //tableNames.addObject(nme_bitacora_entidad);

  var tables := DataAdapter.getDataTables(tableNames);

get this message

Error dispatching message: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

building a where condition

{$IFDEF JAVA}
    var lCondition :BinaryExpression :=
        new BinaryExpression(
          new BinaryExpression(
            new BinaryExpression(
              new FieldExpression(fld_empresas_empresaglobalkey),
              new ConstantExpression(fDataAccess.adapter_loginCompany),
              BinaryOperator.Equal),
            new BinaryExpression(
              new FieldExpression(fld_personas_usuario),
              new ConstantExpression(fDataAccess.adapter_loginName),
              BinaryOperator.Equal),
            BinaryOperator.And),
        new BinaryExpression(
          new FieldExpression(fld_hardware_device_serie_imei),
          new ConstantExpression(fDataAccess.adapter_loginIMEI),
          BinaryOperator.Equal),
        BinaryOperator.And);
{$ENDIF}

Thats all.

Thanks in advance!

Hello

This is a platform (iOS) thing not direcly related to DA. Please take a look at http://highaltitudehacks.com/2016/06/23/ios-application-security-part-46-app-transport-security/ for more details.

Regards

Thanks for your help, but i dont undesrtand. Seems like the conenction is made in an insecure form. Is not related to remobejcts channel? I build an IOS client, using Delphi + DA, IOS 10 and never see that message, over the same server. Then i think some is misconfigurated on Fire? Sorry, i think i need a more deeper information here about how to configure my remobjects channel.

Best regards.
P.S. Please if can ask the other stuff?

Ih you are using Url like http://... (not https://...) then the connection is not secure by definition.

If in this case Delphi-built app doesn’t warn you then ( IMHO ) this is actually a security flaw and a kind of violation of Apple requirements (ones that require all apps to use https for connections). Most probably Delphi app just have the override option enabled by default.

Ok, delphi fault as usual. How to fix that then? Must i put a security certficate on the server? Can please explain that?

Apple require all communication to go via TSL1.2 or later. You must switch your server to use https:. As a workaround you can add this to your Info.plist file, but you may nit be able to submit the app to the store with that, in there future:

		<key>NSAppTransportSecurity</key>
		<dict>
			<key>NSAllowsArbitraryLoads</key>
			<true/>
		</dict>
1 Like

Thanks for the clarification.

1 Like

FWIW, the same would apply to a Delphi app, but it’d not be shocked to hear that Delphi just adds the above to your Plist automatically (which would be really, really bad, but…)

—marc

Marc, the strange stuff here is i submitted delphi ios app to the apple store, not complain at all.

Best regards.

Apple is not enforcing this 100% yet.

But that means Delphi most likely did add that setting for you secretly. The mind boggles. But then, DataSnap also opens a pass-thru connection to your database to the client, and they call out “secure multi-tier”, so what do i expect… :stuck_out_tongue_winking_eye:

Sorry for ask again. Can help my explaining how to migrtae taht code from java to cocoa?

Thanks in advance.

Need URGENT help with that please. Theres no documentation or samples covering this case.

Thanks.

Please explain what you are trying to achieve

Connect to a Remobjects service and call a method, same the java code do, but in IOS. See the java code.

Best regards.

Did you lokk at the c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for Java folder?

“c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for Java\Oxygene\HTTP Chat\Program.pas”

F.e. the file c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for Java\Oxygene\Mega Demo\UserInterface.pas:

method DemoWindow.initDemoProxy;
begin
  var lProtocol: String := protocolBox.SelectedItem as String;
  var lHost: String := hostField.Text as String;
  var lPort: String := portSpinner.Text as String;
  var lMessageType: String := '/';
  if binaryRbtn.isSelected then
    lMessageType := '/bin';
  var lURI := new URI(lProtocol + '://' + lHost + ':' + lPort + lMessageType);
  MegaDemoService := new MegaDemoService_Proxy(lURI);
  if useCompession.isSelected then
    (MegaDemoService.ProxyMessage as BinMessage).UseCompression := true
  else
    (MegaDemoService.ProxyMessage as BinMessage).UseCompression := false;
  (MegaDemoService.ProxyClientChannel as HttpClientChannel).Timeout := 1000;
end;

Similar code in the MegaDemo Android sample:

var lURI := new URI("http://10.0.2.2:8099/bin");
fService := new MegaDemoService_Proxy(lURI);
(fService.ProxyMessage as BinMessage).UseCompression := true;
(fService.ProxyClientChannel as HttpClientChannel).Timeout := 1000;

Regards

No, sorry, i dont. I start in the bad path thinking syntaxis for RO and DA are the same on all platforms. I will check every sample for IOS now.

Best regards.

There is a good reason why the syntax differs:
The code you write is compiled directly into platform-native code, without a massive overhead of some runtime library that hides platform-specific stuff.
From one side, it requires you to write more code, from other it gives beter performance more native apps. Also it allows to use platform-specific tutorials to do the things needed (f.e. you want ot use https with self-signed certificate on Android and just found some code on StackOverflow. You can oxidize that code and it will work fo you in your app)

I have to disagree. That forces to wrote all the code two or tree times to do the same. In any case, as i talk with marc, will be better if you offer a common wrapper and let the use to decide if use native code or the common wrappers, and not force to write a lot of code. is a manintenance nigthmare, despite the aditional time to get it working.

Best regards.

As i explained before, DA/.NET and DA/Cocoa were written LONG before there was Elements support for Java and Cocoa. They were design dot fit in well with each respective platform because there WAS no way to share code anyways (Android apps would have been in Java, Cocoa apps in Objective-C).

We ARE looking into a better approach in the future, but for now, thats what it is.

Thank you marc, will be a better approach without any doubt.

Best regards.