Example #1
0
        public IndexedHashtable connect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource)
        {
            permission.IsPrimary = true;
            QueryTemplate qt = new ConnectQuery(this);

            if (validationDataSource == null)
            {
                validationDataSource = new DataSource();
            }
            qt.QueryMethod("AbstractConnection", "authorizedConnect", new object[] { credentials, permission, validationDataSource });
            IndexedHashtable t = buildResults();

            // KLUGE:  This is here to make the number of connections come out right.
            // Note that the first element in the table will be a connection, but
            // the rest either User or Exception.
            if (HasBaseConnection && myResults.Count < myCxns.Count)
            {
                IndexedHashtable t2 = new IndexedHashtable(myCxns.Count);
                t2.Add(BaseConnection.DataSource.SiteId.Id, BaseConnection);
                for (int i = 0; i < t.Count; i++)
                {
                    t2.Add(t.GetKey(i), t.GetValue(i));
                }
                t = t2;
            }
            return(t);
        }
Example #2
0
 public UserSecurityKeyTO(AbstractPermission p)
 {
     if (p.Type != PermissionType.SecurityKey)
     {
         fault = new FaultTO(p.Name + " is not a Security Key");
         return;
     }
     this.id = p.PermissionId;
     this.name = p.Name;
 }
Example #3
0
        public override object query(MdoQuery query, AbstractPermission permission = null)
        {
            // hardcoded datetime request
            if (String.Equals(query.RpcName, "ORWU DT") && String.Equals(((VistaQuery.Parameter)query.Parameters[0]).Value, "NOW"))
            {
                return("3010101.120101");
            }

            if (!IsConnected)
            {
                throw new NotConnectedException();
            }

            string reply = (string)_sqliteCxn.query(query, permission);

            if (reply.Contains("M  ERROR"))
            {
                throw new MdoException(MdoExceptionCode.VISTA_FAULT, reply);
            }
            return(reply);
        }
Example #4
0
 public override object query(SqlQuery request, Delegate functionToInvoke, AbstractPermission permission = null)
 {
     throw new NotImplementedException();
 }
Example #5
0
        public override object query(MdoQuery query, AbstractPermission permission = null)
        {
            // hardcoded datetime request
            if (String.Equals(query.RpcName, "ORWU DT") && String.Equals(((VistaQuery.Parameter)query.Parameters[0]).Value, "NOW"))
            {
                return "3010101.120101";
            }

            if (!IsConnected)
            {
                throw new NotConnectedException();
            }

            string reply = (string)_sqliteCxn.query(query, permission);

            if (reply.Contains("M  ERROR"))
            {
                throw new MdoException(MdoExceptionCode.VISTA_FAULT, reply);
            }
            return reply;
        }
Example #6
0
 public override object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource)
 {
     throw new NotImplementedException();
 }
 public override object query(MdoQuery request, AbstractPermission permission = null)
 {
     throw new NotImplementedException();
 }
 public abstract User authenticateAndAuthorize(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource = null);
Example #9
0
        // This is the core visit method the others are using. The permission must have been set before
        // getting here.
        internal User doTheVisit(string sitecode, AbstractCredentials credentials, AbstractPermission permission)
        {
            Site site = mySession.SiteTable.getSite(sitecode);
            DataSource src = site.getDataSourceByModality("HIS");
            if (src == null)
            {
                throw new Exception("No HIS data source at site " + sitecode);
            }

            AbstractDaoFactory factory = AbstractDaoFactory.getDaoFactory(AbstractDaoFactory.getConstant(src.Protocol));
            myCxn = factory.getConnection(src);
            myCxn.Account.AuthenticationMethod = mySession.DefaultVisitMethod;

            if (!MdwsUtils.isValidCredentials(myCxn.Account.AuthenticationMethod, credentials, permission))
            {
                throw new Exception("Invalid credentials");
            }

            object result = null;
            if (myCxn.Account.AuthenticationMethod == VistaConstants.BSE_CREDENTIALS_V2WEB)
            {
                result = myCxn.authorizedConnect(credentials, permission,
                    new DataSource() { ConnectionString = mySession.MdwsConfiguration.BseValidatorConnectionString });
            }
            else
            {
                result = myCxn.authorizedConnect(credentials, permission, null);
            }
            if (result.GetType().Name.EndsWith("Exception"))
            {
                throw (Exception)result;
            }
            else
            {
                return (User)result;
            }
        }
