예제 #1
0
        static VistaConnection login(String host, Int32 port, String accessCode, String verifyCode)
        {
            DataSource src = new DataSource()
            {
                SiteId = new SiteId()
                {
                    Id = "500", Name = "Local"
                }, Provider = host, Modality = "HIS", Protocol = "VISTA", Port = port
            };
            VistaConnection cxn = new VistaConnection(src);

            cxn.ConnectStrategy = new VistaNatConnectStrategy(cxn);

            cxn.connect();

            AbstractCredentials credentials = new VistaCredentials();

            credentials.AccountName          = accessCode;
            credentials.AccountPassword      = verifyCode;
            cxn.Account.AuthenticationMethod = VistaConstants.LOGIN_CREDENTIALS; // TBD - VERY IMPORTANT!!!! SHOULD THIS BE Connection or Credentials?!?!?!?

            AbstractPermission permission = new MenuOption("DVBA CAPRI GUI");

            permission.IsPrimary = true;

            User authenticatedUser = cxn.Account.authenticateAndAuthorize(credentials, permission);

            System.Console.WriteLine("Successfully authenticated! Ready for some work...");

            return(cxn);
        }
예제 #2
0
        // This constructor is needed for API level tests.
        public MockConnection(string siteId, string protocol, bool updateRpc = false) : base(null)
        {
            this.DataSource          = new DataSource();
            this.DataSource.SiteId   = new SiteId(siteId, "Mock");
            this.DataSource.Protocol = protocol;

            //DP 3/24/2011
            //I commented out the line below, the pid should not be set to
            //"0" as the default, as all of the other subclasses of
            //AbstractCollection do not set it.  This was causing conflicts
            //b/w the MockConnection.XML file and the DaoX tests.

            //I will fix the affected tests (14 now fail as the exception
            //message has changed).

            //this.Pid = "0";

            setXmlSource(siteId, updateRpc);

            this.Account   = new VistaAccount(this);
            this.updateRpc = updateRpc;

            AbstractCredentials credentials = new VistaCredentials();

            credentials.AccountName     = "AccessCode";
            credentials.AccountPassword = "******";
            AbstractPermission permission = new MenuOption(VistaConstants.MDWS_CONTEXT);

            permission.IsPrimary = true;
            this.Account.Permissions.Add(permission.Name, permission);
            //permission = new MenuOption(VistaConstants.DDR_CONTEXT);
            //this.Account.Permissions.Add(permission.Name, permission);
            sysFileHandler = new VistaSystemFileHandler(this);
        }
예제 #3
0
        internal AbstractCredentials getAdministrativeCredentials(Site site)
        {
            AbstractCredentials credentials = new VistaCredentials();

            credentials.LocalUid             = VistaAccount.getAdminLocalUid(site.Id);
            credentials.FederatedUid         = mySession.MdwsConfiguration.AllConfigs[ConfigFileConstants.PRIMARY_CONFIG_SECTION][MdwsConfigConstants.SERVICE_ACCOUNT_FED_UID];
            credentials.SubjectName          = mySession.MdwsConfiguration.AllConfigs[ConfigFileConstants.PRIMARY_CONFIG_SECTION][MdwsConfigConstants.SERVICE_ACCOUNT_NAME];
            credentials.SubjectPhone         = "";
            credentials.AuthenticationSource = site.getDataSourceByModality("HIS");
            credentials.AuthenticationToken  = site.Id + '_' + credentials.LocalUid;
            return(credentials);
        }
예제 #4
0
        internal AbstractCredentials getAdministrativeCredentials(Site site)
        {
            AbstractCredentials credentials = new VistaCredentials();

            credentials.LocalUid             = VistaAccount.getAdminLocalUid(site.Id);
            credentials.FederatedUid         = "123456789";
            credentials.SubjectName          = "DEPARTMENT OF DEFENSE,USER";
            credentials.SubjectPhone         = "";
            credentials.AuthenticationSource = site.getDataSourceByModality("HIS");
            credentials.AuthenticationToken  = site.Id + '_' + credentials.LocalUid;
            return(credentials);
        }
