Exemplo n.º 1
0
 internal TypeInfoDataBaseManager(IEnumerable<string> formatFiles, bool isShared, AuthorizationManager authorizationManager, PSHost host)
 {
     this.databaseLock = new object();
     this.updateDatabaseLock = new object();
     this.formatFileList = new List<string>();
     Collection<PSSnapInTypeAndFormatErrors> files = new Collection<PSSnapInTypeAndFormatErrors>();
     Collection<string> loadErrors = new Collection<string>();
     foreach (string str in formatFiles)
     {
         if (string.IsNullOrEmpty(str) || !Path.IsPathRooted(str))
         {
             throw PSTraceSource.NewArgumentException("formatFiles", "FormatAndOutXmlLoadingStrings", "FormatFileNotRooted", new object[] { str });
         }
         PSSnapInTypeAndFormatErrors item = new PSSnapInTypeAndFormatErrors(string.Empty, str) {
             Errors = loadErrors
         };
         files.Add(item);
         this.formatFileList.Add(str);
     }
     MshExpressionFactory expressionFactory = new MshExpressionFactory();
     List<XmlLoaderLoggerEntry> logEntries = null;
     this.LoadFromFile(files, expressionFactory, true, authorizationManager, host, false, out logEntries);
     this.isShared = isShared;
     if (loadErrors.Count > 0)
     {
         throw new FormatTableLoadException(loadErrors);
     }
 }
Exemplo n.º 2
0
 internal FormatTable(IEnumerable<string> formatFiles, AuthorizationManager authorizationManager, PSHost host)
 {
     if (formatFiles == null)
     {
         throw PSTraceSource.NewArgumentNullException("formatFiles");
     }
     this.formatDBMgr = new TypeInfoDataBaseManager(formatFiles, true, authorizationManager, host);
 }
 public LogoutAndExit(
     IContainer container,
     AuthorizationManager authorizationManager,
     IBusyIndicator busyIndicator, 
     DataContext dataContext)
 {
     _container = container;
     _authorizationManager = authorizationManager;
     _busyIndicator = busyIndicator;
     _dataContext = dataContext;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="formatFiles"></param>
        /// <param name="isShared"></param>
        /// <param name="authorizationManager">
        /// Authorization manager to perform signature checks before reading ps1xml files (or null of no checks are needed)
        /// </param>
        /// <param name="host">
        /// Host passed to <paramref name="authorizationManager"/>.  Can be null if no interactive questions should be asked.
        /// </param>
        /// <exception cref="ArgumentNullException" />
        /// <exception cref="ArgumentException">
        /// 1. FormatFile is not rooted.
        /// </exception>
        /// <exception cref="FormatTableLoadException">
        /// 1. There were errors loading Formattable. Look in the Errors property to get
        /// detailed error messages.
        /// </exception>
        internal TypeInfoDataBaseManager(
            IEnumerable<string> formatFiles,
            bool isShared,
            AuthorizationManager authorizationManager,
            PSHost host)
        {
            _formatFileList = new List<string>();

            Collection<PSSnapInTypeAndFormatErrors> filesToLoad = new Collection<PSSnapInTypeAndFormatErrors>();
            ConcurrentBag<string> errors = new ConcurrentBag<string>();
            foreach (string formatFile in formatFiles)
            {
                if (string.IsNullOrEmpty(formatFile) || (!Path.IsPathRooted(formatFile)))
                {
                    throw PSTraceSource.NewArgumentException("formatFiles", FormatAndOutXmlLoadingStrings.FormatFileNotRooted, formatFile);
                }

                PSSnapInTypeAndFormatErrors fileToLoad = new PSSnapInTypeAndFormatErrors(string.Empty, formatFile);
                fileToLoad.Errors = errors;
                filesToLoad.Add(fileToLoad);
                _formatFileList.Add(formatFile);
            }

            MshExpressionFactory expressionFactory = new MshExpressionFactory();
            List<XmlLoaderLoggerEntry> logEntries = null;

            // load the files
            LoadFromFile(filesToLoad, expressionFactory, true, authorizationManager, host, false, out logEntries);
            this.isShared = isShared;

            // check to see if there are any errors loading the format files
            if (errors.Count > 0)
            {
                throw new FormatTableLoadException(errors);
            }
        }
Exemplo n.º 5
0
 internal bool LoadFromFile(Collection<PSSnapInTypeAndFormatErrors> files, MshExpressionFactory expressionFactory, bool acceptLoadingErrors, AuthorizationManager authorizationManager, PSHost host, bool preValidated, out List<XmlLoaderLoggerEntry> logEntries)
 {
     bool flag;
     try
     {
         TypeInfoDataBase base2 = null;
         lock (this.updateDatabaseLock)
         {
             base2 = LoadFromFileHelper(files, expressionFactory, authorizationManager, host, preValidated, out logEntries, out flag);
         }
         lock (this.databaseLock)
         {
             if (acceptLoadingErrors || flag)
             {
                 this.dataBase = base2;
             }
             return flag;
         }
     }
     finally
     {
         lock (this.databaseLock)
         {
             if (this.dataBase == null)
             {
                 TypeInfoDataBase db = new TypeInfoDataBase();
                 AddPreLoadInstrinsics(db);
                 AddPostLoadInstrinsics(db);
                 this.dataBase = db;
             }
         }
     }
     return flag;
 }
Exemplo n.º 6
0
 protected bool IsUpdate(ZOperationResult operationResult)
 {
     return(AuthorizationManager.IsUpdate(ActivityOperations, operationResult));
 }
        public async Task <List <Overdraft> > AuthorizationAsync(AuthorizationParams authorizationParams)
        {
            var authorizationManager = new AuthorizationManager();

            return(await authorizationManager.AuthorizationAsync(authorizationParams));
        }
Exemplo n.º 8
0
 public bool HasWriteAccess()
 {
     return(AuthorizationManager.IsAllowed(ContextItem, AccessRight.ItemWrite, Sitecore.Context.User));
 }
Exemplo n.º 9
0
 private void checkIsAuthorizedToReadHistoryOfDecisionDefinitions()
 {
     AuthorizationManager.checkAuthorization(READ_HISTORY, DECISION_DEFINITION);
 }
Exemplo n.º 10
0
        /// <summary>
        /// It loads a database from file(s).
        /// </summary>
        /// <param name="files">*.formal.xml files to be loaded.</param>
        /// <param name="expressionFactory">Expression factory to validate script blocks.</param>
        /// <param name="authorizationManager">
        /// Authorization manager to perform signature checks before reading ps1xml files (or null of no checks are needed)
        /// </param>
        /// <param name="host">
        /// Host passed to <paramref name="authorizationManager"/>.  Can be null if no interactive questions should be asked.
        /// </param>
        /// <param name="preValidated">
        /// True if the format data has been pre-validated (build time, manual testing, etc) so that validation can be
        /// skipped at runtime.
        /// </param>
        /// <param name="logEntries">List of logger entries (errors, etc.) to return to the caller.</param>
        /// <param name="success">True if no error occurred.</param>
        /// <returns>A database instance loaded from file(s).</returns>
        private static TypeInfoDataBase LoadFromFileHelper(
            Collection <PSSnapInTypeAndFormatErrors> files,
            PSPropertyExpressionFactory expressionFactory,
            AuthorizationManager authorizationManager,
            PSHost host,
            bool preValidated,
            out List <XmlLoaderLoggerEntry> logEntries,
            out bool success)
        {
            success = true;
            // Holds the aggregated log entries for all files...
            logEntries = new List <XmlLoaderLoggerEntry>();

            // fresh instance of the database
            TypeInfoDataBase db = new TypeInfoDataBase();

            // prepopulate the database with any necessary overriding data
            AddPreLoadIntrinsics(db);

            var etwEnabled = RunspaceEventSource.Log.IsEnabled();

            // load the XML document into a copy of the
            // in memory database
            foreach (PSSnapInTypeAndFormatErrors file in files)
            {
                // Loads formatting data from ExtendedTypeDefinition instance
                if (file.FormatData != null)
                {
                    LoadFormatDataHelper(file.FormatData, expressionFactory, logEntries, ref success, file, db, isBuiltInFormatData: false, isForHelp: false);
                    continue;
                }

                if (etwEnabled)
                {
                    RunspaceEventSource.Log.ProcessFormatFileStart(file.FullPath);
                }

                if (!ProcessBuiltin(file, db, expressionFactory, logEntries, ref success))
                {
                    // Loads formatting data from formatting data XML file
                    XmlFileLoadInfo info =
                        new XmlFileLoadInfo(Path.GetPathRoot(file.FullPath), file.FullPath, file.Errors, file.PSSnapinName);
                    using (TypeInfoDataBaseLoader loader = new TypeInfoDataBaseLoader())
                    {
                        if (!loader.LoadXmlFile(info, db, expressionFactory, authorizationManager, host, preValidated))
                        {
                            success = false;
                        }

                        foreach (XmlLoaderLoggerEntry entry in loader.LogEntries)
                        {
                            // filter in only errors from the current file...
                            if (entry.entryType == XmlLoaderLoggerEntry.EntryType.Error)
                            {
                                string mshsnapinMessage = StringUtil.Format(FormatAndOutXmlLoadingStrings.MshSnapinQualifiedError, info.psSnapinName, entry.message);
                                info.errors.Add(mshsnapinMessage);
                                if (entry.failToLoadFile)
                                {
                                    file.FailToLoadFile = true;
                                }
                            }
                        }
                        // now aggregate the entries...
                        logEntries.AddRange(loader.LogEntries);
                    }
                }

                if (etwEnabled)
                {
                    RunspaceEventSource.Log.ProcessFormatFileStop(file.FullPath);
                }
            }

            // add any sensible defaults to the database
            AddPostLoadIntrinsics(db);

            return(db);
        }
Exemplo n.º 11
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //Clearing the error label
        lblError.Text   = string.Empty;
        lblMessage.Text = string.Empty;

        btnAddRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");

        btnSave.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return SaveButtonClickValidate();");


        txtCountryName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtCountryName.ClientID + "','" + imgCountryName.ClientID + "','" + Common.CommonConstants.VALIDATE_ISALPHABET + "');");
        imgCountryName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanCountryName.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');");
        imgCountryName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanCountryName.ClientID + "');");

        txtVisaType.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtVisaType.ClientID + "','" + imgVisaType.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPACE + "');");
        imgVisaType.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanVisaType.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');");
        imgVisaType.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanVisaType.ClientID + "');");

        ucDatePickerExpiryDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + ucDatePickerExpiryDate.ClientID + "','','');");
        ucDatePickerExpiryDate.Attributes.Add(ReadOnly, ReadOnly);
        ucDatePickerVisaExpiryDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + ucDatePickerVisaExpiryDate.ClientID + "','','');");
        ucDatePickerVisaExpiryDate.Attributes.Add(ReadOnly, ReadOnly);
        ucDatePickerIssueDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + ucDatePickerIssueDate.ClientID + "','','');");
        ucDatePickerIssueDate.Attributes.Add(ReadOnly, ReadOnly);

        txtPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtPassportNo.ClientID + "','" + imgPassportNo.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHA_NUMERIC_FUNCTION + "');");

        //CR - 28321 -  Passport Application Number Sachin  - Start
        txtPassportAppNo.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtPassportNo.ClientID + "','" + imgPassportNo.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHA_NUMERIC_FUNCTION + "');");
        //CR - 28321 -  Passport Application Number Sachin  - End

        //txtPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return Max_Length1();");
        //imgPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanPassportNo.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');");
        //imgPassportNo.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanPassportNo.ClientID + "');");

        txtIssuePlace.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtIssuePlace.ClientID + "','" + imgIssuePlace.ClientID + "','" + Common.CommonConstants.VALIDATE_ISALPHABET + "');");
        imgIssuePlace.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanIssuePlace.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');");
        imgIssuePlace.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanIssuePlace.ClientID + "');");

        if (!ValidateURL())
        {
            Response.Redirect(CommonConstants.INVALIDURL, false);
        }
        if (Session[Common.SessionNames.EMPLOYEEDETAILS] != null)
        {
            employee = (BusinessEntities.Employee)Session[Common.SessionNames.EMPLOYEEDETAILS];
        }

        if (employee != null)
        {
            employeeID      = employee.EMPId;
            lblempName.Text = employee.FirstName.ToUpper() + " " + employee.LastName.ToUpper();
        }

        if (!IsPostBack)
        {
            Session[SessionNames.PAGEMODE] = Common.MasterEnum.PageModeEnum.View;
            this.PopulateControl();
            this.PopulateGrid(employeeID);
        }

        if (gvVisaDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE)
        {
            VisaDetailsCollection.Clear();
            ShowHeaderWhenEmptyGrid();
        }

        // Get logged-in user's email id
        AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager();

        UserRaveDomainId = objRaveHRAuthorizationManager.getLoggedInUser();
        UserMailId       = UserRaveDomainId.Replace("co.in", "com");

        arrRolesForUser = RaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser());

        if (UserMailId.ToLower() == employee.EmailId.ToLower() || arrRolesForUser.Contains(AuthorizationManagerConstants.ROLEHR))
        {
            if (Session[SessionNames.PAGEMODE] != null)
            {
                PageMode = Session[SessionNames.PAGEMODE].ToString();

                if (PageMode == Common.MasterEnum.PageModeEnum.View.ToString() && IsPostBack == false)
                {
                    if (!string.IsNullOrEmpty(txtPassportNo.Text))
                    {
                        passportdetails.Enabled   = false;
                        visaDetails.Enabled       = false;
                        rbtnValidPassport.Enabled = false;
                        lblValidPassport.Enabled  = false;
                        btnEdit.Visible           = true;
                        btnSave.Visible           = false;
                    }
                    else
                    {
                        passportdetails.Enabled   = true;
                        visaDetails.Enabled       = true;
                        rbtnValidPassport.Enabled = true;
                        lblValidPassport.Enabled  = true;
                        btnEdit.Visible           = false;
                        btnSave.Visible           = true;
                    }
                }
            }
        }
        else
        {
            passportdetails.Enabled   = false;
            btnEdit.Visible           = false;
            btnCancel.Visible         = false;
            btnAddRow.Visible         = false;
            visaDetails.Enabled       = false;
            btnSave.Visible           = false;
            rbtnValidPassport.Enabled = false;
            lblValidPassport.Enabled  = false;
        }

        SavedControlVirtualPath = "~/EmployeeMenuUC.ascx";
        ReloadControl();
    }