Example #10
0
 public abstract object query(string request, AbstractPermission permission   = null);
Example #11
0
 public abstract object query(SqlQuery request, Delegate functionToInvoke, AbstractPermission permission = null);
Example #12
0
 public abstract object query(string request, AbstractPermission permission = null);
Example #13
0
 public abstract object query(MdoQuery request, AbstractPermission permission = null);
Example #14
0
 //public abstract object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission);
 public abstract object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource);
Example #15
0
 public void removePermission(AbstractConnection cxn, string uid, AbstractPermission permission)
 {
     ((IUserDao)cxn.getDao(DAO_NAME)).removePermission(uid, permission);
 }
Example #16
0
 public bool hasPermission(AbstractConnection cxn, string userId, AbstractPermission permission)
 {
     return ((IUserDao)cxn.getDao(DAO_NAME)).hasPermission(userId, permission);
 }
Example #17
0
 public abstract object query(MdoQuery request, AbstractPermission permission = null);
Example #18
0
 public static bool hasPermission(AbstractConnection cxn, string userId, AbstractPermission permission)
 {
     return getDao(cxn).hasPermission(userId, permission);
 }
Example #19
0
 public abstract object query(SqlQuery request, Delegate functionToInvoke, AbstractPermission permission = null);
Example #20
0
 public static bool isValidCredentials(string authenticationMethod, AbstractCredentials credentials, AbstractPermission permission)
 {
     if (credentials == null)
     {
         return false;
     }
     if (authenticationMethod == MdwsConstants.LOGIN_CREDENTIALS)
     {
         if (String.IsNullOrEmpty(credentials.AccountName) ||
             String.IsNullOrEmpty(credentials.AccountPassword))
         {
             return false;
         }
     }
     else if (authenticationMethod == MdwsConstants.NON_BSE_CREDENTIALS)
     {
         if (String.IsNullOrEmpty(credentials.LocalUid) ||
             String.IsNullOrEmpty(credentials.FederatedUid) ||
             String.IsNullOrEmpty(credentials.SubjectName) ||
             credentials.AuthenticationSource == null ||
             credentials.AuthenticationSource.SiteId == null ||
             String.IsNullOrEmpty(credentials.AuthenticationSource.SiteId.Id) ||
             String.IsNullOrEmpty(credentials.AuthenticationSource.SiteId.Name) ||
             String.IsNullOrEmpty(credentials.AuthenticationToken))
         {
             return false;
         }
     }
     else if (authenticationMethod == MdwsConstants.BSE_CREDENTIALS_V2WEB)
     {
         if (String.IsNullOrEmpty(credentials.LocalUid) ||
             String.IsNullOrEmpty(credentials.FederatedUid) ||
             String.IsNullOrEmpty(credentials.SubjectName) ||
             credentials.AuthenticationSource == null ||
             credentials.AuthenticationSource.SiteId == null ||
             String.IsNullOrEmpty(credentials.AuthenticationSource.SiteId.Id) ||
             String.IsNullOrEmpty(credentials.AuthenticationSource.SiteId.Name) ||
             String.IsNullOrEmpty(credentials.AuthenticationToken) ||
             String.IsNullOrEmpty(credentials.SecurityPhrase))
         {
             return false;
         }
     }
     else
     {
         throw new ArgumentException("Invalid credential type");
     }
     if (permission == null || String.IsNullOrEmpty(permission.Name))
     {
         return false;
     }
     return true;
 }
 public abstract User authorize(AbstractCredentials credentials, AbstractPermission permission);
Example #22
0
 public abstract User authenticateAndAuthorize(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource = null);
Example #23
0
 public abstract User authorize(AbstractCredentials credentials, AbstractPermission permission);
