private void LoginButton(object sender, RoutedEventArgs e) { try { if (signIn.rememberChk.IsChecked == true) // method creates or refreshes user`s config file if checkbox is selected { CredentialDTO credential = new CredentialDTO { Email = signIn.loginField.Text, Password = signIn.passwordField.Password }; BinaryFormatter formatter = new BinaryFormatter(); using (var stream = store.OpenFile("credential.cfg", FileMode.OpenOrCreate, FileAccess.Write)) { formatter.Serialize(stream, credential); } } //StartCounting((int)signUp.userId); menu = new Menu(_dal, (int)signIn.userId); contentControl.Content = menu; menu.AddHandler(Menu.ExitClick, new RoutedEventHandler(ExitButton)); menu.AddHandler(Menu.LogOutClick, new RoutedEventHandler(LogOutButton)); } catch (Exception ex) { Helper.log.Error($"Exception: {ex.ToString()}"); MaterialMessageBox.ShowError(ex.ToString()); } }
public static CredentialDC CredentialDTOtoDC(CredentialDTO credentialDTO) { MapperConfiguration configDTOtoDM = new MapperConfiguration(cfg => { cfg.CreateMap <CredentialDTO, CredentialDC>(); }); IMapper iMapper = configDTOtoDM.CreateMapper(); return(iMapper.Map <CredentialDTO, CredentialDC>(credentialDTO)); }
protected CredentialDTO ParseCredential(string param) { var cred = new CredentialDTO(); if (param.Contains(":")) { string[] raw = param.Split(':'); cred.SAPUsername = raw[0]; cred.SAPPassword = raw[1]; cred.SessionKey = raw[2]; } return(cred); }
public MainWindow() { try { InitializeComponent(); //autorun GetExeLocation(); StartExeWhenPcStartup(fileName, path); ResizeMode = ResizeMode.NoResize; BinaryFormatter formatter = new BinaryFormatter(); CredentialDTO credential = new CredentialDTO(); using (var stream = store.OpenFile("credential.cfg", FileMode.OpenOrCreate, FileAccess.Read)) // this snipet of the code checks for the file user`s credential and decides how to start app { if (stream.Length != 0) { credential = (CredentialDTO)formatter.Deserialize(stream); } } var userId = _dal.GetUserIdByCredential(credential); if (userId.HasValue) { Helper.log.Info($"Login: {credential.Email} Password: {credential.Password} UserId: {userId} entered in the app"); menu = new Menu(_dal, (int)userId); contentControl.Content = menu; menu.AddHandler(Menu.ExitClick, new RoutedEventHandler(ExitButton)); menu.AddHandler(Menu.LogOutClick, new RoutedEventHandler(LogOutButton)); //StartCounting((int)userId); } else { signIn = new SignIn(_dal); contentControl.Content = signIn; signIn.AddHandler(SignIn.SignUpClick, new RoutedEventHandler(SignUpButton)); signIn.AddHandler(SignIn.LoginClick, new RoutedEventHandler(LoginButton)); } } catch (FaultException ex) { Helper.log.Error($"Exception: {ex.ToString()}"); MaterialMessageBox.ShowError(ex.ToString()); } catch (Exception ex) { Helper.log.Error($"Exception: {ex.ToString()}"); MaterialMessageBox.ShowError(ex.ToString()); } }
public async Task <IHttpActionResult> GetAccessToken([FromBody] CredentialDTO credential, [FromUri] string scope = null) { string userName = credential.UserName; string password = credential.Password; try { bool isValidUser = await Authentication.CheckAuthenticateAsync(userName, password, DOMAIN_NAME); if (!isValidUser) { return(Unauthorized()); } AuthorizationDTO authorization = null; if (string.Equals(scope, "none", StringComparison.OrdinalIgnoreCase)) { authorization = new AuthorizationDTO { IdToken = JWTAuthenticate.Instance().GetBasicToken(userName) }; } else { UserDetail user = await Authentication.GetUserEmailFromADAsync(userName, password, DOMAIN_NAME); authorization = new AuthorizationDTO { IdToken = JWTAuthenticate.Instance().GetDetailedToken(userName, user.EmailAddress, user.Name) }; } return(Ok(authorization)); } catch { return(InternalServerError()); } }
public RfcDestination GetRfcDestination(CredentialDTO user) { RfcDestination dest = null; if (_pool.ContainsKey(user.SAPUsername)) { _pool.TryGetValue(user.SAPUsername, out dest); } if (dest == null) { dest = GetNewRfcDestination(user); _pool.Add(user.SAPUsername, dest); } else { if (dest.IsShutDown) { dest = GetNewRfcDestination(user); } } return(dest); }
public async Task <IHttpActionResult> GetUserDetails(CredentialDTO credential) { string userName = credential.UserName; string password = credential.Password; try { bool isValidUser = await Authentication.CheckAuthenticateAsync(userName, password, DOMAIN_NAME); if (!isValidUser) { return(Unauthorized()); } UserDetail userDetails = await Authentication.GetUserEmailFromADAsync(userName, password, DOMAIN_NAME); return(Ok(userDetails)); } catch { return(InternalServerError()); } }
private RfcDestination GetNewRfcDestination(CredentialDTO user) { var p = new { Name = Properties.Settings.Default.SAP_Name, AppServerHost = Properties.Settings.Default.SAP_ServerIP, SystemNumber = Properties.Settings.Default.SAP_SysNumber, SystemID = Properties.Settings.Default.SAP_SystemID, SAPUser = user.SAPUsername, Password = user.SAPPassword, Client = Properties.Settings.Default.SAP_Client, Language = Properties.Settings.Default.SAP_Lang, PoolSize = Properties.Settings.Default.SAPConnPoolSize }; System.Diagnostics.Debug.WriteLine("<NEW_SAP_CONNECTION USER = '******'/>"); var config = new RfcConfigParameters { { RfcConfigParameters.Name, p.Name }, { RfcConfigParameters.AppServerHost, p.AppServerHost }, { RfcConfigParameters.SystemNumber, p.SystemNumber }, { RfcConfigParameters.SystemID, p.SystemID }, { RfcConfigParameters.User, p.SAPUser }, { RfcConfigParameters.Password, p.Password }, { RfcConfigParameters.Client, p.Client }, { RfcConfigParameters.Language, p.Language }, { RfcConfigParameters.ConnectionIdleTimeout, "43200" }, { RfcConfigParameters.PoolIdleTimeout, "43200" }, { RfcConfigParameters.RepositoryConnectionIdleTimeout, "43200" }, { RfcConfigParameters.PoolSize, p.PoolSize.ToString(CultureInfo.InvariantCulture) } }; var dest = RfcDestinationManager.GetDestination(config); return(dest); }
private async void Login_Click(object sender, RoutedEventArgs e) { try { if (String.IsNullOrEmpty(loginField.Text) || String.IsNullOrEmpty(passwordField.Password)) { MaterialMessageBox.ShowError("Please fill in all login details."); } else { string msgErr = String.Empty; string pattern = @"^\w+.*,*@\w+[.]\w+$"; var regex = new Regex(pattern); var match = regex.Match(loginField.Text); if (!match.Success) { msgErr = "Invalid email address. \n"; loginField.Text = String.Empty; passwordField.Password = String.Empty; } pattern = @"\w$"; regex = new Regex(pattern); match = regex.Match(passwordField.Password); if (!match.Success) { msgErr = String.Concat(msgErr, "Password must contain only numbers and letters. \n"); passwordField.Password = String.Empty; } if (String.IsNullOrEmpty(msgErr)) { CredentialDTO credentialDTO = new CredentialDTO { Email = loginField.Text, Password = passwordField.Password }; progressBar.Visibility = Visibility.Visible; progressBar.IsIndeterminate = true; await Task.Run(() => { userId = _dal.GetUserIdByCredential(credentialDTO); }); progressBar.IsIndeterminate = false; progressBar.Visibility = Visibility.Hidden; if (userId.HasValue) { Helper.log.Info($"Email: {loginField.Text} Password: {passwordField.Password} User id: {userId} has been sign in"); RaiseEvent(new RoutedEventArgs(SignIn.LoginClick, this)); } else { Helper.log.Error($"Invalid login credentials. Email: {loginField.Text} Password: {passwordField.Password}"); MaterialMessageBox.ShowError("Invalid login credentials. Please try again."); loginField.Text = String.Empty; passwordField.Password = String.Empty; } } else { Helper.log.Error(msgErr); MaterialMessageBox.ShowError(msgErr); } } } catch (FaultException ex) { progressBar.IsIndeterminate = false; progressBar.Visibility = Visibility.Hidden; Helper.log.Error(ex.ToString()); MaterialMessageBox.ShowError(ex.ToString()); } catch (Exception ex) { progressBar.IsIndeterminate = false; progressBar.Visibility = Visibility.Hidden; Helper.log.Error(ex.ToString()); MaterialMessageBox.ShowError(ex.ToString()); } }
public RfcDestination GetRfcDestinationSoldToParty(CredentialDTO user) { RfcDestination dest = GetNewRfcDestination(user); return(dest); }
public int?GetUserIdByCredential(CredentialDTO credentialDTO) { var credential = MappingCredential.MappingDTOtoDM(credentialDTO); return(_dal.GetUserIdByCredential(credential)); }
public int?GetUserIdByCredential(CredentialDTO credentialDTO) { var credentialDC = MappingCredential.CredentialDTOtoDC(credentialDTO); return(vocabularyClient.GetUserIdByCredential(credentialDC)); }