Exemplo n.º 12
0
        /// <summary>
        /// Creates the user in the system and returns the system generated username
        /// </summary>
        /// <param name="useModelUserName">If true then try to use <see cref="UserModel"/> instance Username if it exists.  Otherwise fall back to building a user name. </param>
        public string CreateUser(UserModel userModel, string storeName, string password, bool active, bool useModelUserName)
        {
            var authorizationManager = new AuthorizationManager(storeName);

            string username = CreateUniqueUserName(userModel.FirstName, userModel.MiddleInitial, userModel.LastName);

            username = (useModelUserName && !string.IsNullOrWhiteSpace(userModel.Username)) ? userModel.Username : username;

            //register the user
            //try to get the dbuser, and if they arlready exists, just create the account, otherwise create the user and account.
            if (!authorizationManager.InAuthorizationSystem(username))
            {
                WebSecurity.CreateUserAndAccount(username,
                                                 password,

                                                 new
                {
                    FirstName            = userModel.FirstName,
                    MiddleName           = userModel.MiddleInitial,
                    LastName             = userModel.LastName,
                    Phone                = userModel.PhoneNumber,
                    Email                = userModel.EmailAddress,
                    CreatedDate          = DateTime.Now,
                    RequirePasswordReset = true
                });
            }
            else
            {
                //only create them if they dont already exist
                if (!WebSecurity.UserExists(username))
                {
                    //create them
                    WebSecurity.CreateAccount(username, password);
                }
            }

            //update their profile
            //set the models username now that we have it
            userModel.Username = username;

            UpdateUserProfile(userModel, active);
            //now force them to change their pw on next login
            UpdateUserPasswordReset(username, true);

            //add the password to the password history so they cant set it back ot the default
            var pwMGr = new PasswordManager(username);

            pwMGr.AddPasswordToHistory(password);

            //now add them to the default group for this store they will have access to
            authorizationManager.AddGroupMember(Constants.Security.DefaultStoreGroupName, username);

            //update the caching table to include this person
            int userID = GetUserId(userModel.Username);

            authorizationManager.AddCustomerAccess(userID);

            //have to check to see if groupname is null - otherwise we throw an error
            if (!string.IsNullOrEmpty(userModel.Role))
            {
                // now add them to the specific group for this store they will have access to
                authorizationManager.AddGroupMember(userModel.Role, username);
            }

            return(username);
        }