Example #24
0
        //public override object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission)
        //{
        //    IsConnected = true;
        //    return null;
        //}

        public override object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource)
        {
            IsConnected = true;
            return(null);
        }
Example #25
0
 public override object query(string request, AbstractPermission permission = null)
 {
     throw new NotImplementedException("Must use the DAO directly");
 }
Example #26
0
 public override object query(string request, AbstractPermission permission = null)
 {
     throw new MethodAccessException("This query method was not expected");
 }
Example #27
0
        public IndexedHashtable connect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource)
        {
            permission.IsPrimary = true;
            QueryTemplate qt = new ConnectQuery(this);
            if (validationDataSource == null)
            {
                validationDataSource = new DataSource();
            }
            qt.QueryMethod("AbstractConnection", "authorizedConnect", new object[] { credentials, permission, validationDataSource });
            IndexedHashtable t = buildResults();

            // KLUGE:  This is here to make the number of connections come out right.
            // Note that the first element in the table will be a connection, but
            // the rest either User or Exception.
            if (HasBaseConnection && myResults.Count < myCxns.Count)
            {
                IndexedHashtable t2 = new IndexedHashtable(myCxns.Count);
                t2.Add(BaseConnection.DataSource.SiteId.Id, BaseConnection);
                for (int i = 0; i < t.Count; i++)
                {
                    t2.Add(t.GetKey(i), t.GetValue(i));
                }
                t = t2;
            }
            return t;
        }
Example #28
0
 public override object query(SqlQuery request, Delegate functionToInvoke, AbstractPermission permission = null)
 {
     throw new NotImplementedException();
 }
Example #29
0
 //internal void updateSqlite(MdoQuery oldRequest, string newRequest, string reply)
 //{
 //    sqlite.SqliteDao sqliteDao = new sqlite.SqliteDao();
 //    string hashedOldQueryString = StringUtils.getMD5Hash(oldRequest.buildMessage());
 //    string hashedNewQueryString = StringUtils.getMD5Hash(newRequest);
 //    try
 //    {
 //        sqliteDao.getObject(this.xmlSource.siteId, hashedOldQueryString); // should throw exception on failure
 //        sqliteDao.updateObject(this.xmlSource.siteId, hashedOldQueryString, newRequest, hashedNewQueryString, reply);
 //    }
 //    catch (Exception)
 //    {
 //        // swallow
 //    }
 //}
 //internal void saveToSqlite(MdoQuery request, string reply)
 //{
 //    sqlite.SqliteDao sqliteDao = new sqlite.SqliteDao();
 //    string queryString = request.buildMessage();
 //    string hashedQueryString = StringUtils.getMD5Hash(queryString);
 //    try
 //    {
 //        object savedObj = sqliteDao.getObject(this.xmlSource.siteId, hashedQueryString);
 //        if (savedObj as string == reply)
 //        {
 //            return;
 //        }
 //        else
 //        {
 //            sqliteDao.updateObject(this.xmlSource.siteId, hashedQueryString, reply);
 //        }
 //    }
 //    catch (Exception)
 //    {
 //        try
 //        {
 //            if (!sqliteDao.hasTable(this.xmlSource.siteId))
 //            {
 //                sqliteDao.createTableForSite(this.xmlSource.siteId);
 //            }
 //            sqliteDao.saveObject(this.xmlSource.siteId, queryString, reply);
 //        }
 //        catch (Exception exc)
 //        {
 //            throw new Exception("There was a problem saving the XML data to Sqlite: " + exc.Message);
 //        }
 //    }
 //}
 public override object query(string request, AbstractPermission permission = null)
 {
     throw new MethodAccessException("This query method was not expected");
 }
Example #30
0
 //public abstract object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission);
 public abstract object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource);
Example #31
0
 public override object authorizedConnect(AbstractCredentials credentials, AbstractPermission permission, DataSource validationDataSource)
 {
     IsConnected = true;
     return null;
 }
Example #32
0
 public AbstractPermission addPermission(AbstractConnection cxn, string uid, AbstractPermission permission)
 {
     return ((IUserDao)cxn.getDao(DAO_NAME)).addPermission(uid, permission);
 }