Exemple #1
0
 /// <summary>
 /// This constructor must be use only for unit tests purposes.
 /// </summary>
 /// <param name="modSicProxy">An instance of ModSicServiceProxy with mock behavior.</param>
 /// <param name="username">modSIC user name. It´s optional, because you do not need to pass username in order to call Heartbeat operation.</param>
 /// <param name="username">modSIC password. Like username parameter.</param>
 public ModSicConnection(ModSicServiceProxy modSicProxyMock, string username = null, string password = null, string clientId = null, APIVersion apiVersion = null, string fakeCertificatePassword = "******")
 {
     this.Username = username;
     this.Password = password;
     this.ClientId = clientId;
     this.RequiredVersion = apiVersion;
     this.ModSicProxyService = modSicProxyMock;
     this.CertificatePassword = fakeCertificatePassword;
 }
Exemple #2
0
        /// <summary>
        /// Constructor for modSIC API. This is the constructor that be used in production code.
        /// </summary>
        /// <param name="username">modSIC user name. It´s optional, because you do not need to pass username in order to call Heartbeat operation.</param>
        /// <param name="username">modSIC password. Like username parameter.</param>
        public ModSicConnection(string modSicServiceURL, string username = null, string password = null, string clientId = null)
        {
            this.Username = username;
            this.Password = password;
            this.ClientId = clientId;
            this.RequiredVersion = new APIVersion(APIVersion.CURRENT_VERSION);

            this.ModSicProxyService = new ModSicServiceProxy(modSicServiceURL);
        }
 public virtual LoginInfo LoginEx(string username, string password, string clientId, APIVersion required)
 {
     CreateModSicChannel();
     return this.ModSicChannel.LoginEx(username, password, clientId, required);
 }
Exemple #4
0
        public LoginInfo LoginEx(string username, string password, string clientId, APIVersion required)
        {
            LoginInfo retVal = new LoginInfo();
            retVal.APIVersion = new APIVersion(APIVersion.CURRENT_VERSION);
            retVal.ServerVersion = Assembly.GetExecutingAssembly().GetName().Version;

            if ((required != null) &&
                ((required.Major > retVal.APIVersion.Major) ||
                ((required.Major == retVal.APIVersion.Major) && (required.Minor > retVal.APIVersion.Minor))))
            {
                retVal.ErrorType = "ActionNotSupportedException";
                retVal.ErrorMessage =
                    String.Format(
                        "This client uses a modSIC API version ({0}) not supported by this modSIC Server ({1}).",
                        required.ToString(),
                        retVal.APIVersion);
                //retVal.ErrorMessage = "Client requires API " + required.ToString() + "; Server supports " + retVal.APIVersion;
            }
            else
            {
                var result = CollectController.Login(username, password, clientId);
                if (result == null)
                {
                    retVal.ErrorType = "UnauthorizedAccessException";
                    retVal.ErrorMessage = "Invalid username or password";
                }
                else
                {
                    retVal.Token = result;
                }
            }

            return retVal;
        }
Exemple #5
0
 public ModSicApiTest()
 {
     this.FakeApiVersion = new APIVersion("1.0");
     this.FakeLoginInfoToReturn = new LoginInfo() { APIVersion = FakeApiVersion, Token = Guid.NewGuid().ToString() };
 }