Exemplo n.º 13
0
        /// <summary>
        /// it loads a database from file(s).
        /// </summary>
        /// <param name="files">*.formal.xml files to be loaded</param>
        /// <param name="expressionFactory">expression factory to validate script blocks</param>
        /// <param name="authorizationManager">
        /// Authorization manager to perform signature checks before reading ps1xml files (or null of no checks are needed)
        /// </param>
        /// <param name="host">
        /// Host passed to <paramref name="authorizationManager"/>.  Can be null if no interactive questions should be asked.
        /// </param>
        /// <param name="preValidated">
        /// True if the format data has been pre-validated (build time, manual testing, etc) so that validation can be
        /// skipped at runtime.
        /// </param>
        /// <param name="logEntries">list of logger entries (errors, etc.) to return to the caller</param>
        /// <param name="success"> true if no error occurred</param>
        /// <returns>a database instance loaded from file(s)</returns>
        private static TypeInfoDataBase LoadFromFileHelper(
            Collection<PSSnapInTypeAndFormatErrors> files,
            MshExpressionFactory expressionFactory,
            AuthorizationManager authorizationManager,
            PSHost host,
            bool preValidated,
            out List<XmlLoaderLoggerEntry> logEntries,
            out bool success)
        {
            success = true;
            // Holds the aggregated log entries for all files...
            logEntries = new List<XmlLoaderLoggerEntry>();

            // fresh instance of the database
            TypeInfoDataBase db = new TypeInfoDataBase();

            // prepopulate the database with any necessary overriding data
            AddPreLoadInstrinsics(db);

            var etwEnabled = RunspaceEventSource.Log.IsEnabled();

            // load the XML document into a copy of the
            // in memory database
            foreach (PSSnapInTypeAndFormatErrors file in files)
            {
                // Loads formatting data from ExtendedTypeDefinition instance
                if (file.FormatData != null)
                {
                    LoadFormatDataHelper(file.FormatData, expressionFactory, logEntries, ref success, file, db, isBuiltInFormatData: false, isForHelp: false);
                    continue;
                }

                if (etwEnabled) RunspaceEventSource.Log.ProcessFormatFileStart(file.FullPath);

                if (!ProcessBuiltin(file, db, expressionFactory, logEntries, ref success))
                {
                    // Loads formatting data from formatting data XML file
                    XmlFileLoadInfo info =
                        new XmlFileLoadInfo(Path.GetPathRoot(file.FullPath), file.FullPath, file.Errors, file.PSSnapinName);
                    using (TypeInfoDataBaseLoader loader = new TypeInfoDataBaseLoader())
                    {
                        if (!loader.LoadXmlFile(info, db, expressionFactory, authorizationManager, host, preValidated))
                            success = false;

                        foreach (XmlLoaderLoggerEntry entry in loader.LogEntries)
                        {
                            // filter in only errors from the current file...
                            if (entry.entryType == XmlLoaderLoggerEntry.EntryType.Error)
                            {
                                string mshsnapinMessage = StringUtil.Format(FormatAndOutXmlLoadingStrings.MshSnapinQualifiedError, info.psSnapinName, entry.message);
                                info.errors.Add(mshsnapinMessage);
                                if (entry.failToLoadFile) { file.FailToLoadFile = true; }
                            }
                        }
                        // now aggregate the entries...
                        logEntries.AddRange(loader.LogEntries);
                    }
                }

                if (etwEnabled) RunspaceEventSource.Log.ProcessFormatFileStop(file.FullPath);
            }

            // add any sensible defaults to the database
            AddPostLoadInstrinsics(db);

            return db;
        }
Exemplo n.º 14
0
 /// <summary>
 /// load the database
 /// NOTE: need to be protected by lock since not thread safe per se
 /// </summary>
 /// <param name="files">*.formal.xml files to be loaded</param>
 /// <param name="expressionFactory">expression factory to validate script blocks</param>
 /// <param name="acceptLoadingErrors">if true, load the database even if there are loading errors</param>
 /// <param name="authorizationManager">
 /// Authorization manager to perform signature checks before reading ps1xml files (or null of no checks are needed)
 /// </param>
 /// <param name="host">
 /// Host passed to <paramref name="authorizationManager"/>.  Can be null if no interactive questions should be asked.
 /// </param>
 /// <param name="preValidated">
 /// True if the format data has been pre-validated (build time, manual testing, etc) so that validation can be
 /// skipped at runtime.
 /// </param>
 /// <param name="logEntries">Trace and error logs from loading the format Xml files.</param>
 /// <returns>true if we had a successful load</returns>
 internal bool LoadFromFile(
     Collection<PSSnapInTypeAndFormatErrors> files,
     MshExpressionFactory expressionFactory,
     bool acceptLoadingErrors,
     AuthorizationManager authorizationManager,
     PSHost host,
     bool preValidated,
     out List<XmlLoaderLoggerEntry> logEntries)
 {
     bool success;
     try
     {
         TypeInfoDataBase newDataBase = null;
         lock (updateDatabaseLock)
         {
             newDataBase = LoadFromFileHelper(files, expressionFactory, authorizationManager, host, preValidated, out logEntries, out success);
         }
         // if we have a valid database, assign it to the
         // current database
         lock (databaseLock)
         {
             if (acceptLoadingErrors || success)
                 Database = newDataBase;
         }
     }
     finally
     {
         // if, for any reason, we failed the load, we initialize the
         // data base to an empty instance
         lock (databaseLock)
         {
             if (Database == null)
             {
                 TypeInfoDataBase tempDataBase = new TypeInfoDataBase();
                 AddPreLoadInstrinsics(tempDataBase);
                 AddPostLoadInstrinsics(tempDataBase);
                 Database = tempDataBase;
             }
         }
     }
     return success;
 }
Exemplo n.º 15
0
        /// <summary>
        /// Update the current formattable with the existing formatFileList.
        /// New files might have been added using Add() or Files might
        /// have been removed using Remove.
        /// </summary>
        /// <param name="authorizationManager">
        /// Authorization manager to perform signature checks before reading ps1xml files (or null of no checks are needed)
        /// </param>
        /// <param name="host">
        /// Host passed to <paramref name="authorizationManager"/>.  Can be null if no interactive questions should be asked.
        /// </param>
        internal void Update(AuthorizationManager authorizationManager, PSHost host)
        {
            if (DisableFormatTableUpdates)
            {
                return;
            }

            if (isShared)
            {
                throw PSTraceSource.NewInvalidOperationException(FormatAndOutXmlLoadingStrings.SharedFormatTableCannotBeUpdated);
            }

            Collection<PSSnapInTypeAndFormatErrors> filesToLoad = new Collection<PSSnapInTypeAndFormatErrors>();
            lock (_formatFileList)
            {
                foreach (string formatFile in _formatFileList)
                {
                    PSSnapInTypeAndFormatErrors fileToLoad = new PSSnapInTypeAndFormatErrors(string.Empty, formatFile);
                    filesToLoad.Add(fileToLoad);
                }
            }

            UpdateDataBase(filesToLoad, authorizationManager, host, false);
        }
Exemplo n.º 16
0
        public bool IsAvailableForUser(Guid itemId, Guid @for)
        {
            var id     = itemId.ToString();
            var result = false;

            var tenant = TenantManager.GetCurrentTenant();
            var dic    = WebItemSecurityCache.GetOrInsert(tenant.TenantId);

            if (dic != null)
            {
                lock (dic)
                {
                    if (dic.ContainsKey(id + @for))
                    {
                        return(dic[id + @for]);
                    }
                }
            }

            // can read or administrator
            var securityObj = WebItemSecurityObject.Create(id, WebItemManager);

            if (CoreBaseSettings.Personal &&
                securityObj.WebItemId != WebItemManager.DocumentsProductID)
            {
                // only files visible in your-docs portal
                result = false;
            }
            else
            {
                var webitem = WebItemManager[securityObj.WebItemId];
                if (webitem != null)
                {
                    if ((webitem.ID == WebItemManager.CRMProductID ||
                         webitem.ID == WebItemManager.PeopleProductID ||
                         webitem.ID == WebItemManager.BirthdaysProductID ||
                         webitem.ID == WebItemManager.MailProductID) &&
                        UserManager.GetUsers(@for).IsVisitor(UserManager))
                    {
                        // hack: crm, people, birtthday and mail products not visible for collaborators
                        result = false;
                    }
                    else if ((webitem.ID == WebItemManager.CalendarProductID ||
                              webitem.ID == WebItemManager.TalkProductID) &&
                             UserManager.GetUsers(@for).IsOutsider(UserManager))
                    {
                        // hack: calendar and talk products not visible for outsider
                        result = false;
                    }
                    else if (webitem is IModule)
                    {
                        result = PermissionContext.PermissionResolver.Check(Authentication.GetAccountByID(tenant.TenantId, @for), securityObj, null, Read) &&
                                 IsAvailableForUser(WebItemManager.GetParentItemID(webitem.ID), @for);
                    }
                    else
                    {
                        var hasUsers = AuthorizationManager.GetAces(Guid.Empty, Read.ID, securityObj).Any(a => a.SubjectId != ASC.Core.Users.Constants.GroupEveryone.ID);
                        result = PermissionContext.PermissionResolver.Check(Authentication.GetAccountByID(tenant.TenantId, @for), securityObj, null, Read) ||
                                 (hasUsers && IsProductAdministrator(securityObj.WebItemId, @for));
                    }
                }
                else
                {
                    result = false;
                }
            }

            dic = WebItemSecurityCache.Get(tenant.TenantId);
            if (dic != null)
            {
                lock (dic)
                {
                    dic[id + @for] = result;
                }
            }
            return(result);
        }
