Пример #1
0
 /// <summary>
 /// Initializes a new <see cref="AuthScopeItem"/>.
 /// </summary>
 /// <param name="scopeName">The scope name. Can not be empty.</param>
 /// <param name="status">The WAR status.</param>
 /// <param name="statusLastWriteTime">The last write time of the status.</param>
 public AuthScopeItem(string scopeName, ScopeWARStatus status, DateTime statusLastWriteTime)
 {
     if (string.IsNullOrWhiteSpace(scopeName))
     {
         throw new ArgumentException("Scope name can not be empty.");
     }
     ScopeName           = scopeName;
     Status              = status;
     StatusLastWriteTime = statusLastWriteTime;
 }
Пример #2
0
 /// <summary>
 /// Creates a scope set with an optional initial set of scopes.
 /// </summary>
 /// <param name="ctx">The call context.</param>
 /// <param name="actorId">The acting actor identifier.</param>
 /// <param name="scopes">Optional initial scopes.</param>
 /// <param name="scopesHaveStatus">True to handle [W], [A] or [R] prefix from scopes.</param>
 /// <param name="defaultStatus">Initial status of of initial scopes.</param>
 /// <returns>The scope set identifier.</returns>
 public virtual Task <int> CreateScopeSetAsync(ISqlCallContext ctx, int actorId, string scopes = null, bool scopesHaveStatus = false, ScopeWARStatus defaultStatus = ScopeWARStatus.Waiting)
 {
     return(DoCreateScopeSetAsync(ctx, actorId, scopes, scopesHaveStatus, defaultStatus.ToString()[0]));
 }
Пример #3
0
 /// <summary>
 /// Removes all scopes from a scope set that have a specific status.
 /// </summary>
 /// <param name="ctx">The call context.</param>
 /// <param name="actorId">The acting actor identifier.</param>
 /// <param name="scopeSetId">The target scope set identifier.</param>
 /// <param name="status">The status that must match for the scope to be removed.</param>
 /// <returns>The awaitable.</returns>
 public Task RemoveScopesAsync(ISqlCallContext ctx, int actorId, int scopeSetId, ScopeWARStatus status)
 {
     return(DoRemoveScopesAsync(ctx, actorId, scopeSetId, null, false, 'W', status.ToString()[0]));
 }
Пример #4
0
 /// <summary>
 /// Removes the given scopes from a scope set.
 /// </summary>
 /// <param name="ctx">The call context.</param>
 /// <param name="actorId">The acting actor identifier.</param>
 /// <param name="scopeSetId">The target scope set identifier.</param>
 /// <param name="scopes">Whitespace separated list of scopes to remove.</param>
 /// <param name="scopesHaveStatus">True to handle [W], [A] or [R] prefixes from <paramref name="scopes"/>.</param>
 /// <param name="defaultWARStatus">The status ('W', 'A' or 'R') to use when no explicit prefix are handled.</param>
 /// <param name="statusFilter">Optional filter status: only scopes with this status will be removed.</param>
 /// <returns>The awaitable.</returns>
 public Task RemoveScopesAsync(ISqlCallContext ctx, int actorId, int scopeSetId, string scopes, bool scopesHaveStatus, ScopeWARStatus defaultWARStatus = ScopeWARStatus.Waiting, ScopeWARStatus?statusFilter = null)
 {
     return(DoRemoveScopesAsync(ctx, actorId, scopeSetId, scopes, scopesHaveStatus, defaultWARStatus.ToString()[0], statusFilter?.ToString()[0]));
 }
