Esempio n. 1
0
        /// <summary>
        /// Examines whether RPA supports logging out the <see cref="User" /> from the mobile device that have been used to provide the Access Number for authenticating the user to another device/browser session. Therefore, the method should be used after Access Number authentication, i.e. following the <see cref="M:MPinSDK.MPin.AuthenticateAN">AuthenticateAN(user, accessNumber)</see> method.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>True if the user can be logged out from the remote server, False - if (s)he cannot.</returns>
        public bool CanLogout(User user)
        {
            if (user == null)
                return false;

            bool canLogout;
            lock (lockObject)
            {
                canLogout = mPtr.CanLogout(user.Wrapper);
            }

            return canLogout;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the registration process for a <see cref="User"/> which has been alredy created with the MakeNewUser method. This causes the RPA to begin an identity verification procedure for the User (like sending a verification email, for instance). At that, the User’s status changes to StartedRegistration and remains like this until the FinishRegistration method has been executed successfully.
        /// </summary>
        /// <param name="user">The <see cref="User"/> object instance.</param>
        /// <param name="userData"> Optionally, the application might pass additional userData which might help the RPA to verify the user identity. The RPA might decide to verify the identity without starting a verification process. In this case the Status of the call will still be Status::OK, but the User State will be Activated. </param>
        /// <returns> A <see cref="Status"/> which indicates whether the operation was successful or not.</returns>
        /// <remarks> Under certain scenarios, like a demo application, the RPA might be configured to verify identities without starting a verification process. In this case, the status of the call will still be OK, but the User state will be set to Activated. </remarks>
        public Status StartRegistration(User user, string activateData = "", string userData = "")
        {
            Status st = null;
            if (AreParametersValid(ref st, user))
            {
                StatusWrapper sw;
                lock (lockObject)
                {
                    sw = user != null ? mPtr.StartRegistration(user.Wrapper, activateData, userData) : new StatusWrapper() { Code = InvalidStatus, Error = ResourceLoader.GetForCurrentView().GetString("NullUser") };
                }

                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 3
0
        private bool AreParametersValid(ref Status st, User user = null, string pin = DefaultStringValue,
                                        string accessNumber = DefaultStringValue, string pushMessageIdentifier = DefaultStringValue)
        {
            if (user == null)
                st = new Status(InvalidStatus, ResourceLoader.GetForCurrentView().GetString("NullUser"));

            if (string.IsNullOrEmpty(pin))
                st = new Status(InvalidStatus, ResourceLoader.GetForCurrentView().GetString("EmptyPin"));

            if (string.IsNullOrEmpty(accessNumber))
                st = new Status(InvalidStatus, ResourceLoader.GetForCurrentView().GetString("NullAccessNumber"));

            // we still does not use this flow
            //if (string.IsNullOrEmpty(pushMessageIdentifier))
            //    st = new Status(InvalidStatus, ResourceLoader.GetForCurrentView().GetString("EmptyPushMsg"));

            return st == null ? true : false;
        }
Esempio n. 4
0
        /// <summary>
        /// This method re-initializes the registration process for a <see cref="User"/> that already started it. 
        /// </summary>
        /// <param name="user">The <see cref="User"/> object instance.</param>
        /// <param name="userData"> Optionally, the application might pass additional userData which might help the RPA to verify the user identity. The RPA might decide to verify the identity without starting a verification process. In this case the Status of the call will still be Status::OK, but the User State will be Activated. </param>
        /// <returns> A <see cref="Status"/> which indicates whether the operation was successful or not.</returns>
        /// <remarks>The difference between this method and the StartRegistration() is that during this one, no new M-Pin ID will be generated for the user, but the already generated one will be used. So StartRegistration can be called only for Users in the StartedRegistration state and RestartRegistration is designed to be used for Users in the Invalid state.</remarks>   
        public Status RestartRegistration(User user, string userData = "")
        {
            Status st = null;
            if (AreParametersValid(ref st, user))
            {
                StatusWrapper sw;
                lock (lockObject)
                {
                    sw = mPtr.RestartRegistration(user.Wrapper, userData);
                }

                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 5
0
        /// <summary>
        /// Starts the authentication process of a <see cref="User" /> for the needs of the overlaying application. 
        /// </summary>
        /// <param name="user">The <see cref="User" /> to be authenticated.</param>
        /// <returns>
        /// A <see cref="Status" /> which indicates whether the operation was successful or not.
        /// </returns>
        public Status StartAuthentication(User user)
        {
            Status st = null;
            if (AreParametersValid(ref st, user))
            {
                StatusWrapper sw = mPtr.StartAuthentication(user.Wrapper);
                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 6
0
        /// <summary>
        /// Finalizes the <see cref="User" /> registration process.
        /// </summary>
        /// <param name="user">The <see cref="User" /> object instance.</param>
        /// <param name="pin">The pin that the user just entered.</param>
        /// <returns>
        /// A <see cref="Status" /> which indicates whether the operation was successful or not. On successful completion, the <see cref="User" /> state is set to Registered and the method returns OK.
        /// </returns>
        public Status FinishRegistration(User user, string pin)
        {
            Status st = null;
            if (AreParametersValid(ref st, user, pin))
            {
                StatusWrapper sw;
                lock (lockObject)
                {
                    sw = mPtr.FinishRegistration(user.Wrapper, pin);
                }

                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 7
0
        /// <summary>
        /// Attempts to log out the end-user from a remote (browser) session after successful authentication through the <see cref="M:MPinSDK.MPin.AuthenticateAN">AuthenticateAN(user, accessNumber)</see> method. 
        /// <remarks>Before calling this method, make sure that the logout data has been provided by the RPA and that the logout operation is feasible.</remarks>
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns>True if the log-out request to the RPA has been successful, false - if failed.</returns>
        public bool Logout(User user)
        {
            if (user == null)
                return false;

            bool logout;
            lock (lockObject)
            {
                logout = mPtr.Logout(user.Wrapper);
            }

            return logout;
        }
Esempio n. 8
0
        /// <summary>
        /// Authenticates the <see cref="User" /> and, if authentication has been successful, the RPA issues One-Time Password (OTP) for authenticating with a RADIUS server. (The authentication itself doesn’t log the User in: instead, the result of the authentication is the issuing of the OTP.)
        /// </summary>
        /// <param name="user">The <see cref="User" /> to be authenticated.</param>
        /// <param name="pin">The PIN of the user.</param>
        /// <param name="otp">When the authentication is successful, in addition to the OK status, the method returns also an <see cref="OTP" /> structure generated by the RPA.</param>
        /// <returns>
        /// A <see cref="Status" /> which indicates whether the operation was successful or not.
        /// </returns>
        public Status FinishAuthenticationOTP(User user, string pin, OTP otp)
        {
            if (otp == null)
                return FinishAuthentication(user, pin);

            Status st = null;
            if (AreParametersValid(ref st, user, pin))
            {
                StatusWrapper sw = mPtr.FinishAuthenticationOTP(user.Wrapper, pin, otp.Wrapper);
                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 9
0
        /// <summary>
        /// Authenticates a <see cref="User" /> against an Access Number provided by a PC/browser session. After this authentication, the user will be able to log-in on to the PC/browser with the provided Access Number while the authentication itself is performed on the user's mobile device.
        /// </summary>
        /// <param name="user">The <see cref="User" /> to be authenticated.</param>
        /// <param name="pin">The PIN of the user.</param>
        /// <param name="accessNumber">The Access Number provided by the PC/browser session. Required if Access Number authentication is being performed.</param>
        /// <returns>
        /// A <see cref="Status" /> which indicates whether the operation was successful or not.
        /// </returns>
        public Status FinishAuthenticationAN(User user, string pin, string accessNumber)
        {
            Status st = null;
            if (AreParametersValid(ref st, user, pin, accessNumber))
            {
                StatusWrapper sw = mPtr.FinishAuthenticationAN(user.Wrapper, pin, accessNumber);
                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 10
0
        /// <summary>
        /// Finishes the authentication process of a <see cref="User" /> for the needs of the overlaying application.
        /// </summary>
        /// <param name="user">The <see cref="User" /> to be authenticated.</param>
        /// <returns>
        /// A <see cref="Status" /> which indicates whether the operation was successful or not.
        /// </returns>
        public Status FinishAuthentication(User user, string pin, string authResultData = null)
        {
            Status st = null;
            if (AreParametersValid(ref st, user, pin))
            {
                StatusWrapper sw = authResultData == null
                        ? mPtr.FinishAuthentication(user.Wrapper, pin)
                        : mPtr.FinishAuthentication(user.Wrapper, pin, authResultData);

                return new Status(sw.Code, sw.Error);
            }

            return st;
        }
Esempio n. 11
0
 /// <summary>
 /// Deletes a <see cref="User"/> from the Users List maintained by the SDK and all the data related this User, such as the User’s M-Pin ID, State, and M-Pin Token.
 /// </summary>
 /// <param name="user">The user instance.</param>
 public void DeleteUser(User user)
 {
     Status st = null;
     if (AreParametersValid(ref st, user))
     {
         lock (lockObject)
         {
             if (mPtr != null && user != null)
                 mPtr.DeleteUser(user.Wrapper);
         }
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Confirms the <see cref="User" /> registration process.
        /// </summary>
        /// <param name="user">The <see cref="User" /> object instance.</param>
        /// <param name="pushMessageIdentifier">The push message identifier.</param>
        /// <returns>
        /// A <see cref="Status" /> which indicates whether the operation was successful or not.
        /// </returns>
        public Status ConfirmRegistration(User user, string pushMessageIdentifier = "")
        {
            Status st = null;
            if (AreParametersValid(ref st, user, DefaultStringValue, DefaultStringValue, pushMessageIdentifier))
            {
                StatusWrapper sw;
                lock (lockObject)
                {
                    sw = mPtr.ConfirmRegistration(user.Wrapper, pushMessageIdentifier);
                }

                return new Status(sw.Code, sw.Error);
            }

            return st;
        }