Exemplo n.º 17
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!ValidateURL())
            {
                Response.Redirect(CommonConstants.INVALIDURL, false);
            }
            else
            {
                //Clearing the error label
                lblError.Text   = string.Empty;
                lblMessage.Text = string.Empty;

                btnAddRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
                btnUpdate.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
                btnSave.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return SaveButtonClickValidate();");

                txtYearsOfExperience.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtYearsOfExperience.ClientID + "','" + imgYearsOfExperience.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
                imgYearsOfExperience.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanYearsOfExperience.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
                imgYearsOfExperience.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanYearsOfExperience.ClientID + "');");

                txtLastUsedDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + txtLastUsedDate.ClientID + "','','');");
                txtLastUsedDate.Attributes.Add(ReadOnly, ReadOnly);

                if (Session[Common.SessionNames.EMPLOYEEDETAILS] != null)
                {
                    employee = (BusinessEntities.Employee)Session[Common.SessionNames.EMPLOYEEDETAILS];
                }

                if (employee != null)
                {
                    employeeID = employee.EMPId;
                }

                if (!IsPostBack)
                {
                    this.PopulateGrid(employeeID);
                    this.GetSkillTypes();
                    this.GetSkillsByType(0);
                    this.GetProficiencyLevel();
                }

                // Get logged-in user's email id
                AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager();
                UserRaveDomainId = objRaveHRAuthorizationManager.getLoggedInUser();
                UserMailId       = UserRaveDomainId.Replace("co.in", "com");


                if (Session[SessionNames.PAGEMODE] != null)
                {
                    string PageMode = Session[SessionNames.PAGEMODE].ToString();
                    arrRolesForUser = RaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser());

                    if (UserMailId.ToLower() == employee.EmailId.ToLower())
                    {
                        if (arrRolesForUser.Count > 0)
                        {
                            if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString())
                            {
                                Skillsdetails.Enabled = true;
                                btnCancel.Visible     = true;
                                SkillTypeRow.Disabled = false;
                                if (gvSkills.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                                {
                                    btnSave.Visible = true;
                                }
                            }
                            else
                            {
                                Skillsdetails.Enabled = false;
                                btnSave.Visible       = false;
                                btnCancel.Visible     = false;
                                SkillTypeRow.Disabled = true;
                            }
                        }
                    }
                    else
                    {
                        if (arrRolesForUser.Contains(AuthorizationManagerConstants.ROLEHR))
                        {
                            if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString())
                            {
                                Skillsdetails.Enabled = true;
                                btnCancel.Visible     = true;
                                SkillTypeRow.Disabled = false;
                                if (gvSkills.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                                {
                                    btnSave.Visible = true;
                                }
                            }
                            else
                            {
                                Skillsdetails.Enabled = false;
                                btnSave.Visible       = false;
                                btnCancel.Visible     = false;
                                SkillTypeRow.Disabled = true;
                            }
                        }
                        else
                        {
                            if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString())
                            {
                                Skillsdetails.Enabled        = true;
                                btnCancel.Visible            = true;
                                SkillTypeRow.Disabled        = true;
                                ddlSkills.Enabled            = false;
                                txtLastUsedDate.Enabled      = false;
                                txtYearsOfExperience.Enabled = false;
                                imgLastUsedDate.Enabled      = false;

                                for (int i = 0; i < gvSkills.Rows.Count; i++)
                                {
                                    ImageButton ibtnDelete = (ImageButton)gvSkills.Rows[i].FindControl(IBTNDELETE);
                                    ibtnDelete.Enabled = false;
                                }
                                if (gvSkills.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                                {
                                    btnSave.Visible = true;
                                }
                            }
                            else
                            {
                                Skillsdetails.Enabled = false;
                                btnSave.Visible       = false;
                                btnCancel.Visible     = false;
                                SkillTypeRow.Disabled = true;
                            }
                        }
                    }
                }
            }
        }
        catch (RaveHRException ex)
        {
            LogErrorMessage(ex);
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "Page_Load", EventIDConstants.RAVE_HR_PROJECTS_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }
    }
Exemplo n.º 18
0
 internal void Update(AuthorizationManager authorizationManager, PSHost host)
 {
     if (!this.DisableFormatTableUpdates)
     {
         if (this.isShared)
         {
             throw PSTraceSource.NewInvalidOperationException("FormatAndOutXmlLoadingStrings", "SharedFormatTableCannotBeUpdated", new object[0]);
         }
         Collection<PSSnapInTypeAndFormatErrors> mshsnapins = new Collection<PSSnapInTypeAndFormatErrors>();
         lock (this.formatFileList)
         {
             foreach (string str in this.formatFileList)
             {
                 PSSnapInTypeAndFormatErrors item = new PSSnapInTypeAndFormatErrors(string.Empty, str);
                 mshsnapins.Add(item);
             }
         }
         this.UpdateDataBase(mshsnapins, authorizationManager, host, false);
     }
 }
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //Clearing the error label
        lblError.Text   = string.Empty;
        lblMessage.Text = string.Empty;

        btnAddRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
        btnUpdateRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
        btnSave.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return SaveButtonClickValidate();");

        ddlQualification.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + spanzQualification.ClientID + "','','');");
        imgQualification.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanQualification.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');");
        imgQualification.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanQualification.ClientID + "');");

        txtUniversityName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtUniversityName.ClientID + "','" + imgUniversityName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPECIALCHAR + "');");
        imgUniversityName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanUniversityName.ClientID + "','" + Common.CommonConstants.MSG_ALPHABET_SPECIALCHAR + "');");
        imgUniversityName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanUniversityName.ClientID + "');");

        txtInstituteName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtInstituteName.ClientID + "','" + imgInstituteName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPECIALCHAR + "');");
        imgInstituteName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanInstituteName.ClientID + "','" + Common.CommonConstants.MSG_ALPHABET_SPECIALCHAR + "');");
        imgInstituteName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanInstituteName.ClientID + "');");

        txtYearOfPassing.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtYearOfPassing.ClientID + "','" + imgYearOfPassing.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgYearOfPassing.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanYearOfPassing.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgYearOfPassing.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanYearOfPassing.ClientID + "');");

        txtGPA.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtGPA.ClientID + "','" + imgGPA.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgGPA.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanGPA.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgGPA.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanGPA.ClientID + "');");

        txtOutOf.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtOutOf.ClientID + "','" + imgOutOf.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgOutOf.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanOutOf.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgOutOf.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanOutOf.ClientID + "');");

        txtPercentage.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtPercentage.ClientID + "','" + imgPercentage.ClientID + "','" + "Decimal" + "');");
        imgPercentage.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanPercentage.ClientID + "','" + Common.CommonConstants.MSG_DECIMAL + "');");
        imgPercentage.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanPercentage.ClientID + "');");

        if (!ValidateURL())
        {
            Response.Redirect(CommonConstants.INVALIDURL, false);
        }
        else
        {
            if (Session[Common.SessionNames.EMPLOYEEDETAILS] != null)
            {
                employee = (BusinessEntities.Employee)Session[Common.SessionNames.EMPLOYEEDETAILS];
            }

            if (employee != null)
            {
                employeeID = employee.EMPId;
            }

            if (!IsPostBack)
            {
                this.PopulateGrid(employeeID);
                this.GetQualifications();
            }

            // Get logged-in user's email id
            AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager();
            UserRaveDomainId = objRaveHRAuthorizationManager.getLoggedInUser();
            UserMailId       = UserRaveDomainId.Replace("co.in", "com");


            if (Session[SessionNames.PAGEMODE] != null)
            {
                string PageMode = Session[SessionNames.PAGEMODE].ToString();
                arrRolesForUser = RaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser());

                if (UserMailId.ToLower() == employee.EmailId.ToLower())
                {
                    if (arrRolesForUser.Count > 0)
                    {
                        if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString())
                        {
                            Qualificationdetails.Enabled = true;
                            btnCancel.Visible            = true;
                            if (gvQualification.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                            {
                                btnSave.Visible = true;
                            }
                        }
                        else
                        {
                            Qualificationdetails.Enabled = false;
                            btnSave.Visible   = false;
                            btnCancel.Visible = false;
                        }
                    }
                }
                else
                {
                    if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString() && arrRolesForUser.Contains(AuthorizationManagerConstants.ROLEHR))
                    {
                        Qualificationdetails.Enabled = true;
                        btnCancel.Visible            = true;
                        if (gvQualification.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                        {
                            btnSave.Visible = true;
                        }
                    }
                    else
                    {
                        Qualificationdetails.Enabled = false;
                        btnSave.Visible   = false;
                        btnCancel.Visible = false;
                    }
                }
            }
        }
    }
