public NbtPrintClientConfig() { printers = new PrinterSetupDataCollection(); //hardcoding the NBT seed into the print client, because [3/5/2014] Steven Salter: just use the same seed and provide it in your app encryptor = new CswEncryption("52978"); logMessages = string.Empty; }
public void MyTestInitialize() { TestData = new TestData { FinalizeNodes = true }; _SchemaAuthenticator = new CswNbtSchemaAuthenticator(TestData.CswNbtResources); _CswEncryption = new CswEncryption(TestData.CswNbtResources.MD5Seed); DataTable MaxNodeTable = TestData.CswNbtResources.execArbitraryPlatformNeutralSqlSelect("getHWM", "select max(loginid) as hwm from login_data"); _LoginDataHWM = CswConvert.ToInt32(MaxNodeTable.Rows[0]["hwm"]); }
}//saveUserSettings() /// <summary> /// Reads BalanceReaderClient.cfg, and sets state accordingly /// </summary> public void loadUserSettings() { if (File.Exists(ConfigPath)) { string[] ConfigurationFileLines = File.ReadAllLines(ConfigPath); string PasswordDecrypted; if (string.IsNullOrEmpty(ConfigurationFileLines[2])) { //need to manually avoid calling decrypt on an empty string to avoid an infinite loop PasswordDecrypted = ""; } else { CswEncryption Encryptor = new CswEncryption(""); PasswordDecrypted = Encryptor.decrypt(ConfigurationFileLines[2]); } AccessIdField.Text = ConfigurationFileLines[0]; UsernameField.Text = ConfigurationFileLines[1]; PasswordField.Text = PasswordDecrypted; AddressField.Text = ConfigurationFileLines[3]; pollingFrequencyField.Value = Decimal.Parse(ConfigurationFileLines[4]); _authenticationClient.AccessId = ConfigurationFileLines[0]; _authenticationClient.UserId = ConfigurationFileLines[1]; _authenticationClient.Password = PasswordDecrypted; _authenticationClient.baseURL = ConfigurationFileLines[3]; constructPollTimer(int.Parse(ConfigurationFileLines[4])); //all the remaining lines in the configuration file contain balance data, which is handled by the Balances for (int line = 5; line < ConfigurationFileLines.Length; line++) { string[] balanceDetails = ConfigurationFileLines[line].Split('|'); string COM = balanceDetails[0]; if (_balanceList.ContainsKey(COM)) { //set a current cell to avoid a crash from the handleGridUpdate event, then apply data to Balance HardwareGrid.BeginInvoke((Action)(() => { HardwareGrid.CurrentCell = _balanceList[COM].InterfaceRow.Cells["FriendlyName"]; })); bool fileOutdated = _balanceList[COM].FromString(balanceDetails, _configurationList); if (fileOutdated) { File.Delete(ConfigPath); } //unset current cell to avoid having a highlighted region that the user did not click HardwareGrid.BeginInvoke((Action)(() => { HardwareGrid.CurrentCell = null; })); } //if ( File.Exists( "BalanceReaderClient.cfg" ) ) } //for ( int line = 5; line < ConfigurationFileLines.Length; line++ ) } //if File.Exists } //loadUserSettings()
public CswEnumAuthenticationStatus AuthenticateWithSchema(CswEncryption CswEncryption, CswWebSvcSessionAuthenticateData.Authentication.Request AuthenticationRequest, out ICswUser AuthenticatedUser) { CswNbtSchemaAuthenticationLogic AuthenticationLogic = new CswNbtSchemaAuthenticationLogic(_CswNbtResources); CswNbtObjClassUser UserNode = null; if (AuthenticationRequest.AuthenticationStatus != CswEnumAuthenticationStatus.TooManyUsers) { UserNode = _authorizeUser(CswEncryption, AuthenticationRequest); AuthenticationRequest.AuthenticationStatus = AuthenticationLogic.GetAuthStatus(UserNode); } AuthenticationLogic.LogAuthenticationAttempt(UserNode, AuthenticationRequest); AuthenticatedUser = UserNode; return(AuthenticationRequest.AuthenticationStatus); }
public CswNbtNodePropPassword(CswNbtResources CswNbtResources, CswNbtNodePropData CswNbtNodePropData, CswNbtMetaDataNodeTypeProp CswNbtMetaDataNodeTypeProp, CswNbtNode Node) : base(CswNbtResources, CswNbtNodePropData, CswNbtMetaDataNodeTypeProp, Node) { _EncryptedPasswordSubField = ((CswNbtFieldTypeRulePassword)_FieldTypeRule).EncryptedPasswordSubField; _ChangedDateSubField = ((CswNbtFieldTypeRulePassword)_FieldTypeRule).ChangedDateSubField; _PreviouslyUsedPasswords = ((CswNbtFieldTypeRulePassword)_FieldTypeRule).PreviouslyUsedPasswords; _CswEncryption = new CswEncryption(CswNbtResources.MD5Seed); // Associate subfields with methods on this object, for SetSubFieldValue() _SubFieldMethods.Add(_EncryptedPasswordSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => EncryptedPassword, x => EncryptedPassword = CswConvert.ToString(x))); _SubFieldMethods.Add(_ChangedDateSubField.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => ChangedDate, x => ChangedDate = CswConvert.ToDateTime(x))); _SubFieldMethods.Add(_PreviouslyUsedPasswords.Name, new Tuple <Func <dynamic>, Action <dynamic> >(() => PreviouslyUsedPasswords, x => PreviouslyUsedPasswords = CswConvert.ToString(x))); }
private CswNbtObjClassUser _authorizeUser(CswEncryption CswEncryption, CswWebSvcSessionAuthenticateData.Authentication.Request AuthenticationRequest) { CswNbtObjClassUser ret = null; CswNbtObjClassUser UserNode = _CswNbtResources.Nodes.makeUserNodeFromUsername(AuthenticationRequest.UserName, RequireViewPermissions: false); if (UserNode != null && false == UserNode.IsArchived() && false == UserNode.IsAccountLocked()) { CswAuthorizationToken token = _authenticate(AuthenticationRequest); if (null != token) { if (token.Authorized) { UserNode.clearFailedLoginCount(); //We don't keep track of this when using WebSvc Authentication, but if this gets set ot something other than 0 this user won't be able to log in UserNode.LastLogin.DateTimeValue = DateTime.Now; if (null != token.UserId) { UserNode.EmployeeId.Text = token.UserId; } if (null != token.FirstName) { UserNode.FirstNameProperty.Text = token.FirstName; } if (null != token.LastName) { UserNode.LastNameProperty.Text = token.LastName; } if (null != token.Email) { UserNode.EmailProperty.Text = token.Email; } if (null != token.CostCode) { UserNode.CostCode.Text = token.CostCode; } UserNode.postChanges(false); ret = UserNode; } else if (false == string.IsNullOrEmpty(token.ErrorMsg)) { _CswNbtResources.logMessage(token.ErrorMsg); } } } return(ret); }
private CswNbtObjClassUser _authorizeUser(CswEncryption CswEncryption, CswWebSvcSessionAuthenticateData.Authentication.Request AuthenticationRequest) { CswNbtObjClassUser UserNode = _CswNbtResources.Nodes.makeUserNodeFromUsername(AuthenticationRequest.UserName, RequireViewPermissions: false); if (UserNode != null) { string encryptedpassword = CswEncryption.getMd5Hash(AuthenticationRequest.Password); if (UserNode.EncryptedPassword == encryptedpassword) { UserNode.clearFailedLoginCount(); UserNode.LastLogin.DateTimeValue = DateTime.Now; } else { UserNode.incFailedLoginCount(); } UserNode.postChanges(false); } return(UserNode); }
/// <summary> /// Stores user-entered values to BalanceReaderClient.cfg /// </summary> /// <param name="Sender"></param> /// <param name="E"></param> public void saveUserSettings(object Sender, EventArgs E) { CswEncryption Encryptor = new CswEncryption(""); string PasswordString = string.IsNullOrEmpty(_authenticationClient.Password) ? "" : Encryptor.encrypt(_authenticationClient.Password); string[] ConfigurationFileLines = new string[5 + _balanceList.Count]; ConfigurationFileLines[0] = _authenticationClient.AccessId; ConfigurationFileLines[1] = _authenticationClient.UserId; ConfigurationFileLines[2] = PasswordString; ConfigurationFileLines[3] = _authenticationClient.baseURL; ConfigurationFileLines[4] = pollingFrequencyField.Value.ToString(); int lineNumber = 5; foreach (Balance Balance in _balanceList.Values) { ConfigurationFileLines[lineNumber] = Balance.ToString(); lineNumber = lineNumber + 1; } File.WriteAllLines(ConfigPath, ConfigurationFileLines); }//saveUserSettings()