Register a user using a predefined asynchronous authentication mechanism.
Before initializing connection between client and server, you need to initialize the SDMRequestManager to get user the details. To initialize the SDMRequestManager, perform the following:
SDMLogger logger = new SDMLogger(); SDMPreferences pref = new SDMPreferences(context, logger); pref.setStringPreference(ISDMPreferences.SDM_CONNECTIVITY_HANDLER_C LASS_NAME, SDMConstants.SDM_HTTP_HANDLER_CLASS); SDMConnectivityParameters param = new SDMConnectivityParameters(); /*Set the Username and Password in SDMConnectivityParameters.*/ param.setUserName(Utilities.userName); param.setUserPassword(Utilities.password); /*Enable XSRF support.*/ param.enableXsrf(true);
/* Initialize the SDMRequestManager */ SDMRequestManager reqMan = new SDMRequestManager(logger,pref, param, 1);
/*Initialize the ClientConnection using ClientConnection(<Context>,<Application ID>, <Domain>, <SecurityConfig>,<SDMRequestManager>)*/ ClientConnection cc = new ClientConnection(getApplicationContext(),com.sap.NewFlight, default, SSO ,reqMan);
/*Initialize the UserManager using UserManager(ClientConnection)*/ UserManager um = new UserManager(cc);
/* Initialize the AppSettings class using AppSettings(ClientConnection)*/ AppSettings as = new AppSettings(cc);
/*Provide the server details such as the request type HTTP/HTTPS, host, port, and so on. relay server URL template, farm ID (can be set to "null" if relay server is not used) */ cc.setConnectionProfile(isHttp,host,port,null, null);
/*set the Listener in case of Asynchronous Registration. This class has to implement ISMPUserRegistrationListener to get the callback*/ um.setUserRegistrationListener(this);
/*Asynchronously register the user using um.register(isSynchronous)*/ um.registerUser(false);
@Override public void onAsyncRegistrationResult(State registrationState, ClientConnection clientConnection, int errCode, String errMsg) { if(registrationState == ISMPUserRegistrationListener.State.SUCCESS) { Log.i("Tutorial", "Registration successful"); } }