Exemplo n.º 20
0
        public AllRunsSet GetTestRunDetails(DateTime?fromDate, DateTime?toDate, int[] configIDs, int[] CategoryIDs, int page, int PageSize)
        {
            AllRunsSet model = new AllRunsSet();

            model.FromDate = Convert.ToDateTime(fromDate);
            model.ToDate   = Convert.ToDateTime(toDate);

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var categoryDetails = from Categoryset in dc.TestCategorySets
                                      select new
                {
                    Categoryset.Id,
                    Categoryset.Name
                };

                List <CategoryList> testCategory = new List <CategoryList>();
                foreach (var category in categoryDetails.ToList())
                {
                    testCategory.Add(new CategoryList {
                        ID = category.Id, Name = category.Name
                    });
                }

                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.Name,
                    configset.Type,
                    configset.AnonymousAccess,
                    configset.TestCategory_Id,
                    configset.TestAuthentication_Id,
                    configset.Branch
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                if (CategoryIDs != null && CategoryIDs.Any())
                {
                    configDetails = configDetails.Where(c => CategoryIDs.Contains(c.TestCategory_Id));
                }

                List <ConfigurationList> testConfigurations = new List <ConfigurationList>();
                foreach (var config in configDetails.ToList())
                {
                    testConfigurations.Add(new ConfigurationList {
                        ID = config.Id, Name = config.Name
                    });
                }

                if (configIDs != null && configIDs.Any())
                {
                    configDetails = configDetails.Where(c => configIDs.Contains(c.Id));

                    //model.SelectedCategory = category;
                }


                var testResults = (from configset in configDetails
                                   join categorySet in dc.TestCategorySets on configset.TestCategory_Id equals categorySet.Id
                                   join authenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals authenticationset.Id
                                   join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                   where DbFunctions.TruncateTime(testrunsets.TestDate) >= DbFunctions.TruncateTime(fromDate) &&
                                   DbFunctions.TruncateTime(testrunsets.TestDate) <= DbFunctions.TruncateTime(toDate)
                                   select new
                {
                    Status = testrunsets.Status,
                    Testdate = testrunsets.TestDate,
                    TestDuration = testrunsets.TestTime,
                    Passed = testrunsets.TestsPassed,
                    Skipped = testrunsets.TestsSkipped,
                    Failed = testrunsets.TestsFailed,
                    Log = (testrunsets.MSBuildLog != null ? true : false),
                    TestRunSetId = testrunsets.Id,
                    CId = testrunsets.TestConfigurationId,
                    cName = configset.Name,
                    CategoryName = categorySet.Name,
                    appOnly = authenticationset.AppOnly,
                    cType = configset.Type,
                    GithubBranch = configset.Branch
                }).OrderByDescending(t => t.Testdate).Skip((page - 1) * PageSize).Take(PageSize).ToList();

                List <AllRuns> configTestRuns = (from testrunsets in testResults
                                                 select new AllRuns
                {
                    Status = testrunsets.Status,
                    ConfiguratioName = testrunsets.cName,
                    GithubBranch = testrunsets.GithubBranch,
                    CategoryName = testrunsets.CategoryName,
                    AppOnly = Enum.GetName(typeof(AppOnly), testrunsets.appOnly),
                    Environment = Enum.GetName(typeof(EnvironmentType), testrunsets.cType),
                    Testdate = testrunsets.Testdate,
                    TestDuration = (testrunsets.TestDuration != null ? Convert.ToString(testrunsets.TestDuration).Remove(Convert.ToString(testrunsets.TestDuration).IndexOf('.')) : "N/A"),
                    Passed = (testrunsets.Passed != null ? testrunsets.Passed : 0),
                    Skipped = (testrunsets.Skipped != null ? testrunsets.Skipped : 0),
                    Failed = (testrunsets.Failed != null ? testrunsets.Failed : 0),
                    Log = testrunsets.Log,
                    TestRunSetId = testrunsets.TestRunSetId,
                    Tests = ((testrunsets.Passed != null ? testrunsets.Passed : 0)
                             + (testrunsets.Skipped != null ? testrunsets.Skipped : 0)
                             + (testrunsets.Failed != null ? testrunsets.Failed : 0))
                }).OrderByDescending(d => d.Testdate.Date).ThenByDescending(t => t.Testdate.TimeOfDay).ToList();

                model.pnptestresults     = configTestRuns;
                model.TestConfigurations = testConfigurations;
                model.TestCategory       = testCategory;

                model.TestResultsCount = (from testrunsets in dc.TestRunSets
                                          join config in configDetails on testrunsets.TestConfigurationId equals config.Id
                                          where DbFunctions.TruncateTime(testrunsets.TestDate) >= DbFunctions.TruncateTime(fromDate) && DbFunctions.TruncateTime(testrunsets.TestDate) <= DbFunctions.TruncateTime(toDate)
                                          select new { testrunsets.Id }).ToList().Count;
            }

            return(model);
        }
Exemplo n.º 21
0
        public void OnClick(View view)
        {
            if (view.Id == DemoButton.Id)
            {
                ServerName.Text    = Constants.Localhost;
                Username.Text      = "admin1";
                Password.Text      = "123";
                RememberMe.Checked = false;
            }
            else
            {
                var data = new object[]
                {
                    null,
                    null,
                    ServerName.Text
                };
                AuthorizationManager.SetAuthorization(data);
            }

            LoginModel.ServerName = ServerName.Text;
            LoginModel.Username   = Username.Text;
            LoginModel.Password   = Password.Text;
            LoginModel.RememberMe = RememberMe.Checked;

            var token = CancelAndSetTokenForView(view);

            SetEnabled(false);

            var animationFadeOut = AnimationUtils.LoadAnimation(Context, Android.Resource.Animation.FadeOut);

            animationFadeOut.Duration = 500;
            var animationFadeIn = AnimationUtils.LoadAnimation(Context, Android.Resource.Animation.FadeIn);

            animationFadeIn.Duration = 500;

            animationFadeIn.SetAnimationListener(new VisibilityAnimationListener(LoginProgressBar, ViewStates.Visible));
            animationFadeOut.SetAnimationListener(new VisibilityAnimationListener(LoginLayout, ViewStates.Invisible));

            LoginLayout.StartAnimation(animationFadeOut);
            LoginProgressBar.StartAnimation(animationFadeIn);

            OnServerProvidedListener.OnServerProvided(LoginModel.ServerName);

            Task.Run(async() =>
            {
                HttpResult <string> result = null;
                try
                {
                    result = await AuthService.Login(LoginModel, token);
                }
                catch (System.Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        ShowToastMessage(ex.Message, ToastLength.Long);
                    });
                    return;
                }

                if (result.Error.Any())
                {
                    var errorMessage = result.Error.Select(kv => kv.Value.FirstOrDefault()).FirstOrDefault()
                                       ?? "An error occurred";

                    RunOnUiThread(() =>
                    {
                        ShowToastMessage(errorMessage);

                        animationFadeOut.Cancel();
                        animationFadeIn.Cancel();

                        animationFadeIn.SetAnimationListener(new VisibilityAnimationListener(LoginLayout, ViewStates.Visible));
                        animationFadeOut.SetAnimationListener(new VisibilityAnimationListener(LoginProgressBar, ViewStates.Invisible));

                        LoginProgressBar.StartAnimation(animationFadeOut);
                        LoginLayout.StartAnimation(animationFadeIn);

                        SetEnabled(true);
                    });

                    return;
                }

                RunOnUiThread(() =>
                {
                    animationFadeOut.Cancel();
                    animationFadeIn.Cancel();

                    animationFadeIn.SetAnimationListener(new VisibilityAnimationListener(LoginLayout, ViewStates.Visible));
                    animationFadeOut.SetAnimationListener(new VisibilityAnimationListener(LoginProgressBar, ViewStates.Invisible));

                    LoginProgressBar.StartAnimation(animationFadeOut);
                    LoginLayout.StartAnimation(animationFadeIn);

                    SetEnabled(true);

                    if (LoginModel.RememberMe)
                    {
                        PersistenceProvider.SetCredentials(LoginModel);
                    }
                    else
                    {
                        PersistenceProvider.ClearCredentials();
                    }

                    OnLoginListener.OnLogin(LoginModel, result.Data);
                });
            }, token);
        }
        public override void Process(HttpRequestArgs args)
        {
            //don't do backend
            if (Sitecore.Context.Domain.Name.ToLower().Contains("sitecore") || !Sitecore.Context.PageMode.IsNormal)
            {
                return;
            }

            // Get the site context
            SiteContext site = Sitecore.Context.Site;

            // Check if the current user has sufficient rights to enter this page
            if (!SiteManager.CanEnter(site.Name, Sitecore.Context.User))
            {
                return;
            }

            string prefix = args.StartPath;

            if (args.LocalPath.Contains(Sitecore.Context.Site.StartPath))
            {
                prefix = String.Empty;
            }

            if (Sitecore.Context.Database == null)
            {
                return;
            }

            // Get the item using securityDisabler for restricted items such as permission denied items
            Item contextItem = null;

            using (new SecurityDisabler())
            {
                if (Context.Database == null || args.Url.ItemPath.Length == 0)
                {
                    return;
                }

                string path = MainUtil.DecodeName(args.Url.ItemPath);
                Item   item = args.GetItem(path);
                if (item == null)
                {
                    path = args.LocalPath;
                    item = args.GetItem(path);
                }
                if (item == null)
                {
                    path = MainUtil.DecodeName(args.LocalPath);
                    item = args.GetItem(path);
                }
                string str2 = (site != null) ? site.RootPath : string.Empty;
                if (item == null)
                {
                    path = FileUtil.MakePath(str2, args.LocalPath, '/');
                    item = args.GetItem(path);
                }
                if (item == null)
                {
                    path = MainUtil.DecodeName(FileUtil.MakePath(str2, args.LocalPath, '/'));
                    item = args.GetItem(path);
                }
                if (item == null)
                {
                    Item root = ItemManager.GetItem(site.RootPath, Language.Current, Sitecore.Data.Version.Latest, Context.Database, SecurityCheck.Disable);
                    if (root != null)
                    {
                        string path2 = MainUtil.DecodeName(args.LocalPath);
                        item = this.GetSubItem(path2, root);
                    }
                }
                if (item == null)
                {
                    int index = args.Url.ItemPath.IndexOf('/', 1);
                    if (index >= 0)
                    {
                        Item root = ItemManager.GetItem(args.Url.ItemPath.Substring(0, index), Language.Current, Sitecore.Data.Version.Latest, Context.Database, SecurityCheck.Disable);
                        if (root != null)
                        {
                            string path3 = MainUtil.DecodeName(args.Url.ItemPath.Substring(index));
                            item = this.GetSubItem(path3, root);
                        }
                    }
                }
                if (((item == null) && args.UseSiteStartPath) && (site != null))
                {
                    item = args.GetItem(site.StartPath);
                }
                contextItem = item;
            }

            //Item contextItem = Sitecore.Context.Item;
            if (contextItem == null)
            {
                return;
            }

            User u         = Sitecore.Context.User;
            bool isAllowed = AuthorizationManager.IsAllowed(contextItem, AccessRight.ItemRead, u);

            if (isAllowed)
            {
                return;
            }

            string rawURL = HttpContext.Current.Server.HtmlEncode(HttpContext.Current.Request.RawUrl);

            if (site.LoginPage.Length > 0) // Redirect the user
            {
                WebUtil.Redirect(string.Format("{0}?returnUrl={1}", site.LoginPage, rawURL));
            }
        }