예제 #5
0
        public CrudSvc()
        {
            if (ConnectionPools.getInstance().PoolSource != null)
            {
                return; // already set up the pools!
            }

            _mySession = new MySession();
            SiteTable sites = _mySession.SiteTable;
            IList <AbstractPoolSource> sources     = new List <AbstractPoolSource>();
            ConnectionPoolsSource      poolsSource = new ConnectionPoolsSource();

            poolsSource.CxnSources = new Dictionary <string, ConnectionPoolSource>();
            User user = _mySession.MdwsConfiguration.ApplicationProxy;
            AbstractCredentials creds = new VistaCredentials();

            creds.AccountName                 = user.UserName;
            creds.AccountPassword             = user.Pwd;
            creds.AuthenticationSource        = new DataSource(); // BSE
            creds.AuthenticationSource.SiteId = new SiteId(user.LogonSiteId.Id, user.LogonSiteId.Name);
            creds.AuthenticationToken         = user.LogonSiteId.Id + "_" + user.Uid;
            creds.LocalUid       = user.Uid;
            creds.FederatedUid   = user.SSN.toString();
            creds.SubjectName    = user.Name.getLastNameFirst();
            creds.SubjectPhone   = user.Phone;
            creds.SecurityPhrase = _mySession.MdwsConfiguration.AllConfigs
                                   [conf.MdwsConfigConstants.MDWS_CONFIG_SECTION][conf.MdwsConfigConstants.SECURITY_PHRASE];

            foreach (DataSource source in sites.Sources)
            {
                if (!String.Equals(source.Protocol, "VISTA", StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }
                ConnectionPoolSource newSource = new ConnectionPoolSource()
                {
                    LoadStrategy = (LoadingStrategy)Enum.Parse(typeof(LoadingStrategy),
                                                               _mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_LOAD_STRATEGY]),
                    MaxPoolSize       = Convert.ToInt32(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_MAX_CXNS]),
                    MinPoolSize       = Convert.ToInt32(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_MIN_CXNS]),
                    PoolExpansionSize = Convert.ToInt32(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_EXPAND_SIZE]),
                    WaitTime          = TimeSpan.Parse(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_WAIT_TIME]),
                    Timeout           = TimeSpan.Parse(_mySession.MdwsConfiguration.AllConfigs[conf.MdwsConfigConstants.CONNECTION_POOL_CONFIG_SECTION][conf.MdwsConfigConstants.CONNECTION_POOL_CXN_TIMEOUT]),
                    CxnSource         = source,
                    Credentials       = creds
                };
                newSource.CxnSource.Protocol = "PVISTA";
                poolsSource.CxnSources.Add(source.SiteId.Id, newSource);
            }

            ConnectionPools pools = (ConnectionPools)AbstractResourcePoolFactory.getResourcePool(poolsSource);
        }
예제 #6
0
        public static AbstractCredentials getVisitCredentials(MockApp theApp)
        {
            // Everything but the security phrase.
            AbstractCredentials result = new VistaCredentials();

            result.AuthenticationSource        = new DataSource();
            result.AuthenticationSource.SiteId = new SiteId(theApp.User.LogonSiteId.Id, theApp.User.LogonSiteId.Name);
            result.LocalUid     = theApp.User.Uid;
            result.FederatedUid = theApp.User.SSN.toString();
            result.SubjectName  = theApp.User.Name.getLastNameFirst();
            result.SubjectPhone = theApp.User.Phone;
            return(result);
        }
예제 #7
0
        internal AbstractCredentials getDownstreamCredentialsFromConfig(User user)
        {
            AbstractCredentials result = new VistaCredentials();

            result.AuthenticationSource        = new DataSource(); // BSE
            result.AuthenticationSource.SiteId = new SiteId(user.LogonSiteId.Id, user.LogonSiteId.Name);
            result.AuthenticationToken         = user.LogonSiteId.Id + "_" + user.Uid;
            result.LocalUid       = user.Uid;
            result.FederatedUid   = user.SSN.toString();
            result.SubjectName    = user.Name.getLastNameFirst();
            result.SubjectPhone   = user.Phone;
            result.SecurityPhrase = VistaConstants.MY_SECURITY_PHRASE;
            return(result);
        }
예제 #8
0
        void login(AbstractConnection cxn)
        {
            AbstractPermission permission = new MenuOption(VistaConstants.CPRS_CONTEXT);

            permission.IsPrimary             = true;
            cxn.Account.AuthenticationMethod = VistaConstants.LOGIN_CREDENTIALS;
            AbstractCredentials creds = new VistaCredentials();

            //creds.AccountName = "1programmer";
            //creds.AccountPassword = "******";
            creds.AccountName     = "CLERKWARD01";
            creds.AccountPassword = "******";
            cxn.Account.authenticateAndAuthorize(creds, permission);
        }
예제 #9
0
        // This constructor is needed for API level tests.
        public MockConnection(string siteId, string protocol, bool updateRpc = false) : base(null)
        {
            this.DataSource          = new DataSource();
            this.DataSource.SiteId   = new SiteId(siteId, "Mock");
            this.DataSource.Protocol = protocol;


            _sqliteCxn = new XSqliteConnection(this.DataSource);

            this.Account = new MockAccount(this);
            //this.Account.IsAuthenticated = true;
            this.updateRpc = updateRpc;

            AbstractCredentials credentials = new VistaCredentials();

            credentials.AccountName     = "AccessCode";
            credentials.AccountPassword = "******";
            AbstractPermission permission = new MenuOption(VistaConstants.MDWS_CONTEXT);

            permission.IsPrimary = true;
            this.Account.Permissions.Add(permission.Name, permission);
        }
