setVisitCredentials() public static method

public static setVisitCredentials ( string duz, string ssn, string username, string userphone, DataSource authenticatingSource, string pwd ) : AbstractCredentials
duz string
ssn string
username string
userphone string
authenticatingSource gov.va.medora.mdo.DataSource
pwd string
return gov.va.medora.mdo.dao.AbstractCredentials
コード例 #1
0
ファイル: AccountLib.cs プロジェクト: monkeyglasses/mdws
        /// <summary>
        /// Visit a single data source and authorize without a previous login.
        /// </summary>
        /// <remarks>
        /// This method is for visits without logins.  It makes its credentials
        /// and user the session credentials and session user.
        /// </remarks>
        /// <param name="pwd">Client app's BSE security phrase</param>
        /// <param name="sourceId">Station number of site to visit</param>
        /// <param name="userSourceId">User's station number</param>
        /// <param name="userName">User's name as it appears in VistA</param>
        /// <param name="userLocalId">User's DUZ</param>
        /// <param name="userFederatedId">User's SSN</param>
        /// <param name="permissionString">If blank defaults to CPRS context</param>
        /// <returns>UserTO</returns>
        public UserTO visitAndAuthorize(
            string pwd,
            string sourceId,
            string userSourceId,
            string userName,
            string userLocalId,
            string userFederatedId,
            string permissionString)
        {
            UserTO result = new UserTO();

            //Make sure we have all the args we need
            if (mySession == null || mySession.SiteTable == null)
            {
                result.fault = new FaultTO("No session has been started");
            }
            else if (sourceId == "")
            {
                result.fault = new FaultTO("Missing sitecode of site to visit");
            }
            else if (mySession.SiteTable.getSite(sourceId) == null)
            {
                result.fault = new FaultTO("No site " + sourceId + " in the site table");
            }
            else if (mySession.ConnectionSet != null &&
                     mySession.ConnectionSet.Count > 0 &&
                     mySession.ConnectionSet.IsConnected(sourceId))
            {
                result.fault = new FaultTO("Site " + sourceId + " already connected");
            }
            else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0)
            {
                result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?");
            }
            else if (userSourceId == "")
            {
                result.fault = new FaultTO("Missing userSitecode");
            }
            else if (userName == "")
            {
                result.fault = new FaultTO("Missing userName");
            }
            else if (userLocalId == "")
            {
                result.fault = new FaultTO("Missing DUZ");
            }
            else if (userFederatedId == "")
            {
                result.fault = new FaultTO("Missing SSN");
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                SiteTable t        = mySession.SiteTable;
                Site      userSite = (Site)t.Sites[userSourceId];
                if (userSite == null)
                {
                    result.fault = new FaultTO("No such site: " + userSourceId);
                    return(result);
                }

                Site visitSite = (Site)t.Sites[sourceId];
                if (visitSite == null)
                {
                    result.fault = new FaultTO("No such site: " + sourceId);
                    return(result);
                }

                DataSource dataSource = visitSite.getDataSourceByModality("HIS");
                if (dataSource == null)
                {
                    result.fault = new FaultTO("Site " + sourceId + " has no HIS");
                    return(result);
                }

                mySession.Credentials = MdwsUtils.setVisitCredentials(userLocalId, userFederatedId, userName, "", userSite.getDataSourceByModality("HIS"), pwd);
                mySession.Credentials.SecurityPhrase = pwd;

                if (permissionString == "")
                {
                    permissionString = mySession.DefaultPermissionString;
                }
                mySession.PrimaryPermission = new MenuOption(permissionString);

                mySession.User = doTheVisit(sourceId, mySession.Credentials, mySession.PrimaryPermission);

                mySession.User.Name        = new PersonName(userName);
                mySession.User.SSN         = new SocSecNum(userFederatedId);
                mySession.User.LogonSiteId = dataSource.SiteId;

                addMyCxn2CxnSet();
                result = new UserTO(mySession.User);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            return(result);
        }