public UserTO login(string accountUsername, string accountPwd, string permissionString = null) { // TODO - FIX!!! This is very ugly - here so that SOAP and REST services can both be stateful or stateless if (!Convert.ToBoolean(_mySession.MdwsConfiguration.AllConfigs[MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][MdwsConfigConstants.CONNECTION_POOLING])) { return(new gov.va.medora.mdws.AccountLib(_mySession).login(accountUsername, accountPwd, permissionString)); } UserTO result = new UserTO(); AbstractConnection c = null; try { MdwsUtils.checkNullArgs(MdwsUtils.getArgsDictionary( System.Reflection.MethodInfo.GetCurrentMethod().GetParameters(), new List <object>() { _mySession.ConnectionSet.BaseSiteId, accountUsername, accountPwd, permissionString })); c = _mySession.ConnectionSet.BaseConnection; AbstractCredentials credentials = AbstractCredentials.getCredentialsForCxn(c); credentials.AccountName = accountUsername; credentials.AccountPassword = accountPwd; c.Account.AuthenticationMethod = MdwsConstants.LOGIN_CREDENTIALS; if (String.IsNullOrEmpty(permissionString)) { permissionString = MdwsConstants.CPRS_CONTEXT; } _mySession.PrimaryPermission = new MenuOption(permissionString); _mySession.User = c.Account.authenticateAndAuthorize(credentials, _mySession.PrimaryPermission); _mySession.Credentials = credentials; // REST _mySession.setAuthorized(_mySession.ConnectionSet.BaseSiteId); // TODO - revisit, need to mark connections as authorized but more-so need to cache the symbol table // END REST result = new UserTO(_mySession.User); } catch (Exception e) { result.fault = new FaultTO(e); } finally { // REST //RestSessionMgr.getInstance().returnConnections(_mySession); // END REST } return(result); }
/// <summary> /// Log onto a data source. /// </summary> /// <remarks> /// Combines authentication and authorization into a single function. /// It will create a new set of session credentials and a primary permission. /// These credentials can then be used for subsequent visits. /// Login requires a previous connection. /// </remarks> /// <param name="accountId">Access code</param> /// <param name="accountPwd">Verify code</param> /// <param name="permissionString">If blank defaults to CPRS context</param> /// <returns>UserTO</returns> public UserTO login(string accountId, string accountPwd, string permissionString) { UserTO result = new UserTO(); if (!mySession.HasBaseConnection) { result.fault = new FaultTO("There is no connection to log onto"); } else if (accountId == "") { result.fault = new FaultTO("Missing account ID"); } else if (accountPwd == "") { result.fault = new FaultTO("Missing account password"); } if (result.fault != null) { return(result); } try { AbstractConnection c = mySession.ConnectionSet.BaseConnection; AbstractCredentials credentials = AbstractCredentials.getCredentialsForCxn(c); credentials.AccountName = accountId; credentials.AccountPassword = accountPwd; c.Account.AuthenticationMethod = MdwsConstants.LOGIN_CREDENTIALS; if (String.IsNullOrEmpty(permissionString)) { permissionString = MdwsConstants.CPRS_CONTEXT; } mySession.PrimaryPermission = new MenuOption(permissionString); mySession.User = c.Account.authenticateAndAuthorize(credentials, mySession.PrimaryPermission); mySession.Credentials = credentials; result = new UserTO(mySession.User); } catch (Exception e) { result.fault = new FaultTO(e.Message); } return(result); }