예제 #10
0
        /// <summary>
        /// Visit multiple data sources without a login.
        /// </summary>
        /// <remarks>
        /// Requires no previous login.  Used by daemon apps to visit multiple sources.  Sources may be
        /// VAMCs, VISNs, some combination of VAMCs and VISNs, or the entire VHA.  See the
        /// sourceList parameter.
        /// </remarks>
        /// <param name="pwd">Client app's BSE security phrase</param>
        /// <param name="sourceList">
        /// A comma-delimited list of station numbers and/or VISN IDs, as in
        /// "402,550" or "V12,V22" or "V1,V2,456".  To visit all VistA systems set the param
        /// to "*".  Duplicate station #'s are ignored.
        /// </param>
        /// <param name="permissionStr">If blank defaults to CPRS context</param>
        /// <returns>TaggedTextArray: each site with user DUZ or an error message</returns>
        public TaggedTextArray visitSites(string pwd, string sourceList, string userSitecode, string userName, string DUZ, string SSN, string permissionStr)
        {
            TaggedTextArray result = new TaggedTextArray();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (String.IsNullOrEmpty(sourceList))
            {
                result.fault = new FaultTO("Missing sitelist");
            }
            else if (String.IsNullOrEmpty(userSitecode))
            {
                result.fault = new FaultTO("Missing userSitecode");
            }
            else if (String.IsNullOrEmpty(userName))
            {
                result.fault = new FaultTO("Missing userName");
            }
            else if (String.IsNullOrEmpty(DUZ))
            {
                result.fault = new FaultTO("Missing DUZ");
            }
            else if (String.IsNullOrEmpty(SSN))
            {
                result.fault = new FaultTO("Missing SSN");
            }
            if (result.fault != null)
            {
                return(result);
            }

            if (String.IsNullOrEmpty(permissionStr))
            {
                permissionStr = mySession.DefaultPermissionString;
            }

            try
            {
                // Build the credentials
                Site       site = mySession.SiteTable.getSite(userSitecode);
                DataSource src  = site.getDataSourceByModality("HIS");

                AbstractCredentials creds = new VistaCredentials();
                creds.AuthenticationSource = src;
                creds.AuthenticationToken  = userSitecode + '_' + DUZ;
                creds.FederatedUid         = SSN;
                creds.LocalUid             = DUZ;
                creds.SecurityPhrase       = pwd;
                creds.SubjectName          = userName;
                creds.SubjectPhone         = "";

                User user = new User();
                user.UserName = userName;
                user.Uid      = DUZ;
                user.SSN      = new SocSecNum(SSN);

                mySession.PrimaryPermission = new MenuOption(permissionStr);

                // Make next call think there's been a login
                mySession.Credentials = creds;
                mySession.User        = user;

                // visitSites
                return(visitSites(pwd, sourceList, permissionStr));
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e);
            }

            return(result);
        }
예제 #11
0
        /// <summary>
        /// Visit multiple data sources without a login.
        /// </summary>
        /// <remarks>
        /// Requires no previous login.  Used by daemon apps to visit multiple sources.  Sources may be
        /// VAMCs, VISNs, some combination of VAMCs and VISNs, or the entire VHA.  See the
        /// sourceList parameter.
        /// </remarks>
        /// <param name="pwd">Client app's BSE security phrase</param>
        /// <param name="sourceList">
        /// A comma-delimited list of station numbers and/or VISN IDs, as in
        /// "402,550" or "V12,V22" or "V1,V2,456".  To visit all VistA systems set the param
        /// to "*".  Duplicate station #'s are ignored.
        /// </param>
        /// <param name="permissionStr">If blank defaults to CPRS context</param>
        /// <returns>TaggedTextArray: each site with user DUZ or an error message</returns>
        public TaggedTextArray visitSites(string pwd, string sourceList, string userSitecode, string userName, string DUZ, string permissionStr)
        {
            TaggedTextArray result = new TaggedTextArray();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (String.IsNullOrEmpty(sourceList))
            {
                result.fault = new FaultTO("Missing sitelist");
            }
            else if (String.IsNullOrEmpty(userSitecode))
            {
                result.fault = new FaultTO("Missing userSitecode");
            }
            else if (String.IsNullOrEmpty(userName))
            {
                result.fault = new FaultTO("Missing userName");
            }
            else if (String.IsNullOrEmpty(DUZ))
            {
                result.fault = new FaultTO("Missing DUZ");
            }
            if (result.fault != null)
            {
                return(result);
            }

            if (String.IsNullOrEmpty(permissionStr))
            {
                permissionStr = mySession.DefaultPermissionString;
            }

            try
            {
                // Do an admin visit to get user's SSN
                User theUser = getVisitorData(userSitecode, DUZ, pwd);

                // Build the credentials
                Site       site = mySession.SiteTable.getSite(userSitecode);
                DataSource src  = site.getDataSourceByModality("HIS");

                AbstractCredentials creds = new VistaCredentials();
                creds.AuthenticationSource = src;
                creds.AuthenticationToken  = userSitecode + '_' + theUser.Uid;
                creds.FederatedUid         = theUser.SSN.toString();
                creds.LocalUid             = theUser.Uid;
                creds.SecurityPhrase       = pwd;
                creds.SubjectName          = theUser.Name.getLastNameFirst();
                creds.SubjectPhone         = theUser.Phone;

                mySession.PrimaryPermission = new MenuOption(permissionStr);

                // Make next call think there's been a login
                mySession.Credentials = creds;

                // visitSites
                return(visitSites(pwd, sourceList, permissionStr));
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e);
            }

            return(result);
        }