public void CheckConnection() { var client = new SecurityServiceClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(client.Endpoint.Address.ToString().Replace("app.timelog.dk/local", HostAddr)); client.GetTokenCompleted += ClientGetTokenCompleted; client.GetTokenAsync(new GetTokenRequest(App.IdentityViewModel.User, App.IdentityViewModel.Password)); }
private void OnDeleteExecute() { Busy = true; securityClient = ContainerProvider.GetInstance.Resolve <SecurityServiceClient>(); securityClient.DeleteUserCompleted += DeleteUserCompleted; securityClient.DeleteUserAsync(SelectedUser.ID); }
private void OnSaveExecute() { Busy = true; securityClient = ContainerProvider.GetInstance.Resolve <SecurityServiceClient>(); if (SelectedUser != null) { oldObject = SelectedUser; SelectedUser.Password = null; SelectedUser.Roles = (UserInRole != null ? Functionality.CloneCollection(UserInRole) : null); SelectedUser.DetachmentID = SelectedDetachment.ID; SelectedUser.WorkerID = (SelectedWorker != null ? SelectedWorker.ID : (int?)null); securityClient.UpdateUserCompleted += UpdateUserCompleted; securityClient.UpdateUserAsync(SelectedUser); } else { User user = new User() { Name = UserName, Roles = (UserInRole != null ? UserInRole : null), WorkerID = (SelectedWorker != null ? SelectedWorker.ID : (int?)null), DetachmentID = SelectedDetachment.ID }; securityClient.AddUserCompleted += AddUserCompleted; securityClient.AddUserAsync(user); } }
private void OnResetPasswordExecute() { Busy = true; securityClient = ContainerProvider.GetInstance.Resolve <SecurityServiceClient>(); securityClient.ResetPasswordCompleted += ResetPasswordCompleted; securityClient.ResetPasswordAsync(SelectedUser.ID); }
public void SignOut(System.Action completeAction = null) { try { IsBusy = true; Status = AppStrings.SigningOutMessage; var svc = new SecurityServiceClient(); svc.SignOutCompleted += (sender, e) => { User = IdentityImpl.Empty; IsAuthenticated = false; if (completeAction != null) { completeAction(); } IsBusy = false; IoC.Get <IEventAggregator>().Publish(new SignedOutMessage()); }; svc.SignOutAsync(); } catch { if (completeAction != null) { completeAction(); } IsBusy = false; } }
public void SignUp() { RefreshBindingScope.Scope(); if (this.Validator.HasErrors) { return; } try { IsBusy = true; SecurityServiceClient client = new SecurityServiceClient(); client.SignUpCompleted += (sender, e) => { IsBusy = false; if (e.Error != null) { e.Error.Handle(); } else { HandleSignUpResult(e.Result); } if (SignUpCompleted != null) { SignUpCompleted(this, EventArgs.Empty); } }; client.SignUpAsync(UserName, Password, Email); } catch { IsBusy = false; } }
public static SecurityServiceClient GetServiceClientWithCredentials(string username, string password) { SecurityServiceClient client = new SecurityServiceClient("WSHttpBinding_ISecurityService"); client.ClientCredentials.UserName.UserName = username; client.ClientCredentials.UserName.Password = password; return(client); }
public static string Login(string login, string password) { var client = new SecurityServiceClient(); return(client.Login(new LoginData { Password = password, UserName = login })); }
public static string Login(string login, string password) { var client = new SecurityServiceClient(); return client.Login(new LoginData { Password = password, UserName = login }); }
public void LoginTimelog(string url, string initials, string password) { tlViewModel.ChangeState(ETimelogState.Running, ETimelogOperation.Login, String.Empty); TimelogSession tlSession = TimelogSession.Instance; tlSession.SessionUrl = url; SecurityServiceClient tlSecurityClient = tlSession.SecurityClient; tlSecurityClient.GetTokenCompleted += tlSecurityClient_GetTokenCompleted; tlSecurityClient.GetTokenAsync(initials, password); }
public void ActivateUser(string activationTicket, Action <ActivationResult> completeAction) { if (completeAction == null) { throw new ArgumentNullException("completeAction"); } try { SecurityServiceClient svc = new SecurityServiceClient(); svc.ActivateUserCompleted += (sender, e) => { ActivationResult result = null; if (e.Error != null) { result = new ActivationResult(null, false, ErrorStrings.GenericServerErrorMessage); } else { if (e.Result.Status == ActivationUserStatus.Success) { result = new ActivationResult(e.Result.UserName); User = new IdentityImpl(e.Result.UserName); IsAuthenticated = true; } else if (e.Result.Status == ActivationUserStatus.AlreadyActivated) { result = new ActivationResult(null, false, string.Format(ErrorStrings.UserAlreadyActivatedMessage, e.Result.UserName)); } else if (e.Result.Status == ActivationUserStatus.UserNotFound) { result = new ActivationResult(null, false, ErrorStrings.ActivationFailed_InvalidTicket); } else { result = new ActivationResult(null, false, ErrorStrings.ActivationFailed_ServerError); } } completeAction(result); }; svc.ActivateUserAsync(activationTicket); } catch { completeAction(new ActivationResult(null, false, ErrorStrings.GenericErrorMessage)); IsBusy = false; } }
public void SignIn(string userName, string password, bool isPersistent, Action <SignInResult> completeAction) { if (completeAction == null) { throw new ArgumentNullException("completeAction"); } try { IsBusy = true; Status = AppStrings.SigningInMessage; var svc = new SecurityServiceClient(); svc.SignInCompleted += (sender, e) => { var status = e.Result; SignInResult result = null; if (status == SignInStaus.Success) { User = new IdentityImpl(userName); IsAuthenticated = true; result = new SignInResult(User); } else if (status == SignInStaus.WrongCredentials) { result = new SignInResult(null, false, ErrorStrings.InvalidCredentialsMessage); } else if (status == SignInStaus.Inactive) { result = new SignInResult(null, false, ErrorStrings.InactiveAccountMessage); } else { result = new SignInResult(null, false, ErrorStrings.GenericServerErrorMessage); } completeAction(result); IsBusy = false; }; svc.SignInAsync(userName, password, isPersistent); } catch { completeAction(new SignInResult(null, false, ErrorStrings.GenericErrorMessage)); IsBusy = false; } }
private void OnExecute() { Password password = new Password(UserName, OldPassword); if (password.Hash != LoginInit.user.Password || NewPassword != ConfirmPassword) { Status = "Heslo se nepodařilo změnit!"; } else { Busy = true; securityClient = ContainerProvider.GetInstance.Resolve <SecurityServiceClient>(); securityClient.ChangePasswordCompleted += ChangePasswordCompleted; tmpPass = LoginInit.user.Password; password = new Password(UserName, NewPassword); LoginInit.user.Password = password.Hash; securityClient.ChangePasswordAsync(LoginInit.user); } }
public void StartUpload() { Status = PhotoUploadStatus.Uploading; try { // Generate a request token locally and use it // to ask server for a photo upload ticket // Once ticket received, send both request token and ticket // to server for upload authentication string requestToken = Guid.NewGuid().ToString(); SecurityServiceClient svc = new SecurityServiceClient(); svc.RequestPhotoUploadTicketCompleted += (sender, e) => { if (e.Error != null) { Status = PhotoUploadStatus.Error; } else if (!string.IsNullOrEmpty(e.Result)) { _fileStream = _file.OpenRead(); _dataLength = _fileStream.Length; var webRequest = CreateUploadRequest(_file, _albumId, requestToken, e.Result); webRequest.BeginGetRequestStream(new AsyncCallback(WriteToStreamCallback), webRequest); FileName = _file.Name; CanCancel = true; if (UploadStarted != null) { UploadStarted(this, EventArgs.Empty); } } else { // TODO: Inform users they don't are not authenticated to do this Status = PhotoUploadStatus.Error; } }; svc.RequestPhotoUploadTicketAsync(requestToken); } catch { Status = PhotoUploadStatus.Error; } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); IUnityContainer container = ContainerProvider.GetInstance; container.RegisterType <INavigator, Navigator>(); container.RegisterType <DataServiceClient, DataServiceClient>( new GetterLifetimeManager( () => { var dataClient = new DataServiceClient(); dataClient.ClientCredentials.UserName.UserName = LoginInit.user.Name; dataClient.ClientCredentials.UserName.Password = LoginInit.user.Password; dataClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; return(dataClient); })); container.RegisterType <SecurityServiceClient, SecurityServiceClient>( new GetterLifetimeManager( () => { var securityClient = new SecurityServiceClient(); securityClient.ClientCredentials.UserName.UserName = LoginInit.user.Name; securityClient.ClientCredentials.UserName.Password = LoginInit.user.Password; securityClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; return(securityClient); })); container.RegisterType <FullTextServiceClient, FullTextServiceClient>( new GetterLifetimeManager( () => { var fullTextClient = new FullTextServiceClient(); fullTextClient.ClientCredentials.UserName.UserName = LoginInit.user.Name; fullTextClient.ClientCredentials.UserName.Password = LoginInit.user.Password; fullTextClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None; return(fullTextClient); })); var navigator = container.Resolve <INavigator>(); navigator.Startup <LoginView, LoginViewModel>(ViewMode.Window); }
public ActionResult Login(string userName, string uPassword) { bool check = UserClient.Login(userName, uPassword); int id = 0; ServicePointManager.ServerCertificateValidationCallback = (obj, certificate, chain, errors) => true; AuthServiceClient authClient = new AuthServiceClient(); var isLoggedIn = authClient.Login(userName, uPassword); if (isLoggedIn) { id = UserClient.GetUserByUserName(userName).ID; SecurityServiceClient client = new SecurityServiceClient("WSHttpBinding_ISecurityService"); client.ClientCredentials.UserName.UserName = userName; client.ClientCredentials.UserName.Password = uPassword; var data = client.GetData(1337); } return(RedirectToAction("Index", new { id = id })); }
protected void btn_forget_password_Click(object sender, EventArgs e) { try { lbl_error.Text = ""; string popupScript = ""; SecurityServiceClient pxy = new SecurityServiceClient(); string error = ""; if (pxy.ForgetPassword(txt_user_name.Text, txt_email_id.Text, out error)) { if (error != "") { popupScript = "<script language='javascript'>showErrorToast('" + error + "');</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), "popupScript", popupScript); } else { popupScript = "<script language='javascript'>showsuccessToast('Email has been send successfully');</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), "popupScript", popupScript); } } else { if (error != "") { popupScript = "<script language='javascript'>showErrorToast('" + error.Replace("'", "") + "');</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), "popupScript", popupScript); } else { popupScript = "<script language='javascript'>showErrorToast('Email Sending Failed');</script>"; Page.ClientScript.RegisterStartupScript(typeof(Page), "popupScript", popupScript); } } } catch (Exception) { throw; } }
public UserViewModel(SecurityServiceClient securityClient, DataServiceClient dataClient, UserViewModelValidator validator, INavigator navigator) { Busy = true; busyCount = 2; this.securityClient = securityClient; this.dataClient = dataClient; this.validator = validator; Navigator = navigator; Enabled = true; InitCommands(); this.securityClient.GetRolesCompleted += GetRolesCompleted; this.securityClient.GetRolesAsync(); this.securityClient.GetUsersCompleted += GetUsersCompleted; this.securityClient.GetUsersAsync(); this.dataClient.GetDetachmentsCompleted += GetDetachmentsCompleted; this.dataClient.GetDetachmentsAsync(); PropertyChanged += (s, e) => { (SaveCommand as Command).OnCanExecuteChanged(); (NewCommand as Command).OnCanExecuteChanged(); (DeleteCommand as Command).OnCanExecuteChanged(); }; }
public void LoadUser() { try { string signedInUser = string.Empty; var svc = new SecurityServiceClient(); svc.IsAuthenticatedCompleted += (sneder, e) => { if (e.Error == null) { signedInUser = e.Result; if (!string.IsNullOrEmpty(signedInUser)) { User = new IdentityImpl(signedInUser); IsAuthenticated = true; } } }; svc.IsAuthenticatedAsync(); } catch { } }
public void DeleteFromClientDocumentation(long documentId) { try { _impersonator.ImpersonateValidUser(_username, _domain, _encryptedPassword); } catch (Exception ex) { throw ex; } finally { _impersonator.Dispose(); } using (var securityService = new SecurityServiceClient()) using (new OperationContextScope(securityService.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser")); securityService.EnsureUserExists(null); } using (var clientDocumentService = new ClientDocumentServiceClient()) using (new OperationContextScope(clientDocumentService.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser")); var doc = clientDocumentService.GetById(documentId); if (doc.Deleted == false) { long[] documentIds = { documentId }; clientDocumentService.DeleteByIds(documentIds); } } }
public static bool AuthenticateUser(Credentials Credential, out string error, out string ReturnURL) { SecurityServiceClient pxy = new SecurityServiceClient(); return(pxy.AuthenticateUser(Credential, out error, out ReturnURL)); }
public HttpResponse GetExecutiveSummaryForChecklist(Guid checklistId) { var checklist = _checklistRepository.GetById(checklistId); ClientDocumentDto clientDocumentDto = null; if (checklist != null && checklist.ActionPlan != null && checklist.ActionPlan.ExecutiveSummaryDocumentLibraryId.HasValue && checklist.ActionPlan.ExecutiveSummaryDocumentLibraryId.Value != 0) { using (var securityService = new SecurityServiceClient()) using (new OperationContextScope(securityService.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser")); securityService.EnsureUserExists(null); } using (var clientDocumentService = new ClientDocumentServiceClient()) { using (new OperationContextScope(clientDocumentService.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser")); clientDocumentDto = clientDocumentService.GetByIdWithContent( checklist.ActionPlan.ExecutiveSummaryDocumentLibraryId.Value); } } } // get the object representing the HTTP response to browser HttpResponse httpResponse = System.Web.HttpContext.Current.Response; if (clientDocumentDto == null) { httpResponse.Status = "204 No Content"; httpResponse.StatusCode = 204; httpResponse.ContentType = "text/html"; httpResponse.Write("Error downloading file - Please contact with us"); httpResponse.End(); } else { httpResponse.AddHeader("Content-Type", "application/pdf"); httpResponse.AddHeader("Content-Disposition", String.Format("attachment; filename={1}; size={0}", clientDocumentDto.FileBytes.Length.ToString(), clientDocumentDto.OriginalFilename)); // write the PDF document bytes as attachment to HTTP response httpResponse.BinaryWrite(clientDocumentDto.FileBytes); // Note: it is important to end the response, otherwise the ASP.NET // web page will render its content to PDF document stream httpResponse.End(); } return httpResponse; }
/// <summary> /// 登录权限有效性判断 /// </summary> /// <param name="message"></param> /// <returns></returns> private bool CheckLogin(out string message) { message = string.Empty; SecurityServiceClient SecurityClient = new SecurityServiceClient(); DataTable dtUser = new DataTable(); int flag = SecurityClient.CheckUserLogin(out dtUser, txtName.Text.ToString().Trim(), txtPassword.Text.Trim()); if (flag == 1) //用户有效,但是被锁定 { message = "该用户已被锁定,请联系管理员解决!"; return false; } else if (flag == 3) //登录成功 { AuthenUserMD LoginUser = new AuthenUserMD(dtUser.Rows[0]); Session.Add("LOGINUSER", LoginUser); Response.Cookies["ORGID"].Value = LoginUser.ORGID; Response.Cookies["ORG_CODE"].Value = LoginUser.ORG_CODE; Response.Cookies["ORGID"].Expires = DateTime.Now.AddDays(1); Response.Cookies["ORG_CODE"].Expires = DateTime.Now.AddDays(1); Response.Cookies["SelectedMsg"].Expires = DateTime.Now.AddDays(-1); return true; } else //登录失败 { message = "用户名或密码不正确,请重新输入!"; return false; } }
public long WriteToClientDocumentation(string fileName, byte[] pdfBytes, int clientId, long? siteId) { long documentID = 0; var fullFileName = _holdingPath + Guid.NewGuid(); try { _impersonator.ImpersonateValidUser(_username, _domain, _encryptedPassword); File.WriteAllBytes(fullFileName, pdfBytes); } catch (Exception ex) { throw ex; } finally { _impersonator.Dispose(); } using(var securityService = new SecurityServiceClient()) using (new OperationContextScope(securityService.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser")); securityService.EnsureUserExists(null); } using(var clientDocumentService = new ClientDocumentServiceClient()) using (new OperationContextScope(clientDocumentService.InnerChannel)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser")); var createClientDocumentRequest = new CreateClientDocumentRequest() { ClientId = clientId, DocumentTypeId = 131, //MAGIC NUMBER: refactor out OriginalFilename = fileName, PhysicalFilePath = fullFileName, Title = fileName, SiteId = siteId }; documentID = clientDocumentService.CreateDocument(createClientDocumentRequest); } File.Delete(fullFileName); return documentID; }
/// <summary> /// Disposes the handler. /// </summary> public void Dispose() { this._securityClient = null; this._token = null; _instance = null; }
public static bool SaveChat(ChatHistory chatHistory) { SecurityServiceClient pxy = new SecurityServiceClient(); return(pxy.SaveChat(chatHistory)); }
public static ChatHistory[] GetOfflineChats(int SentTo) { SecurityServiceClient pxy = new SecurityServiceClient(); return(pxy.GetOfflineChats(SentTo)); }
public static BrokerageOnline.TransferObjects.UserDetail[] GetChatUsers() { SecurityServiceClient pxy = new SecurityServiceClient(); return(pxy.GetChatUsers()); }
/// <summary> ///检查用户是否有权限访问请求的页面 /// 如果数据库中设置该页面的属性Skip=true,那么该页面始终都可以访问。 /// </summary> /// <remarks></remarks> protected void CheckPermission() { string path = Request.AppRelativeCurrentExecutionFilePath; if (string.Compare("~/Pages/Common/Login.aspx", path, true) != 0 && string.Compare("~/Pages/Common/Default.aspx", path, true) != 0) { //通过WebService验证页面是否有权限访问。 //SecuritySRVClient securityClient = new SecuritySRVClient(); //this.LogonUser = new EDI.WEB.Base.AuthenUserMD(); SecurityServiceClient securityClient = new SecurityServiceClient(); bool canAccess = false; canAccess = securityClient.CheckCanAccessPage(LogonUser.LOGINNAME.ToString(), path); if (!canAccess) { this.Alert("你无权访问该页面。如需访问,请联系系统管理员解决!"); //Server.Transfer("~/Pages/Common/Default.aspx", false); Response.Close(); //TODO: 创建一个AccessDeny.aspx页面。 } } }
public void SignIn(string userName, string password, bool isPersistent, Action<SignInResult> completeAction) { if (completeAction == null) throw new ArgumentNullException("completeAction"); try { IsBusy = true; Status = AppStrings.SigningInMessage; var svc = new SecurityServiceClient(); svc.SignInCompleted += (sender, e) => { var status = e.Result; SignInResult result = null; if (status == SignInStaus.Success) { User = new IdentityImpl(userName); IsAuthenticated = true; result = new SignInResult(User); } else if (status == SignInStaus.WrongCredentials) { result = new SignInResult(null, false, ErrorStrings.InvalidCredentialsMessage); } else if (status == SignInStaus.Inactive) { result = new SignInResult(null, false, ErrorStrings.InactiveAccountMessage); } else { result = new SignInResult(null, false, ErrorStrings.GenericServerErrorMessage); } completeAction(result); IsBusy = false; }; svc.SignInAsync(userName, password, isPersistent); } catch { completeAction(new SignInResult(null, false, ErrorStrings.GenericErrorMessage)); IsBusy = false; } }
public static bool ResetPassword(Credentials credential, out string error) { SecurityServiceClient pxy = new SecurityServiceClient(); return(pxy.ResetPassword(credential, out error)); }
public static string GetUserID(string UserName) { SecurityServiceClient pxy = new SecurityServiceClient(); return(pxy.GetUserID(UserName)); }
public void ActivateUser(string activationTicket, Action<ActivationResult> completeAction) { if (completeAction == null) throw new ArgumentNullException("completeAction"); try { SecurityServiceClient svc = new SecurityServiceClient(); svc.ActivateUserCompleted += (sender, e) => { ActivationResult result = null; if (e.Error != null) { result = new ActivationResult(null, false, ErrorStrings.GenericServerErrorMessage); } else { if (e.Result.Status == ActivationUserStatus.Success) { result = new ActivationResult(e.Result.UserName); User = new IdentityImpl(e.Result.UserName); IsAuthenticated = true; } else if (e.Result.Status == ActivationUserStatus.AlreadyActivated) { result = new ActivationResult(null, false, string.Format(ErrorStrings.UserAlreadyActivatedMessage, e.Result.UserName)); } else if (e.Result.Status == ActivationUserStatus.UserNotFound) { result = new ActivationResult(null, false, ErrorStrings.ActivationFailed_InvalidTicket); } else { result = new ActivationResult(null, false, ErrorStrings.ActivationFailed_ServerError); } } completeAction(result); }; svc.ActivateUserAsync(activationTicket); } catch { completeAction(new ActivationResult(null, false, ErrorStrings.GenericErrorMessage)); IsBusy = false; } }
protected void btnLogin_Click(object sender, EventArgs e) { string msg = string.Empty; if (this.txtName.Text.Trim() == "") { txtName.Focus(); msg = "请输入用户名!" ; ClientScript.RegisterStartupScript(this.GetType(), "key1", "window.alert('" + msg + "');", true); return; } if (this.txtPassword.Text.Trim().Length == 0) { txtPassword.Focus(); msg = "请输入密码!"; ClientScript.RegisterStartupScript(this.GetType(), "key2", "window.alert('" + msg + "');", true); return; } if (this.txtCheckCode.Text.Trim().Length == 0) { txtCheckCode.Focus(); msg = "请输入验证码!"; ClientScript.RegisterStartupScript(this.GetType(), "key3", "window.alert('" + msg + "');", true); return; } //判断验证码是否匹配 if (Session["Validate_Code"] != null && Session["Validate_Code"].ToString().Trim().ToLower() != txtCheckCode.Text.Trim().ToLower()) { msg = "验证码不匹配,请重新输入!"; ClientScript.RegisterStartupScript(this.GetType(), "key4", "window.alert('" + msg + "');", true); return; } string message = string.Empty; SecurityServiceClient securityClient = new SecurityServiceClient(); //securityClient.ClientCredentials.UserName.UserName = this.txtName.Text.Trim(); //securityClient.ClientCredentials.UserName.Password = this.txtPassword.Text.Trim(); //DataTable dt = securityClient.GetUserAccount("paul"); if (CheckLogin(out message)) { FormsAuthentication.Authenticate(this.txtName.Text, this.txtPassword.Text); if (Request.QueryString.Get("ReturnUrl") != null) { FormsAuthentication.RedirectFromLoginPage(this.txtName.Text, false); } else { FormsAuthentication.SetAuthCookie(this.txtName.Text, false); Response.Redirect("~/Pages/Common/Default.aspx"); } } else { ClientScript.RegisterStartupScript(this.GetType(), "key5", "window.alert('" + message + "');", true); } }
internal void Login() { var secClient = new SecurityServiceClient(); secClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(secClient.Endpoint.Address.ToString().Replace("app.timelog.dk/local", HostAddr)); secClient.GetTokenCompleted += _secClient_GetTokenCompleted; secClient.GetTokenAsync(new GetTokenRequest(App.IdentityViewModel.User, App.IdentityViewModel.Password)); }
public void SignOut(System.Action completeAction = null) { try { IsBusy = true; Status = AppStrings.SigningOutMessage; var svc = new SecurityServiceClient(); svc.SignOutCompleted += (sender, e) => { User = IdentityImpl.Empty; IsAuthenticated = false; if (completeAction != null) completeAction(); IsBusy = false; IoC.Get<IEventAggregator>().Publish(new SignedOutMessage()); }; svc.SignOutAsync(); } catch { if (completeAction != null) completeAction(); IsBusy = false; } }
public void StartUpload() { Status = PhotoUploadStatus.Uploading; try { // Generate a request token locally and use it // to ask server for a photo upload ticket // Once ticket received, send both request token and ticket // to server for upload authentication string requestToken = Guid.NewGuid().ToString(); SecurityServiceClient svc = new SecurityServiceClient(); svc.RequestPhotoUploadTicketCompleted += (sender, e) => { if (e.Error != null) { Status = PhotoUploadStatus.Error; } else if (!string.IsNullOrEmpty(e.Result)) { _fileStream = _file.OpenRead(); _dataLength = _fileStream.Length; var webRequest = CreateUploadRequest(_file, _albumId, requestToken, e.Result); webRequest.BeginGetRequestStream(new AsyncCallback(WriteToStreamCallback), webRequest); FileName = _file.Name; CanCancel = true; if (UploadStarted != null) UploadStarted(this, EventArgs.Empty); } else { // TODO: Inform users they don't are not authenticated to do this Status = PhotoUploadStatus.Error; } }; svc.RequestPhotoUploadTicketAsync(requestToken); } catch { Status = PhotoUploadStatus.Error; } }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="macAddress"></param> /// <returns></returns> private string GetCustomerKey(string username, string macAddress) { string customerKey = string.Empty; using (SecurityServiceClient client = new SecurityServiceClient()) { try { customerKey = client.GetCustomerKey(username, macAddress); } catch (FaultException) { return null; } } return customerKey; }
// public ObservableCollection<ProjectHeader> Projects { // get { return _projects; } // } // public ObservableCollection<CustomerHeader> Customers { // get { return _customers; } // } public void LoadProjects() { LoadInProgress = true; // var _add = new System.ServiceModel.EndpointAddress("https:// app.timelog.dk/local/WebServices/Security/V1_0/SecurityServiceSecure.svc"); SecurityServiceClient _secClient = new SecurityServiceClient(); _secClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(_secClient.Endpoint.Address.ToString().Replace("app.timelog.dk/local", App.IdentityViewModel.HostAddr)); _secClient.GetTokenCompleted += new EventHandler<GetTokenCompletedEventArgs>(_secClient_GetTokenCompleted); _secClient.GetTokenAsync(new tlpSecurity.GetTokenRequest(App.IdentityViewModel.User, App.IdentityViewModel.Password)); }
private string GetConnectionString(string customerKey, string macAddress) { string connectionString = string.Empty; using (SecurityServiceClient client = new SecurityServiceClient()) { try { connectionString = client.AuthenticateCustomerKey(customerKey, macAddress); } catch (FaultException) { return null; } } return connectionString; }