Пример #5
0
 /// <summary>
 /// Sets the scopes of a scope set: existing scopes that do not appear in <paramref name="scopes"/>
 /// are removed.
 /// </summary>
 /// <param name="ctx">The call context.</param>
 /// <param name="actorId">The acting actor identifier.</param>
 /// <param name="scopeSetId">The target scope set identifier.</param>
 /// <param name="scopes">Whitespace separated list of scopes.</param>
 /// <param name="scopesHaveStatus">True to handle [W], [A] or [R] prefixes from <paramref name="scopes"/>.</param>
 /// <param name="defaultWARStatus">The status ('W', 'A' or 'R') to use when no explicit prefix are handled.</param>
 /// <returns>The awaitable.</returns>
 public virtual Task SetScopesAsync(ISqlCallContext ctx, int actorId, int scopeSetId, string scopes, bool scopesHaveStatus, ScopeWARStatus defaultWARStatus = ScopeWARStatus.Waiting)
 {
     return(DoAddOrUpdateScopesAsync(ctx, actorId, scopeSetId, scopes, scopesHaveStatus, defaultWARStatus.ToString()[0], true));
 }
Пример #6
0
 /// <summary>
 /// Checks that all scope names exists and have the given status.
 /// </summary>
 /// <param name="status">Status to check.</param>
 /// <param name="scopes">Names to check.</param>
 /// <returns>True if all the scopes have the given status, false otherwise.</returns>
 public bool CheckStatus(ScopeWARStatus status, IEnumerable <string> scopes)
 {
     return(scopes.All(name => this[name]?.Status == status));
 }
Пример #7
0
 /// <summary>
 /// Checks that all scope names exists and have the given status.
 /// </summary>
 /// <param name="status">Status to check.</param>
 /// <param name="scopes">Names to check.</param>
 /// <returns>True if all the scopes have the given status, false otherwise.</returns>
 public bool CheckStatus(ScopeWARStatus status, params string[] scopes) => CheckStatus(status, (IEnumerable <string>)scopes);
Пример #8
0
 /// <summary>
 /// Removes all scopes from a scope set that have a specific status.
 /// </summary>
 /// <param name="ctx">The call context.</param>
 /// <param name="actorId">The acting actor identifier.</param>
 /// <param name="scopeSetId">The target scope set identifier.</param>
 /// <param name="status">The status that must match for the scope to be removed.</param>
 public void RemoveScopes(ISqlCallContext ctx, int actorId, int scopeSetId, ScopeWARStatus status)
 {
     DoRemoveScopes(ctx, actorId, scopeSetId, null, false, 'W', status.ToString()[0]);
 }
Пример #9
0
 /// <summary>
 /// Sets the scopes of a scope set: existing scopes that do not appear in <paramref name="scopes"/>
 /// are removed.
 /// </summary>
 /// <param name="ctx">The call context.</param>
 /// <param name="actorId">The acting actor identifier.</param>
 /// <param name="scopeSetId">The target scope set identifier.</param>
 /// <param name="scopes">Whitespace separated list of scopes.</param>
 /// <param name="scopesHaveStatus">True to handle [W], [A] or [R] prefixes from <paramref name="scopes"/>.</param>
 /// <param name="defaultWARstatus">The status ('W', 'A' or 'R') to use when no explicit prefix are handled.</param>
 public virtual void SetScopes(ISqlCallContext ctx, int actorId, int scopeSetId, string scopes, bool scopesHaveStatus, ScopeWARStatus defaultWARstatus = ScopeWARStatus.Waiting)
 {
     DoAddScopes(ctx, actorId, scopeSetId, scopes, scopesHaveStatus, defaultWARstatus.ToString()[0], true);
 }
Пример #10
0
 /// <summary>
 /// Initializes a new immutable <see cref="AuthScopeItem"/> (<see cref="StatusLastWriteTime"/> is set to <see cref="Util.UtcMinValue"/>).
 /// </summary>
 /// <param name="scopeName">The scope name. Can not be empty.</param>
 /// <param name="status">The WAR status.</param>
 public AuthScopeItem(string scopeName, ScopeWARStatus status = ScopeWARStatus.Waiting)
     : this(scopeName, status, Util.UtcMinValue)
 {
 }