Exemplo n.º 23
0
        public HttpResponseMessage GetWatchList()
        {
            var jwt = Request.Headers.GetValues("token").FirstOrDefault();

            var response = new HttpResponseMessage();

            if (jwt == null)
            {
                response.Content    = new StringContent("JWT is null.");
                response.StatusCode = HttpStatusCode.Conflict;
                return(response);
            }

            using (var db = new DataBaseContext())
            {
                try
                {
                    TokenManager tokenManager = new TokenManager(db);

                    //Validate Token
                    string newJWT = tokenManager.ValidateToken(jwt);
                    //if jwt not valid redirect to SSO login
                    if (newJWT == null)
                    {
                        response         = Request.CreateResponse(HttpStatusCode.Moved);
                        response.Content = new StringContent("https://kfc-sso.com/#/login");
                        return(response);
                    }

                    //Athorize
                    AuthorizationManager authManager = new AuthorizationManager(db);
                    if (!authManager.AuthorizeAction(newJWT, Actions.WISHLIST))
                    {
                        response.Content    = new StringContent("User in unauthorized to access watchlist.");
                        response.StatusCode = HttpStatusCode.Unauthorized;
                    }

                    Guid userID = tokenManager.ExtractUserID(newJWT);

                    //Get items and make DTO
                    ItemManager itemManager = new ItemManager(db);
                    var         items       = itemManager.GetItemsFromWatchList(userID);
                    var         itemsDTO    = new ItemsDTO()
                    {
                        jwt   = newJWT,
                        items = items
                    };

                    //make response
                    response.Content = new StringContent(JsonConvert.SerializeObject(itemsDTO),
                                                         System.Text.Encoding.UTF8, "application/json");
                    response.StatusCode = HttpStatusCode.OK;
                    return(response);
                }catch (Exception e)
                {
                    response.Content    = new StringContent(e.Message);
                    response.StatusCode = HttpStatusCode.Conflict;
                    return(response);
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Add the RBAC entry for the admin site.
        /// </summary>
        private void AddAdminSite()
        {
            var authorizationManager = new AuthorizationManager();

            Log = "Creating RBAC store for the Admin site.";

            if (authorizationManager.CreateCity(_options.AdminSiteId, "Admin", "PEMS Administration"))
            {
                Log = "Created RBAC Admin store";
            }
            else
            {
                LogError = "Failed to create RBAC Admin store";
            }


            Log = "Creating RBAC entries for the administration site...";
            bool success = authorizationManager.SetConfiguration(_options.AdminSiteTemplate);

            // Now write out the process log.
            foreach (var xmlProcessLog in authorizationManager.XmlProcessLogs)
            {
                Log = xmlProcessLog;
            }

            if (success)
            {
                Log = "***** RBAC entries successfully processed. *****";
            }
            else
            {
                LogError = "***** Errors were encountered creating the RBAC entries.  See below. *****";

                // Now write out errors.
                foreach (var xmlProcessError in authorizationManager.XmlProcessErrors)
                {
                    LogError = xmlProcessError;
                }
            }


            // Create an entry in [CustomerProfiles] if required.
            var RbacEntities = new PEMRBACEntities();

            // Get the user id that is adding this Admin site.
            UserFactory userFactory = new UserFactory();
            int         userId      = userFactory.GetUserId(_options.AdminUserName);

            if (userId != (int)Constants.User.InvalidUserId)
            {
                CustomerProfile customerProfile = RbacEntities.CustomerProfiles.FirstOrDefault(m => m.DisplayName.Equals("Admin"));
                if (customerProfile == null)
                {
                    customerProfile = new CustomerProfile()
                    {
                        CustomerId                    = _options.AdminSiteId,
                        DisplayName                   = "Admin",
                        CreatedOn                     = DateTime.Now,
                        CreatedBy                     = userId,
                        StatusChangeDate              = DateTime.Now,
                        PEMSConnectionStringName      = null,
                        ReportingConnectionStringName = null,
                        CustomerTypeId                = (int)CustomerProfileType.Admin,
                        Status = (int)CustomerStatus.Active
                    };
                    RbacEntities.CustomerProfiles.Add(customerProfile);
                    RbacEntities.SaveChanges();
                    Log = "Created entry in CustomerProfiles for Admin.";
                }
            }
            else
            {
                LogError = "Unable to create an entry in CustomerProfiles for Admin - Invalid admin user name.";
            }
        }
Exemplo n.º 25
0
 private void checkIsAuthorizedToReadHistoryOfProcessDefinitions()
 {
     AuthorizationManager.checkAuthorization(READ_HISTORY, PROCESS_DEFINITION);
 }
Exemplo n.º 26
0
 public TagController(TagService tagService, AuthorizationManager authorizationManager)
 {
     this.tagService           = tagService;
     this.authorizationManager = authorizationManager;
 }
Exemplo n.º 27
0
 public AuthorizationManagerUT()
 {
     _tu = new TestingUtils();
     _am = new AuthorizationManager();
 }
Exemplo n.º 28
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //Clearing the error label
        lblError.Text   = string.Empty;
        lblMessage.Text = string.Empty;

        btnAddRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
        btnUpdate.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
        btnSave.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return SaveButtonClickValidate();");

        txtName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtName.ClientID + "','" + imgName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPACE + "');");
        imgName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanName.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');");
        imgName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanName.ClientID + "');");

        txtTotalScore.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtTotalScore.ClientID + "','" + imgTotalScore.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgTotalScore.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanTotalScore.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgTotalScore.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanTotalScore.ClientID + "');");

        txtOutOf.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtOutOf.ClientID + "','" + imgOutOf.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgOutOf.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanOutOf.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgOutOf.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanOutOf.ClientID + "');");

        txtCertificationDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + txtCertificationDate.ClientID + "','','');");
        txtCertificationDate.Attributes.Add(ReadOnly, ReadOnly);
        txtCertficationValidDate.Attributes.Add(CommonConstants.EVENT_ONBLUR, "javascript:ValidateControl('" + txtCertficationValidDate.ClientID + "','','');");
        txtCertficationValidDate.Attributes.Add(ReadOnly, ReadOnly);
        //imgCertificationDate.Attributes.Add(CommonConstants.EVENT_ONMOUSEOVER, "javascript:ValidateControl('" + imgCertificationDate.ClientID + "','','');");
        //imgCertficationValidDate.Attributes.Add(CommonConstants.EVENT_ONMOUSEOVER, "javascript:ValidateControl('" + imgCertficationValidDate.ClientID + "','','');");

        if (!ValidateURL())
        {
            Response.Redirect(CommonConstants.INVALIDURL, false);
        }
        else
        {
            if (Session[Common.SessionNames.EMPLOYEEDETAILS] != null)
            {
                employee = (BusinessEntities.Employee)Session[Common.SessionNames.EMPLOYEEDETAILS];
            }

            if (employee != null)
            {
                employeeID = employee.EMPId;
            }

            if (!IsPostBack)
            {
                this.PopulateGrid(employeeID);
            }

            // Get logged-in user's email id
            AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager();
            UserRaveDomainId = objRaveHRAuthorizationManager.getLoggedInUser();
            UserMailId       = UserRaveDomainId.Replace("co.in", "com");


            if (Session[SessionNames.PAGEMODE] != null)
            {
                string PageMode = Session[SessionNames.PAGEMODE].ToString();
                arrRolesForUser = RaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser());

                if (UserMailId.ToLower() == employee.EmailId.ToLower())
                {
                    if (arrRolesForUser.Count > 0)
                    {
                        if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString())
                        {
                            Certificationdetails.Enabled = true;
                            btnCancel.Visible            = true;
                            if (gvCertification.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                            {
                                btnSave.Visible = true;
                            }
                        }
                        else
                        {
                            Certificationdetails.Enabled = false;
                            btnSave.Visible   = false;
                            btnCancel.Visible = false;
                        }
                    }
                }
                else
                {
                    if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString() && arrRolesForUser.Contains(AuthorizationManagerConstants.ROLEHR))
                    {
                        Certificationdetails.Enabled = true;
                        btnCancel.Visible            = true;
                        if (gvCertification.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                        {
                            btnSave.Visible = true;
                        }
                    }
                    else
                    {
                        Certificationdetails.Enabled = false;
                        btnSave.Visible   = false;
                        btnCancel.Visible = false;
                    }
                }
            }
        }
    }
