Exemple #1
0
 public Authentication(ScopeEnum scope)
 {
     this.scope              = scope.ToString();
     _httpClient             = new HttpClient();
     _httpClient.BaseAddress = new Uri(KingdeeConfig.Host);
     //_httpClient.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
 }
Exemple #2
0
        public IList <SecurableObject> GetSecurableObjects(object o, bool includeSite, bool includeListAndLibrary, bool includeFolder, bool includeItem, bool includeInherited)
        {
            ScopeEnum scope = ScopeEnum.None;
            string    url   = string.Empty;

            if (o is SPWebApplication)
            {
                scope = ScopeEnum.WebApplication;
                url   = SquadronContext.Url;
            }

            else if (o is SPSite)
            {
                scope = ScopeEnum.SiteCollection;
                url   = (o as SPSite).Url;
            }

            else if (o is SPWeb)
            {
                scope = ScopeEnum.Site;
                url   = (o as SPWeb).Url;
            }

            else
            {
                throw new ApplicationException("Invalid Object in GetSecurableObjects!");
            }

            return(GetSecurableObjects(url, scope, includeSite, includeListAndLibrary, includeFolder, includeItem, includeInherited));
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Volume" /> class.
 /// </summary>
 /// <param name="name">Name of the volume. (required).</param>
 /// <param name="driver">Name of the volume driver used by the volume. (required).</param>
 /// <param name="mountpoint">Mount path of the volume on the host. (required).</param>
 /// <param name="createdAt">Date/Time the volume was created..</param>
 /// <param name="status">Low-level details about the volume, provided by the volume driver. Details are returned as a map with key/value pairs: &#x60;{\&quot;key\&quot;:\&quot;value\&quot;,\&quot;key2\&quot;:\&quot;value2\&quot;}&#x60;.  The &#x60;Status&#x60; field is optional, and is omitted if the volume driver does not support this feature. .</param>
 /// <param name="labels">User-defined key/value metadata. (required).</param>
 /// <param name="scope">The level at which the volume exists. Either &#x60;global&#x60; for cluster-wide, or &#x60;local&#x60; for machine level. (required) (default to ScopeEnum.Local).</param>
 /// <param name="options">The driver specific options used when creating the volume. (required).</param>
 /// <param name="usageData">usageData.</param>
 public Volume(string name = default(string), string driver = default(string), string mountpoint = default(string), string createdAt = default(string), Dictionary <string, Object> status = default(Dictionary <string, Object>), Dictionary <string, string> labels = default(Dictionary <string, string>), ScopeEnum scope = ScopeEnum.Local, Dictionary <string, string> options = default(Dictionary <string, string>), VolumeUsageData usageData = default(VolumeUsageData))
 {
     // to ensure "name" is required (not null)
     if (name == null)
     {
         throw new InvalidDataException("name is a required property for Volume and cannot be null");
     }
     else
     {
         this.Name = name;
     }
     // to ensure "driver" is required (not null)
     if (driver == null)
     {
         throw new InvalidDataException("driver is a required property for Volume and cannot be null");
     }
     else
     {
         this.Driver = driver;
     }
     // to ensure "mountpoint" is required (not null)
     if (mountpoint == null)
     {
         throw new InvalidDataException("mountpoint is a required property for Volume and cannot be null");
     }
     else
     {
         this.Mountpoint = mountpoint;
     }
     // to ensure "labels" is required (not null)
     if (labels == null)
     {
         throw new InvalidDataException("labels is a required property for Volume and cannot be null");
     }
     else
     {
         this.Labels = labels;
     }
     // to ensure "scope" is required (not null)
     if (scope == null)
     {
         throw new InvalidDataException("scope is a required property for Volume and cannot be null");
     }
     else
     {
         this.Scope = scope;
     }
     // to ensure "options" is required (not null)
     if (options == null)
     {
         throw new InvalidDataException("options is a required property for Volume and cannot be null");
     }
     else
     {
         this.Options = options;
     }
     this.CreatedAt = createdAt;
     this.Status    = status;
     this.UsageData = usageData;
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateInboxRulesetOptions" /> class.
 /// </summary>
 /// <param name="scope">What type of emails actions to apply ruleset to. Either &#x60;SENDING_EMAILS&#x60; or &#x60;RECEIVING_EMAILS&#x60; will apply action and target to any sending or receiving of emails respectively. (required).</param>
 /// <param name="action">Action to be taken when the ruleset matches an email for the given scope. For example: &#x60;BLOCK&#x60; action with target &#x60;*&#x60; and scope &#x60;SENDING_EMAILS&#x60; blocks sending to all recipients. Note &#x60;ALLOW&#x60; takes precedent over &#x60;BLOCK&#x60;. &#x60;FILTER_REMOVE&#x60; is like block but will remove offending email addresses during a send or receive event instead of blocking the action. (required).</param>
 /// <param name="target">Target to match emails with. Can be a wild-card type pattern or a valid email address. For instance &#x60;*@gmail.com&#x60; matches all gmail addresses while &#x60;[email protected]&#x60; matches one address exactly. The target is applied to every recipient field email address when &#x60;SENDING_EMAILS&#x60; is the scope and is applied to sender of email when &#x60;RECEIVING_EMAILS&#x60;. (required).</param>
 public CreateInboxRulesetOptions(ScopeEnum scope = default(ScopeEnum), ActionEnum action = default(ActionEnum), string target = default(string))
 {
     this.Scope  = scope;
     this.Action = action;
     // to ensure "target" is required (not null)
     this.Target = target ?? throw new ArgumentNullException("target is a required property for CreateInboxRulesetOptions and cannot be null");
 }
Exemple #5
0
 public bool Equals(ScopeEnum obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value));
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentAttribute"/> class,
 /// marking the decorated class as a component that will be available from
 /// the component container using the specified <paramref name="registerAs" /> types.
 /// </summary>
 /// <param name="registerAs">The type to use to register the decorated component.</param>;
 /// <param name="implicitRegistrationType">Flag how to do the implicit registration when no types are explicitly defined</param>
 /// <param name="scope">The instance scope</param>
 private ComponentAttribute(
     Type[] registerAs = null,
     ImplicitRegistrationTypeEnum?implicitRegistrationType = ImplicitRegistrationTypeEnum.SelfAndImplementedInterfaces,
     ScopeEnum scope = ScopeEnum.Transient)
 {
     RegisterAs = registerAs;
     ImplicitRegistrationType = implicitRegistrationType;
     Scope = scope;
 }
Exemple #7
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ShieldToken" /> class.
        /// </summary>
        /// <param name="iss">
        ///     The RegShield system issuing this ShieldToken. See [issuer
        ///     claim](https://tools.ietf.org/html/rfc7519#section-4.1.1) (required).
        /// </param>
        /// <param name="sub">
        ///     Client-ID which requested this ShieldToken. See [subject
        ///     claim](https://tools.ietf.org/html/rfc7519#section-4.1.2) (required).
        /// </param>
        /// <param name="aud">
        ///     The intended audience (RegGUI client-ID). See [audience
        ///     claim](https://tools.ietf.org/html/rfc7519#section-4.1.3) (required).
        /// </param>
        /// <param name="exp">
        ///     The expiration time of the token as epoch time. See [expiration time
        ///     claim](https://tools.ietf.org/html/rfc7519#section-4.1.4) (required).
        /// </param>
        /// <param name="jti">
        ///     Unique identifier of the ShieldToken. See [JWT ID](https://tools.ietf.org/html/rfc7519#section-4.1.7)
        ///     (required).
        /// </param>
        /// <param name="scope">The requested RegShield access scope. (required).</param>
        /// <param name="subName">The name associated with the client. (required).</param>
        /// <param name="state">The state included in the request. (required).</param>
        /// <param name="redirectUri">The redirect endpoint URL included in the request. (required).</param>
        public ShieldToken(string iss      = default, string sub     = default, string aud   = default, decimal exp = default, string jti = default,
                           ScopeEnum scope = default, string subName = default, string state = default, string redirectUri = default)
        {
            this.Iss = iss ?? throw new InvalidDataException("iss is a required property for ShieldToken and cannot be null");
            this.Sub = sub ?? throw new InvalidDataException("sub is a required property for ShieldToken and cannot be null");
            this.Aud = aud ?? throw new InvalidDataException("aud is a required property for ShieldToken and cannot be null");
            this.Exp = exp;
            this.Jti = jti ?? throw new InvalidDataException("jti is a required property for ShieldToken and cannot be null");

            this.Scope       = scope;
            this.SubName     = subName ?? throw new InvalidDataException("subName is a required property for ShieldToken and cannot be null");
            this.State       = state ?? throw new InvalidDataException("state is a required property for ShieldToken and cannot be null");
            this.RedirectUri = redirectUri ?? throw new InvalidDataException("redirectUri is a required property for ShieldToken and cannot be null");
        }
        public IEnumerable <DeviceDTO> GetDevices(
            StatusEnum status = StatusEnum.All,
            ScopeEnum scope   = ScopeEnum.All,
            Guid?userId       = null)
        {
            IQueryable <Device> query;

            if (userId.HasValue)
            {
                query = this.dbContext.Devices
                        .Where(d => d.UserId == userId.Value);
            }
            else
            {
                query = this.dbContext.Devices;
            }

            query = query.Where(d => d.IsDeleted == false);

            if (status == StatusEnum.Deactivated)
            {
                query = query.Where(d => d.IsActivated == false);
            }
            else if (status == StatusEnum.Activated)
            {
                query = query.Where(d => d.IsActivated == true);
            }

            if (scope == ScopeEnum.Private)
            {
                query = query.Where(d => d.IsPublic == false);
            }
            else if (scope == ScopeEnum.Public)
            {
                query = query.Where(d => d.IsPublic == true);
            }

            var devices = query
                          .Include(d => d.User)
                          .Include(d => d.DeviceSensors)
                          .ThenInclude(r => r.Sensor)
                          .Select(d => new DeviceDTO(d)).ToList();

            return(devices);
        }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentAttribute"/> class,
 /// marking the decorated class as a component that will be available from
 /// the component container, registered as the concrete type or with all
 /// implemented interfaces as well if specified.
 /// </summary>
 /// <param name="implicitRegistrationType">Flag how to do the implicit registration when no types are explicitly defined</param>
 /// <param name="scope">The instance scope</param>
 public ComponentAttribute(
     ImplicitRegistrationTypeEnum implicitRegistrationType = ImplicitRegistrationTypeEnum.Self,
     ScopeEnum scope = ScopeEnum.Transient)
     : this(null, implicitRegistrationType, scope)
 {
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentAttribute"/> class,
 /// marking the decorated class as a component that will be available from
 /// the component container using the specified <paramref name="registerAs" /> types.
 /// </summary>
 /// <param name="registerAs">The type to use to register the decorated component.</param>;
 /// <param name="scope">The instance scope</param>
 public ComponentAttribute(Type[] registerAs, ScopeEnum scope = ScopeEnum.Transient) : this(registerAs, null, scope)
 {
 }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentAttribute"/> class,
 /// marking the decorated class as a component that will be available from
 /// the component container using the specified <paramref name="registerAs" /> type.
 /// </summary>
 /// <param name="registerAs">The type to use to register the decorated component.</param>;
 /// <param name="scope">The instance scope</param>
 public ComponentAttribute(Type registerAs, ScopeEnum scope = ScopeEnum.Transient) : this(new[] { registerAs }, null, scope)
 {
 }
Exemple #12
0
        public IList <e.Permission> GetPermissions(string searchLoginName, string searchUrl, ScopeEnum scope, bool exactMatch, bool checkGroup, bool checkDisplayName)
        {
            IList <e.Permission> result = new List <e.Permission>();

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                var securableObjects = _securableObjectEnumerator.GetSecurableObjects(searchUrl, scope, true, true, true, true, false);
                foreach (SecurableObject so in securableObjects)
                {
                    if (so.InternalObject is SPWeb)
                    {
                        SPWeb web = (so.InternalObject as SPWeb);

                        if (web.HasUniqueRoleAssignments)
                        {
                            CheckAndAddUsers(result, web, searchLoginName, exactMatch, checkGroup, checkDisplayName);
                        }
                    }

                    else if (so.InternalObject is SPList)
                    {
                        SPList list = (so.InternalObject as SPList);

                        if (list.HasUniqueRoleAssignments)
                        {
                            CheckAndAddUsers(result, list, searchLoginName, exactMatch, checkGroup, checkDisplayName);
                        }
                    }

                    else if (so.InternalObject is SPListItem)
                    {
                        SPListItem item = (so.InternalObject as SPListItem);

                        if (item.HasUniqueRoleAssignments)
                        {
                            CheckAndAddUsers(result, item, searchLoginName, exactMatch, checkGroup, checkDisplayName);
                        }
                    }
                }
            });

            return(result);
        }
