cancel
Showing results for 
Search instead for 
Did you mean: 

SMP 2.3 sp4 Synchronization in the native application on HTTPS

Former Member
0 Kudos

Hi I have a big problem with synchronization on port 443 / https.


This is the architecture.



At the Relay Server I have installed a trusted certificate in IIS.

I do not know what I need to use the certificate in SMP and application code.



Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Daniel,

In the code set the connection properties networkprotocol as "https" and port number as "443" and same in synchronizationprofile properties. In addition to that set the networkstream parameters as "trusted_certificates=yourcertificateName;compression=zlib;url_suffix=urlsuffixProvidedByTheRelayServer"];"

Former Member
0 Kudos

My code looks like this:

SMP101DB.java

_profile.getSyncProfile().setProperty("packageName","smp101:1.0" );

        com.sybase.persistence.ConnectionProfile initProfile = new com.sybase.persistence.ConnectionProfile();

        initProfile.setServerName("company.com");

        initProfile.setPortNumber(443);

        initProfile.setNetworkProtocol("https");

        initProfile.setNetworkStreamParams("trusted_certificates=;url_suffix=;custom_header=\"X_SUP_APPCID:" + com.sybase.mo.MessagingClientLib.getInstance().getDeviceID()+ "\"");

        initProfile.setDomainName("default");

        getSynchronizationProfile().setServerName("company.com");

        getSynchronizationProfile().setPortNumber(443);

        getSynchronizationProfile().setNetworkProtocol("https");

        com.sybase.persistence.NetworkStreamParams streamParams = getSynchronizationProfile().getStreamParams();

        Log.e("DJAR", streamParams.toString());

        streamParams.setUrl_Suffix("/ias_relay_server/client/rs_client.dll/rbs.farm");

        streamParams.setTrusted_Certificates("/storage/sdcard0/download/certificate_company.crt");

        getSynchronizationProfile().setDomainName("default");

        DELEGATE.setInitialSyncProfile(initProfile);

        DELEGATE.init("smp101:1.0", "com.test.smp101.android.mbo", META_DATA, _profile, getDSI());

SMP101SampleActivity.java

