Dear All,

From SMP 3.0 onward we have two ways for registering a user with SMP Server.

1. MAF Logon

2. Using OData SDK

A lot of people go for using the MAF Logon. MAF Logon comes with a pre defined UI Screen for Logon functionality so the developers do not need to do anything to onboard users. They can just import the MAF projects inside their IDE (Android Studio/Eclipse for Android)/ Xcode for iOS and just run the application.

You can learn how to onboard users using MAF Logon from this link

But there could be a requirement that you do not want to use the SAP Standard screen and have your own custom login screen, to maintain UI consistency all over the application. For this we can onboard users using OData SDK. The tutorial on how to onboard users using OData SDK can be accessed using this link

You might run into difficulties to authenticate users against any sort of Authentication mechanism that you use like HTTP/HTTPS etc but with NoAuthenticationLoginModule it will onboard your user but when you login to the Management Cockpit it will show the user registered as no_sec_identity.

Follow the below set of code to successfully onboard your user against an authentication mechanism that you have configured against your application id

Assuming that you have your own custom screen with a field for username and password and a Login Button you can add this set of code on the button click event of your Login Button

private LogonCore logonCore;  Define this as a global parameter at the start of your activity.

And within the button click event add this line of code

LogonCoreContext context = logonCore.getLogonContext();

try

{

context.setHost(smpHost);  //address of your SMP Server or relay server

context.setPort(smpPort);    // port of the SMP Server or port 80 if you are using the relay server

context.setHttps(false);       // Set to TRUE if you are using https

context.setFarmId(“0”);     //Set the FARM ID in case you are using the Relay Server

//

context.setResourcePath(“ias_relay_server/client/rs_client.dll);   //User this if you are using the Relay Server

context.setBackendUser(smpUserId);               //The field that the user will input his username

context.setBackendPassword(smpPassword);   // The field that user will input his credentials

context.setSupUserName(smpUserId);

context.setSupPassword(smpPassword);

context.setChannel(Channel.REST);               //This is a very important parameter to add else you would not be able to pass these parameters

logonCore.register(context);

}

With this you can see your user is authenticated against the security provider and now you can use all functionalities like SSO, Role Mapping etc relevant to your security provider.

These are all with inputs from Claudia Pacheco Pavel Penaz Prashanth Sutram

Hope this helps you all and saves all of your time to debug the error.

Thanks,

Regards,

Rakshit Doshi


To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Midhun VP

    Hi Rakshit,

    Thanks for the write up. Could you please mention the version of the server and sdk you used in your blog, because I have followed the blog you mentioned How To… On-board users with SMP 3.0 OData SDK (Android) and I am able to login using HTTP/HTTPS and LDAP authentication login module without changing the code that you mentioned. That means this code change may be needed only in the version you used.

    I am on SMP runtime SP06 and SMP SDK SP07.

    Regards, Midhun

    SAP Technology RIG

    (0) 
  2. Timothy Li

    please use following simplest code to test the OData Onboarding:

    import com.sap.maf.tools.logon.core.LogonCore;

    import com.sap.maf.tools.logon.core.LogonCore.UserCreationPolicy;

    import com.sap.maf.tools.logon.core.LogonCoreContext;

    import com.sap.maf.tools.logon.core.LogonCoreException;

    import com.sap.maf.tools.logon.core.LogonCoreListener;

    import com.sybase.persistence.DataVault.DVPasswordPolicy;

    import android.os.Bundle;

    import android.app.Activity;

    import android.util.Log;

    public class LogonActivity extends Activity implements LogonCoreListener{

        private static final String TAG = “timothy”;

        private boolean isHttpsEnabled = false;

        private String appConnId;

        private LogonCore logonCore;

        @Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_main);

            this.initLogonCore();

            registerDevice();

        }

        private void initLogonCore() {

            logonCore = LogonCore.getInstance();

            logonCore.init(this, “com.sap.flight”);

            logonCore.setLogonCoreListener(this);

        }

        private void registerDevice() {

            Log.i(TAG, “appConnId:” + appConnId);

            LogonCoreContext logonCoreContext = logonCore.getLogonContext();

            logonCoreContext.setHost(“10.***.***.47”); //please input the correct IP address here

            int port = 8080;

            logonCoreContext.setPort(port);

            logonCoreContext.setHttps(isHttpsEnabled);

            UserCreationPolicy ucPolicy = UserCreationPolicy.automatic;

            logonCoreContext.setUserCreationPolicy(ucPolicy);

           

            try {

                logonCoreContext.setBackendUser(“smpAdmin”); // please note: here we input SMP cockpit logon username, NOT backend username

                logonCoreContext.setBackendPassword(“s3****in”); // please note: here we input SMP cockpit logon pwd, NOT backend pwd

            } catch (LogonCoreException e) {

                Log.e(TAG, “error entering user credentials”, e);

            }

           

           

            logonCore.register(logonCoreContext);

            Log.i(TAG, “after register”);

        }

        @Override

        public void applicationSettingsUpdated() {

        }

        @Override

        public void backendPasswordChanged(boolean arg0) {

        }

        @Override

        public void deregistrationFinished(boolean arg0) {

        }

        @Override

        public void registrationFinished(boolean success, String message, int errorCode,

                DVPasswordPolicy arg3) {

            Log.i(TAG, “registrationFinished, success? ” + success); //If you get “success” in console output, go to cockpit/applictions/click on your application id, you will see if a new registration already created!

            Log.i(TAG, “registrationFinished, message= ” + message);

            Log.i(TAG, “registrationFinished, errorCode= ” + errorCode);

        }

        @Override

        public void traceUploaded() {

        }

    }

    (0) 

Leave a Reply