Пример #1
0
        internal void setContext(AbstractPermission permission)
        {
            if (permission == null || string.IsNullOrEmpty(permission.Name))
            {
                throw new ArgumentNullException("permission");
            }

            MdoQuery request  = buildSetContextRequest(permission.Name);
            string   response = "";

            try
            {
                response = (string)Cxn.query(request);
            }
            catch (MdoException e)
            {
                response = e.Message;
            }
            if (response != "1")
            {
                throw getException(response);
            }
            if (!Cxn.Account.Permissions.ContainsKey(permission.Name))
            {
                Cxn.Account.Permissions.Add(permission.Name, permission);
            }
            isAuthorized = isAuthorized || permission.IsPrimary;
        }
Пример #2
0
        internal string login(AbstractCredentials credentials)
        {
            if (String.IsNullOrEmpty(credentials.AccountName))
            {
                throw new MdoException(MdoExceptionCode.ARGUMENT_NULL, "Missing Access Code");
            }
            if (String.IsNullOrEmpty(credentials.AccountPassword))
            {
                throw new MdoException(MdoExceptionCode.ARGUMENT_NULL, "Missing Verify Code");
            }

            VistaQuery vq  = new VistaQuery("XUS SIGNON SETUP");
            string     rtn = (string)Cxn.query(vq);

            if (rtn == null)
            {
                throw new UnexpectedDataException("Unable to setup authentication");
            }

            vq = new VistaQuery("XUS AV CODE");

            // This is here so we can test with MockConnection
            if (Cxn.GetType().Name != "MockConnection")
            {
                vq.addEncryptedParameter(vq.LITERAL, credentials.AccountName + ';' + credentials.AccountPassword);
            }
            else
            {
                vq.addParameter(vq.LITERAL, credentials.AccountName + ';' + credentials.AccountPassword);
            }
            rtn = (string)Cxn.query(vq);

            //TODO - need to catch renew verify id error

            string[] flds = StringUtils.split(rtn, StringUtils.CRLF);
            if (flds[0] == "0")
            {
                throw new UnauthorizedAccessException(flds[3]);
            }
            AccountId = flds[0];

            // Set the connection's UID
            Cxn.Uid = AccountId;

            // Save the credentials
            credentials.LocalUid             = AccountId;
            credentials.AuthenticationSource = Cxn.DataSource;
            credentials.AuthenticationToken  = Cxn.DataSource.SiteId.Id + '_' + AccountId;

            IsAuthenticated = true;
            Cxn.IsRemote    = false;

            // Set the greeting if there is one
            if (flds.Length > 7)
            {
                return(flds[7]);
            }
            return("OK");
        }
Пример #3
0
        internal MdoQuery buildSetContextRequest(string context)
        {
            VistaQuery vq = new VistaQuery("XWB CREATE CONTEXT");

            if (Cxn.GetType().Name != "MockConnection")
            {
                vq.addEncryptedParameter(vq.LITERAL, context);
            }
            else
            {
                vq.addParameter(vq.LITERAL, context);
            }
            return(vq);
        }
Пример #4
0
        public string getAuthenticationTokenFromVista()
        {
            VistaQuery vq = new VistaQuery("XUS SET VISITOR");

            return((string)Cxn.query(vq));
        }