Exemplo n.º 29
0
 public SnapshotController(SnapshotManager snapshotManager, AuthorizationManager authorizationManager)
 {
     m_snapshotManager      = snapshotManager;
     m_authorizationManager = authorizationManager;
 }
Exemplo n.º 30
0
        public ExportResult ExportDatasetActivities(JObject jsonData)
        {
            var db = ServicesContext.Current;

            dynamic json = jsonData;

            User me = AuthorizationManager.getCurrentUser();

            //grab a reference to this dataset so we can parse incoming fields
            Dataset dataset = db.Datasets.Find(json.DatasetId.ToObject <int>());

            if (dataset == null || me == null)
            {
                throw new Exception("Configuration error. Please try again.");
            }

            logger.Debug("Alright!  we are working with dataset: " + dataset.Id);

            //DataTable dt = getQueryResults(dataset, json);
            DataTable dt = QueryHelper.getQueryResults(dataset, json, "Export");

            logger.Debug("Download data -- we have a result back.");

            string Filename = json.Filename;

            Filename = Filename.Replace("\"", string.Empty);
            Filename = Filename.Replace("\\", string.Empty);
            Filename = Filename.Replace("/", string.Empty);

            logger.Debug("Incoming filename specified: " + Filename);

            string root     = System.Web.HttpContext.Current.Server.MapPath("~/exports");
            string the_file = root + @"\" + dataset.Id + @"_" + me.Id + @"\" + Filename;

            logger.Debug("saving file to location: " + the_file);

            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(the_file)); //will create if necessary.

            //TODO: better is to get it from config
            string rootUrl = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, String.Empty);

            //rootUrl += "/services/exports/" + dataset.Id + "_" + me.Id + "/" + Filename;
            rootUrl += "/" + System.Configuration.ConfigurationManager.AppSettings["ExecutingEnvironment"] + "exports/" + dataset.Id + "_" + me.Id + "/" + Filename;
            logger.Debug("rootUrl again = " + rootUrl);

            using (TextWriter writer = System.IO.File.CreateText(the_file)) //will overwrite = good
            {
                using (var csv = new CsvWriter(writer))
                {
                    IEnumerable <string> columnNames = dataset.getExportLabelsList();//dt.Columns.Cast<DataColumn>().Select(column => column.ColumnName);

                    string strHeader            = "Waypoints File";
                    int    intHeaderLength      = strHeader.Length;
                    int    intFieldHeaderLength = 0;
                    logger.Debug("dataset.Datastore.TablePrefix = " + dataset.Datastore.TablePrefix);

                    //columns
                    foreach (var header in columnNames)
                    {
                        //logger.Debug("header = " + header);
                        intFieldHeaderLength = header.Length;
                        if (dataset.Datastore.TablePrefix == "SpawningGroundSurvey")
                        {
                            if ((intFieldHeaderLength >= intHeaderLength) && (header.IndexOf(strHeader) > -1))
                            {
                                // For Spawning Ground Survey, the "Waypoints File" header is unnecessary,
                                // because the data is not saved.  The header is only used in the front end.
                                // Consequently, it causes the data items to be skewed; everything from Channel to the right,
                                // gets shifted to the left one, because there is no Waypoint File entry.
                                // Therefore, we will skip adding this header.
                                logger.Debug("Skipping Waypoints File Header...");
                            }
                            else
                            {
                                csv.WriteField(header);
                            }
                        }
                        else
                        {
                            csv.WriteField(header);
                        }
                    }
                    csv.NextRecord();

                    //fields
                    foreach (DataRow row in dt.Rows)
                    {
                        IEnumerable <string> fields = row.ItemArray.Select(field => field.ToString());
                        foreach (var field in fields)
                        {
                            //logger.Debug("field before replace = " + field);
                            //replace out the multiselect array stuff.
                            var f = field.Replace("[]", string.Empty).Replace("[\"", string.Empty).Replace("\"]", string.Empty).Replace("\",\"", ",");
                            //logger.Debug("field after replace = " + f);
                            csv.WriteField(f);
                        }
                        csv.NextRecord();
                    }
                }
            }

            //TODO-- error handling?

            ExportResult result = new ExportResult();

            result.success = true;
            result.file    = rootUrl;
            result.errors  = null;

            return(result);
        }
Exemplo n.º 31
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //Clearing the error label
        lblError.Text   = string.Empty;
        lblMessage.Text = string.Empty;

        btnAddRow.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
        btnUpdate.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return ButtonClickValidate();");
        btnSave.Attributes.Add(Common.CommonConstants.EVENT_ONCLICK, "return SaveButtonClickValidate();");

        ddlLocation.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + spanzLocation.ClientID + "','','');");
        imgLocation.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanLocation.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');");
        imgLocation.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanLocation.ClientID + "');");

        txtCompanyName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtCompanyName.ClientID + "','" + imgCompanyName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPECIALCHAR + "');");
        imgCompanyName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanCompanyName.ClientID + "','" + Common.CommonConstants.MSG_ALPHABET_SPECIALCHAR + "');");
        imgCompanyName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanCompanyName.ClientID + "');");

        txtProjectName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtProjectName.ClientID + "','" + imgProjectName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPECIALCHAR + "');");
        imgProjectName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanProjectName.ClientID + "','" + Common.CommonConstants.MSG_ALPHABET_SPECIALCHAR + "');");
        imgProjectName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanProjectName.ClientID + "');");

        txtClientName.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtClientName.ClientID + "','" + imgClientName.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPECIALCHAR + "');");
        imgClientName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanClientName.ClientID + "','" + Common.CommonConstants.MSG_ALPHABET_SPECIALCHAR + "');");
        imgClientName.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanClientName.ClientID + "');");

        txtDuration.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtDuration.ClientID + "','" + imgDuration.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgDuration.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanDuration.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgDuration.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanDuration.ClientID + "');");

        txtProjectSiZe.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtProjectSiZe.ClientID + "','" + imgProjectSize.ClientID + "','" + Common.CommonConstants.VALIDATE_NUMERIC_FUNCTION + "');");
        imgProjectSize.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanProjectSize.ClientID + "','" + Common.CommonConstants.MSG_NUMERIC + "');");
        imgProjectSize.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanProjectSize.ClientID + "');");

        txtProjectDescription.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return MultiLineTextBox('" + txtProjectDescription.ClientID + "','" + txtProjectDescription.MaxLength + "','" + imgProjectDescription.ClientID + "');");
        imgProjectDescription.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanProjectDescription.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');");
        imgProjectDescription.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanProjectDescription.ClientID + "');");

        txtRole.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return ValidateControl('" + txtRole.ClientID + "','" + imgRole.ClientID + "','" + Common.CommonConstants.VALIDATE_ALPHABET_WITHSPACE + "');");
        imgRole.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanRole.ClientID + "','" + Common.CommonConstants.MSG_ONLY_ALPHABET + "');");
        imgRole.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanRole.ClientID + "');");

        txtResponsibility.Attributes.Add(Common.CommonConstants.EVENT_ONBLUR, "return MultiLineTextBox('" + txtResponsibility.ClientID + "','" + txtResponsibility.MaxLength + "','" + imgResponsibility.ClientID + "');");
        imgResponsibility.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOVER, "ShowTooltip('" + spanResponsibility.ClientID + "','" + Common.CommonConstants.MSG_ALPHA_NUMERIC + "');");
        imgResponsibility.Attributes.Add(Common.CommonConstants.EVENT_ONMOUSEOUT, "HideTooltip('" + spanResponsibility.ClientID + "');");

        if (!ValidateURL())
        {
            Response.Redirect(CommonConstants.INVALIDURL, false);
        }
        else
        {
            if (Session[Common.SessionNames.EMPLOYEEDETAILS] != null)
            {
                employee = (BusinessEntities.Employee)Session[Common.SessionNames.EMPLOYEEDETAILS];
            }

            if (employee != null)
            {
                employeeID = employee.EMPId;
            }

            if (!IsPostBack)
            {
                this.PopulateGrid(employeeID);
                this.GetLocation();
                this.GetBifurcation();
            }

            if (gvProjectDetails.Rows[0].Cells[0].Text == NO_RECORDS_FOUND_MESSAGE)
            {
                ProjectDetailsCollection.Clear();
                ShowHeaderWhenEmptyGrid();
            }

            // Get logged-in user's email id
            AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager();
            UserRaveDomainId = objRaveHRAuthorizationManager.getLoggedInUser();
            UserMailId       = UserRaveDomainId.Replace("co.in", "com");


            if (Session[SessionNames.PAGEMODE] != null)
            {
                string PageMode = Session[SessionNames.PAGEMODE].ToString();
                arrRolesForUser = RaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser());

                if (UserMailId.ToLower() == employee.EmailId.ToLower())
                {
                    if (arrRolesForUser.Count > 0)
                    {
                        if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString())
                        {
                            Projectdetails.Enabled = true;
                            btnCancel.Visible      = true;
                            if (gvProjectDetails.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                            {
                                btnSave.Visible = true;
                            }
                        }
                        else
                        {
                            Projectdetails.Enabled = false;
                            btnSave.Visible        = false;
                            btnCancel.Visible      = false;
                        }
                    }
                }
                else
                {
                    if (PageMode == Common.MasterEnum.PageModeEnum.Edit.ToString() && arrRolesForUser.Contains(AuthorizationManagerConstants.ROLEHR))
                    {
                        Projectdetails.Enabled = true;
                        btnCancel.Visible      = true;
                        if (gvProjectDetails.Rows[0].Cells[0].Text != NO_RECORDS_FOUND_MESSAGE)
                        {
                            btnSave.Visible = true;
                        }
                    }
                    else
                    {
                        Projectdetails.Enabled = false;
                        btnSave.Visible        = false;
                        btnCancel.Visible      = false;
                    }
                }
            }
        }
    }