private static final int REQUEST_DETAIL = 99;

    private static String USERNAME = "yyyy";

    private static String PASSWORD = "xxxx";

    private static String HOST = "company.com";

    private static int PORT = 443;

    private static int TIMEOUT = 600;

    private static String networkStreamParamsRBS = "trusted_certificates=/storage/sdcard0/download/certificate_company.crt;url_suffix=/ias_relay_server/client/rs_client.dll/rbs.farm/";

    private static String networkStreamParamsMBS = "url_suffix=/ias_relay_server/client/rs_client.dll/mbs.farm/";

    private CustomerListAdapter adapter;

    private static volatile boolean initializationDone = false;

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        initializeApplication();

    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data)

    {

        if (requestCode == REQUEST_DETAIL)

        {

            if (resultCode == RESULT_OK)

            {

                SMP101SampleActivity.this.adapter.refreshUI(true);

            }

        }

    }

    private void initializeApplication()

    {      

        final ProgressDialog dialog = new ProgressDialog(this);

        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

        dialog.setTitle("on boarding ...");

        dialog.setMessage("Please wait while download initial data...");

        dialog.setIndeterminate(false);

        dialog.setProgress(100);

        dialog.setCancelable(true);

        dialog.show();

        new Thread()

        {

            @Override

            public void run()

            {

                try

                {

                    int count = 0;

                    while (!initializationDone)

                    {

                        dialog.setProgress(++count);

                        Thread.sleep(500);

                        if (count == 100)

                        {

                            count = 0;

                        }

                    }

                    dialog.cancel();

                }

                catch (Exception e)

                {

                    dialog.cancel();

                }

            }

        }.start();

        Application app = Application.getInstance();

        app.setApplicationIdentifier("SMP101");

        app.setApplicationContext(SMP101SampleActivity.this);

        new Thread(new Runnable()

        {

           

            private void startLogon() {

                Application app = Application.getInstance();

                ApplicationCallback appCallback = new MyApplicationCallback();

                SMP101DB.registerCallbackHandler(new CustomerDBCallback());

                app.setApplicationCallback(appCallback);

               

                SMP101DB.setApplication(app);

               

                // Connection Profile

                ConnectionProfile connProf = SMP101DB.getConnectionProfile();

                connProf.setCacheSize(102400);

                connProf.setNetworkProtocol("https");

                Application.getInstance().getConnectionProperties().setFarmId("mbs.farm");

                connProf.save();

               

//                Application app = Application.getInstance();

               

               

//                SMP101DB.registerCallbackHandler(new CustomerDBCallback());

//                SMP101DB.setApplication(app);

               

//                SMP101DB.getSynchronizationProfile().setServerName(HOST); // Convenience only

                // Synchronization Profile

                ConnectionProfile connProps = SMP101DB.getSynchronizationProfile(); //app.getConnectionProperties();

//                LoginCredentials loginCredentials = new LoginCredentials(USERNAME, PASSWORD);

//                connProps.setLoginCredentials(loginCredentials);

                connProps.setServerName(HOST);

                connProps.setPortNumber(PORT);

                connProps.setNetworkProtocol("https");

                connProps.enableTrace(true);

                connProps.setMaxDbConnections(6);

                connProps.setNetworkStreamParams(networkStreamParamsRBS);

     

                connProps.save();

            }

           

            @Override

            public void run()

            {

                try

                {

                    Application app = Application.getInstance();

                   

                    // ConnectionProperties

                    ConnectionProperties prop = app.getConnectionProperties();

                   

                    prop.setServerName(HOST);

                    prop.setPortNumber(PORT);

                    prop.setNetworkProtocol("https");

                    prop.setFarmId("mbs.farm");

                   

                    Log.i("SMP101","Starting Application Registration");

                    if (app.getRegistrationStatus() != RegistrationStatus.REGISTERED) {

                       

                        startLogon();

                        try {

                            app.getConnectionProperties().setLoginCredentials(new LoginCredentials(USERNAME, PASSWORD));

                            app.registerApplication(3600);   

                        }

                        catch (Exception e)

                        {

                            Log.e("SMP101","Cannot register " + e.getMessage());

                        }

                    } else {

                        app.startConnection(TIMEOUT);

                    }

                    Log.i("SMP101","Application REGISTERED");

                   

                    if (!SMP101DB.isSynchronized("default")) {

                       

                        Log.i("SMP101","Starting Initial Sync");

                        SMP101DB.disableChangeLog();

                        SMP101DB.synchronize(); // Initial Synchronize

                        SynchronizationGroup sg = SMP101DB.getSynchronizationGroup("default");

                        sg.setEnableSIS(true);

                        sg.save();

                        SMP101DB.synchronize();

                        Log.i("SMP101","Initial Sync COMPLETED");

                    }

                    SMP101DB.enableChangeLog();

                }

                catch (Exception e)

                {

                    e.printStackTrace();

                }

                finally

                {

                    initializationDone = true;

                }

                SMP101SampleActivity.this.runOnUiThread(new Runnable()

                {

                    @Override

                    public void run()

                    {

                        adapter = new CustomerListAdapter(SMP101SampleActivity.this);

                        ListView listView = (ListView) findViewById(R.id.listView1);

                        listView.setAdapter(adapter);

                        listView.setOnItemClickListener(new OnItemClickListener()

                        {

                            @Override

                            public void onItemClick(AdapterView<?> a, View v, int position, long id)

                            {

                                Intent intent = new Intent(SMP101SampleActivity.this, DetailActivity.class);

                                intent.putExtra("sk", adapter.getSK(position));

                                SMP101SampleActivity.this.startActivityForResult(intent, REQUEST_DETAIL);

                            }

                        });

                    }

                });

            }

        }).start();

    }

Former Member
0 Kudos

Hi Daniel,

With the above code are you able to register the App? If not what is the error that you are getting can you please share the same.