Exemple #13
0
        public IList <SecurableObject> GetSecurableObjects(string url, ScopeEnum scope, bool includeSite, bool includeListAndLibrary, bool includeFolder, bool includeItem, bool includeInherited)
        {
            _securableObjects = new List <SecurableObject>();

            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    if (scope == ScopeEnum.WebApplication)
                    {
                        SPWebApplication webApplication = SPWebApplication.Lookup(new Uri(url));

                        foreach (SPSite site in webApplication.Sites)
                        {
                            // Site
                            if (includeSite)
                            {
                                GetWebSites(site, includeInherited, null);
                            }

                            // List
                            if (includeListAndLibrary)
                            {
                                GetLists(site, includeInherited);
                            }

                            // Folder
                            if (includeFolder)
                            {
                                GetFolders(site, includeInherited);
                            }

                            // List Item
                            if (includeItem)
                            {
                                GetListItems(site, includeInherited);
                            }
                        }
                    }

                    else if (scope == ScopeEnum.SiteCollection)
                    {
                        using (SPSite site = new SPSite(url))
                        {
                            // Site
                            if (includeSite)
                            {
                                GetWebSites(site, includeInherited, null);
                            }

                            // List
                            if (includeListAndLibrary)
                            {
                                GetLists(site, includeInherited);
                            }

                            // Folder
                            if (includeFolder)
                            {
                                GetFolders(site, includeInherited);
                            }

                            // List Item
                            if (includeItem)
                            {
                                GetListItems(site, includeInherited);
                            }
                        }
                    }

                    else if (scope == ScopeEnum.Site)
                    {
                        using (SPSite site = new SPSite(url))
                        {
                            foreach (SPWeb web in site.AllWebs)
                            {
                                if (Helper.Instance.AreUrlsEqual(web.Url, url))
                                {
                                    // Site
                                    if (includeSite)
                                    {
                                        GetWebSites(site, includeInherited, web);
                                    }

                                    // List
                                    if (includeListAndLibrary)
                                    {
                                        GetLists(site, includeInherited);
                                    }

                                    // Folder
                                    if (includeFolder)
                                    {
                                        GetFolders(site, includeInherited);
                                    }

                                    // List Item
                                    if (includeItem)
                                    {
                                        GetListItems(site, includeInherited);
                                    }
                                }
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                SquadronContext.HandleException(ex);
            }

            return(_securableObjects);
        }
Exemple #14
0
 public string ObtainAccessTokenFromUsernamePassword(string username, string password, ScopeEnum scope)
 {
     // Make request based on username/password
     return(ObtainAccessToken(new Dictionary <string, object>
     {
         { "grant_type", "password" },
         { "username", username },
         { "password", password },
         { "scope", scope.GetDescription() }
     }));
 }
Exemple #15
0
 public string ObtainAccessTokenFromAuthorizationCode(string code, string redirectUri, ScopeEnum scope)
 {
     // Make request based on token
     return(ObtainAccessToken(new Dictionary <string, object>
     {
         { "grant_type", "authorization_code" },
         { "code", code },
         { "redirect_uri", redirectUri },
         { "scope", scope.GetDescription() }
     }));
 }
Exemple #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InboxRulesetDto" /> class.
 /// </summary>
 /// <param name="id">id (required).</param>
 /// <param name="inboxId">inboxId (required).</param>
 /// <param name="scope">scope (required).</param>
 /// <param name="action">action (required).</param>
 /// <param name="target">target (required).</param>
 /// <param name="handler">handler (required).</param>
 /// <param name="createdAt">createdAt (required).</param>
 public InboxRulesetDto(Guid id = default(Guid), Guid inboxId = default(Guid), ScopeEnum scope = default(ScopeEnum), ActionEnum action = default(ActionEnum), string target = default(string), HandlerEnum handler = default(HandlerEnum), DateTime createdAt = default(DateTime))
 {
     this.Id      = id;
     this.InboxId = inboxId;
     this.Scope   = scope;
     this.Action  = action;
     // to ensure "target" is required (not null)
     this.Target    = target ?? throw new ArgumentNullException("target is a required property for InboxRulesetDto and cannot be null");
     this.Handler   = handler;
     this.CreatedAt = createdAt;
 }
Exemple #17
0
 public static IServiceCollection AddInstance(
     ScopeEnum scopeType, IServiceCollection services, Type implementType)
 => scopeType switch
 {
 public ServiceAttribute(Type interfaceType = null, ScopeEnum scope = ScopeEnum.Scope)
 {
     InterfaceType = interfaceType;
     ScopeType     = scope;
 }
Exemple #19
0
        public HashSet <SPPrincipal> GetPrincipals(string url, ScopeEnum scope)
        {
            if (scope == ScopeEnum.None)
            {
                throw new ApplicationException("Invalid Scope!");
            }

            HashSet <SPPrincipal> result = new HashSet <SPPrincipal>();

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                if (scope == ScopeEnum.WebApplication)
                {
                    SPWebApplication webApplication = SPWebApplication.Lookup(new Uri(url));

                    foreach (SPSite site in webApplication.Sites)
                    {
                        foreach (SPWeb web in site.AllWebs)
                        {
                            foreach (SPUser user in web.AllUsers)
                            {
                                if (!result.Any(p => p.LoginName == user.LoginName))
                                {
                                    result.Add(user);
                                }
                            }
                        }
                    }
                }

                else if (scope == ScopeEnum.SiteCollection)
                {
                    using (SPSite site = new SPSite(url))
                    {
                        foreach (SPWeb web in site.AllWebs)
                        {
                            foreach (SPUser user in web.AllUsers)
                            {
                                if (!result.Any(p => p.LoginName == user.LoginName))
                                {
                                    result.Add(user);
                                }
                            }
                        }
                    }
                }

                else if (scope == ScopeEnum.Site)
                {
                    using (SPSite site = new SPSite(url))
                    {
                        foreach (SPWeb web in site.AllWebs)
                        {
                            if (Helper.Instance.AreUrlsEqual(web.Url, url))
                            {
                                foreach (SPUser user in web.AllUsers)
                                {
                                    if (!result.Any(p => p.LoginName == user.LoginName))
                                    {
                                        result.Add(user);
                                    }
                                }
                            }
                        }
                    }
                }
            });

            return(result);
        }
Exemple #20
0
 public BaseController(ScopeEnum scope)
 {
     _Authentication = new Authentication(scope);
 }