/// <summary> /// Changes the email or password. /// </summary> /// <param name="currentCredentials">The current credentials.</param> /// <param name="cpec">The credentials required for the email change.</param> /// <returns></returns> public SessionResponse ChangePassword(NetSuiteCredential currentCredentials, ChangePassword cpec) { var svcMgr = _svcPoolMgr.BuildTemporaryServiceManager(); svcMgr.Credentials = currentCredentials; return(svcMgr.ChangePassword(cpec)); }
/// <summary> /// Logins in to NetSuite using the Credentials provided. /// </summary> /// <param name="credential">NetSuite user's Credentials.</param> /// <returns>Response from NetSuite.</returns> public override IUserSession CreateSession(NetSuiteCredential credential) { var serviceProxy = this.ServiceProxy.Clone(); var response = ExecuteLogin(serviceProxy, credential, null); return(new UserSession(serviceProxy, credential, response)); }
private IServiceManager GenerateServiceManager(NetSuiteCredential credential) { IServiceManager svcMgr = _factoryMethod.Invoke(); svcMgr.Credentials = credential; svcMgr.Configuration = ServiceConfiguration ?? new NetSuiteServiceConfiguration(); return(svcMgr); }
/// <summary>Performs the actual login</summary> /// <returns></returns> private SessionResponse ExecuteLogin(INetSuiteService serviceProxy, NetSuiteCredential credential, Action <ServiceInvocationEventArgs> onErrorCallback) { bool loggedIn = false; _log.Debug("Initializing NetSuite Service Proxy", null); serviceProxy.CookieContainer = new CookieContainer(); Configuration.Configure(serviceProxy); SessionResponse ssnResponse = null; ServiceInvocationEventArgs invokerEventArgs = new ServiceInvocationEventArgs("login", credential); for (; invokerEventArgs.InvokationAttempt < Configuration.RetryCount; invokerEventArgs.InvokationAttempt++) { ssnResponse = TryLogin(serviceProxy, credential.GetPassport(), _log, invokerEventArgs, onErrorCallback); loggedIn = (ssnResponse != null && ssnResponse.status.isSuccessSpecified && ssnResponse.status.isSuccess); if (this.IsSuspended) { this.IsSuspended = !loggedIn; } if (loggedIn || invokerEventArgs.Cancel) { break; } else if (!invokerEventArgs.ForceRetry) { throw invokerEventArgs.Exception; } else if (invokerEventArgs.InvokationAttempt != Configuration.RetryCount - 1) { WaitForRetryInterval(); } } if (!loggedIn) { ProcessLoginError(ssnResponse, invokerEventArgs); } return(ssnResponse); }
/// <summary> /// Adopts a session created using the <see cref="INetSuiteServiceBase.CreateSession(NetSuiteCredential)"/> /// method. /// </summary> /// <param name="session">An active session.</param> public void AdoptSession(IUserSession session) { var userSession = session as UserSession; if (null == userSession) { throw new NsException("This session was not generated by a ServiceManager and therefore, cannot be adopted."); } //else if (userSession.ServiceProxy == null) //{ // throw new NsException("Specified session is inactive."); //} else { this.ServiceProxy = userSession.ServiceProxy ?? this.ServiceProxy.Clone(); this.Credentials = userSession.Credentials; this._virtualSessionId = userSession.SessionId; this.IsSuspended = false; } }
/// <summary> /// Initializes a new instance of the <see cref="UserSession"/> class. /// </summary> /// <param name="service">The service.</param> /// <param name="credential">Credential used to create this session.</param> /// <param name="response">The response.</param> internal UserSession(INetSuiteService service, NetSuiteCredential credential, SessionResponse response) { UserId = response.userId; Roles = response.wsRoleList; ServiceProxy = service; Credentials = credential; IsSuccess = response.status.isSuccess; if (service.CookieContainer != null) { var nsUrl = new Uri(service.Url); var cookies = service.CookieContainer.GetCookies(nsUrl); for (int i = 0; i < cookies.Count; i++) { if (cookies[i].Name.Equals(JSESSIONID, StringComparison.CurrentCultureIgnoreCase)) { SessionId = cookies[i].Value; break; } } } }
/// <summary> /// Logins in to NetSuite using the Credentials provided. /// </summary> /// <param name="credential">NetSuite user's Credentials.</param> /// <returns>Response from NetSuite.</returns> public override IUserSession CreateSession(NetSuiteCredential credential) { var serviceManager = ServicePoolManager.BuildTemporaryServiceManager(); return(serviceManager.CreateSession(credential)); }
/// <summary> /// Logins in to NetSuite using the Credentials provided. /// </summary> /// <param name="credential">NetSuite user's Credentials.</param> /// <returns>Response from NetSuite.</returns> public abstract IUserSession CreateSession(NetSuiteCredential credential);