Exemple #1
0
 /// <summary>
 /// If a class does not exist get for this group, then one is added to the set
 /// </summary>
 /// <param name="groupName"></param>
 internal void EnsureRoleManagerExistsForRole(
     string groupName,
     ProvisioningGroup.GrantLicenseMode ifCreateGrantLicenseMode,
     string ifCreateGrantLicenseRole)
 {
     GetManagerForGroup_CreateIfNeeded(groupName, ifCreateGrantLicenseMode, ifCreateGrantLicenseRole);
 }
Exemple #2
0
    /// <summary>
    /// Return the group manager for the group
    /// </summary>
    /// <param name="group"></param>
    /// <param name="ifCreateGrantLicenseMode">If a group needs to be created, give it this Grant License Mode</param>
    /// <param name="ifCreateGrantLicenseRole">If the group needs to be created, give it this Grant License Role</param>
    /// <returns></returns>
    public SingleGroupManager GetManagerForGroup_CreateIfNeeded(
        string group,
        ProvisioningGroup.GrantLicenseMode ifCreateGrantLicenseMode,
        string ifCreateGrantLicenseRole)
    {
        var cannonicalGroup = group.ToLower();
        SingleGroupManager thisGroupManager;

        //Prevent this from getting entered my multiple threads
        lock (_threadLock_ModifyGroupsList)
        {
            //Add the user to a group manager
            _groupsManager.TryGetValue(cannonicalGroup, out thisGroupManager);

            if (thisGroupManager == null)
            {
                thisGroupManager = new SingleGroupManager(group, ifCreateGrantLicenseMode, ifCreateGrantLicenseRole);
                _groupsManager.Add(cannonicalGroup, thisGroupManager);
            }
            else
            {
                //Check to see if this definition of the group specifies a BETTER Grant License behavior,
                //if so, apply that
                thisGroupManager.ConsiderGrantLicenseRoleUpgrade(ifCreateGrantLicenseMode, ifCreateGrantLicenseRole);
            }
        }
        return(thisGroupManager);
    }
Exemple #3
0
 /// <summary>
 /// Parse the Grant license text returned
 /// </summary>
 /// <param name="text"></param>
 /// <returns></returns>
 ProvisioningGroup.GrantLicenseMode AttemptParseGrantLicenseText(string text)
 {
     //var parseGrantLicenseMode
     ProvisioningGroup.GrantLicenseMode grantLicenseMode = ProvisioningGroup.GrantLicenseMode.Ignore;
     try
     {
         return(ProvisioningGroup.ParseGrantLicenseModeFromTableauServer(text));
     }
     catch (Exception ex)
     {
         //Note the error -- but it is not fatal for our purposes
         IwsDiagnostics.Assert(false, "1012-528: Unknown grant license mode parsing error, " + ex.Message);
         return(grantLicenseMode);
     }
 }
Exemple #4
0
        /// <summary>
        /// Called if a Group comes up more than once in provisioning (e.g. multiple wildcard matches)
        /// If so, then we consider promoting the group to the higer of the two roles
        /// </summary>
        /// <param name="suggestedMode"></param>
        /// <param name="suggestedSiteRole"></param>
        public bool ConsiderGrantLicenseRoleUpgrade(ProvisioningGroup.GrantLicenseMode suggestedMode, string suggestedSiteRole)
        {
            string currentRole = _grantLicenseRole;
            var    currentMode = _grantLicenseInstructions;

            //-------------------------------------------------------------------------
            //See if the suggested state is once that we need to act on.
            //-------------------------------------------------------------------------
            switch (suggestedMode)
            {
            case ProvisioningGroup.GrantLicenseMode.Ignore:
                return(false);    //Do nothing

            case ProvisioningGroup.GrantLicenseMode.None:
                return(false);    //Do nothing

            case ProvisioningGroup.GrantLicenseMode.OnLogin:
                break;   //Advance onward....

            default:     //Degenerate case
                IwsDiagnostics.Assert(false, "1021-106: Unknown grant license mode, " + suggestedMode.ToString());
                throw new Exception("1021-106: Unknown grant license mode, " + suggestedMode.ToString());
            }

            //-------------------------------------------------------------------------
            //Based on the current state, take the approprate action
            //-------------------------------------------------------------------------
            switch (currentMode)
            {
            case ProvisioningGroup.GrantLicenseMode.Ignore:
                //Apply the new mode
                _grantLicenseInstructions = suggestedMode;
                _grantLicenseRole         = suggestedSiteRole;
                return(true);

            case ProvisioningGroup.GrantLicenseMode.None:
                //Apply the new mode
                _grantLicenseInstructions = suggestedMode;
                _grantLicenseRole         = suggestedSiteRole;
                return(true);

            case ProvisioningGroup.GrantLicenseMode.OnLogin:
                //Apply the new mode if it ranks higher
                if (ProvisioningUser.CalculateRoleRank(currentRole) >=
                    ProvisioningUser.CalculateRoleRank(suggestedSiteRole))
                {
                    //The current role ranks above/same as the suggested role.  Do nothing
                    return(false);
                }
                else
                {
                    //Apply the new mode
                    _grantLicenseInstructions = suggestedMode;
                    _grantLicenseRole         = suggestedSiteRole;
                    return(true);
                }

            default:     //Degenerate case
                IwsDiagnostics.Assert(false, "1021-113: Unknown grant license mode, " + currentMode.ToString());
                throw new Exception("1021-113: Unknown grant license mode, " + currentMode.ToString());
            }
        }
Exemple #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="group"></param>
 public SingleGroupManager(string group, ProvisioningGroup.GrantLicenseMode grantLicenseMode, string grantLicenseRole)
 {
     this.GroupName            = group;
     _grantLicenseInstructions = grantLicenseMode;
     _grantLicenseRole         = grantLicenseRole;
 }