Exemplo n.º 32
0
 protected bool IsTask(string task, ZOperationResult operationResult)
 {
     return(AuthorizationManager.IsTask("", task, operationResult));
 }
 public SettingsViewModel(AuthorizationManager authorizationManager, IContainer container)
 {
     _authorizationManager = authorizationManager;
     _container = container;
 }
Exemplo n.º 34
0
 protected SimpleJsonHandler(AuthorizationManager manager)
 {
     this.manager = manager;
 }
Exemplo n.º 35
0
 private static TypeInfoDataBase LoadFromFileHelper(Collection<PSSnapInTypeAndFormatErrors> files, MshExpressionFactory expressionFactory, AuthorizationManager authorizationManager, PSHost host, bool preValidated, out List<XmlLoaderLoggerEntry> logEntries, out bool success)
 {
     success = true;
     logEntries = new List<XmlLoaderLoggerEntry>();
     TypeInfoDataBase db = new TypeInfoDataBase();
     AddPreLoadInstrinsics(db);
     foreach (PSSnapInTypeAndFormatErrors errors in files)
     {
         if (errors.FormatData != null)
         {
             using (TypeInfoDataBaseLoader loader = new TypeInfoDataBaseLoader())
             {
                 if (!loader.LoadFormattingData(errors.FormatData, db, expressionFactory))
                 {
                     success = false;
                 }
                 foreach (XmlLoaderLoggerEntry entry in loader.LogEntries)
                 {
                     if (entry.entryType == XmlLoaderLoggerEntry.EntryType.Error)
                     {
                         string item = StringUtil.Format(FormatAndOutXmlLoadingStrings.MshSnapinQualifiedError, errors.PSSnapinName, entry.message);
                         errors.Errors.Add(item);
                     }
                 }
                 logEntries.AddRange(loader.LogEntries);
                 continue;
             }
         }
         XmlFileLoadInfo info = new XmlFileLoadInfo(Path.GetPathRoot(errors.FullPath), errors.FullPath, errors.Errors, errors.PSSnapinName);
         using (TypeInfoDataBaseLoader loader2 = new TypeInfoDataBaseLoader())
         {
             if (!loader2.LoadXmlFile(info, db, expressionFactory, authorizationManager, host, preValidated))
             {
                 success = false;
             }
             foreach (XmlLoaderLoggerEntry entry2 in loader2.LogEntries)
             {
                 if (entry2.entryType == XmlLoaderLoggerEntry.EntryType.Error)
                 {
                     string str2 = StringUtil.Format(FormatAndOutXmlLoadingStrings.MshSnapinQualifiedError, info.psSnapinName, entry2.message);
                     info.errors.Add(str2);
                     if (entry2.failToLoadFile)
                     {
                         errors.FailToLoadFile = true;
                     }
                 }
             }
             logEntries.AddRange(loader2.LogEntries);
         }
     }
     AddPostLoadInstrinsics(db);
     return db;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthorizationManagerTest"/> class.
 /// </summary>
 public AuthorizationManagerTest()
 {
     this.authorizationRepository = new Mock<IAuthorizationServiceRepository>();
     this.authorizationManager = new AuthorizationManager(this.authorizationRepository.Object);
 }
Exemplo n.º 37
0
 internal void UpdateDataBase(Collection<PSSnapInTypeAndFormatErrors> mshsnapins, AuthorizationManager authorizationManager, PSHost host, bool preValidated)
 {
     if (!this.DisableFormatTableUpdates)
     {
         if (this.isShared)
         {
             throw PSTraceSource.NewInvalidOperationException("FormatAndOutXmlLoadingStrings", "SharedFormatTableCannotBeUpdated", new object[0]);
         }
         MshExpressionFactory expressionFactory = new MshExpressionFactory();
         List<XmlLoaderLoggerEntry> logEntries = null;
         this.LoadFromFile(mshsnapins, expressionFactory, false, authorizationManager, host, preValidated, out logEntries);
     }
 }
Exemplo n.º 38
0
 protected internal virtual void configureQuery(HistoricDecisionInstanceQueryImpl query)
 {
     AuthorizationManager.configureHistoricDecisionInstanceQuery(query);
     TenantManager.configureQuery(query);
 }
Exemplo n.º 39
0
 /// <summary>
 /// 验证权限
 /// </summary>
 /// <returns></returns>
 public bool VerifyPermission()
 {
     return(AuthorizationManager.GetInstance().VerifyPermission(this.PermissionId, HttpContext.Current.Session[GlobalConstant.ROLE_KEY].ToString()));
 }
Exemplo n.º 40
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ValidateURL())
        {
            Response.Redirect(CommonConstants.INVALIDURL, false);
        }
        else
        {
            Response.Expires = 0;
            Response.Cache.SetNoStore();
            Response.AppendHeader("Pragma", "no-cache");

            //Umesh: Issue 'Modal Popup issue in chrome' Starts
            //btnCancle.Attributes.Add(CommonConstants.EVENT_ONCLICK, "JavaScript:window.close(); return false;");
            //Umesh: Issue 'Modal Popup issue in chrome' Ends

            btnOK.Attributes.Add("onclick", "return RadioChecked1();");


            if (!IsPostBack)
            {
                Session[SessionNames.CLIENT_NAME] = null;
                Session[SessionNames.PROJECT_SUMMARY_PROJECT_NAME] = null;
                Session[SessionNames.STATUS]       = null;
                Session[SessionNames.PAGENUMBER]   = null;
                Session[SessionNames.FILERCLICKED] = null;

                AuthorizationManager objRaveHRAuthorizationManager = new AuthorizationManager();
                arrRolesForUser = objRaveHRAuthorizationManager.getRolesForUser(objRaveHRAuthorizationManager.getLoggedInUser());
                objProjectCriteria.UserMailId = objRaveHRAuthorizationManager.getLoggedInUser();
                objProjectCriteria.UserMailId = objProjectCriteria.UserMailId.Replace("co.in", "com");

                foreach (string STR in arrRolesForUser)
                {
                    switch (STR)
                    {
                    case AuthorizationManagerConstants.ROLECOO:
                        objProjectCriteria.RoleCOO = AuthorizationManagerConstants.ROLECOO;
                        break;

                    case AuthorizationManagerConstants.ROLEPRESALES:
                        objProjectCriteria.RolePresales = AuthorizationManagerConstants.ROLEPRESALES;
                        break;

                    case AuthorizationManagerConstants.ROLEPROJECTMANAGER:
                        objProjectCriteria.RolePM = AuthorizationManagerConstants.ROLEPROJECTMANAGER;
                        break;

                    case AuthorizationManagerConstants.ROLERPM:
                        objProjectCriteria.RoleRPM = AuthorizationManagerConstants.ROLERPM;
                        break;

                    default:
                        break;
                    }
                }

                FillClientDropDown();

                FillStatusDropDown();

                //Populate the Grid with project details.
                populateGridWithPRojectDetails(1);
            }
        }
    }