Core: refactor

This commit is contained in:
Maksim Chegulov 2022-02-28 12:06:06 +03:00
parent e6f111f651
commit fe15811c8f
5 changed files with 9 additions and 10 deletions

View File

@ -30,9 +30,5 @@ public interface ISecurityObjectId
{
object SecurityId { get; }
Type ObjectType { get; }
string ToString()
{
return AzObjectIdHelper.GetFullObjectId(this);
}
string FullId { get; }
}

View File

@ -30,6 +30,7 @@ public class SecurityObjectId : ISecurityObjectId
{
public object SecurityId { get; private set; }
public Type ObjectType { get; private set; }
public string FullId => AzObjectIdHelper.GetFullObjectId(this);
public SecurityObjectId(object id, Type objType)
{

View File

@ -41,12 +41,12 @@ public class AzRecord : IMapFrom<Acl>
{
}
public AzRecord(Guid subjectId, Guid actionId, AceType reaction, string objectId)
public AzRecord(Guid subjectId, Guid actionId, AceType reaction, string fullId)
{
Subject = subjectId;
Action = actionId;
AceType = reaction;
Object = objectId;
Object = fullId;
}
public static implicit operator AzRecord(AzRecordCache cache)

View File

@ -29,6 +29,7 @@ public class UserSecurityProvider : ISecurityObject
{
public Type ObjectType { get; private set; }
public object SecurityId { get; private set; }
public string FullId => AzObjectIdHelper.GetFullObjectId(this);
public UserSecurityProvider(Guid userId)
{

View File

@ -210,7 +210,7 @@ namespace ASC.Web.Core
// remove old aces
AuthorizationManager.RemoveAllAces(securityObj);
var allowToAll = new AzRecord(ASC.Core.Users.Constants.GroupEveryone.ID, Read.ID, AceType.Allow, securityObj.ToString());
var allowToAll = new AzRecord(ASC.Core.Users.Constants.GroupEveryone.ID, Read.ID, AceType.Allow, securityObj.FullId);
AuthorizationManager.RemoveAce(allowToAll);
// set new aces
@ -225,7 +225,7 @@ namespace ASC.Web.Core
}
foreach (var s in subjects)
{
var a = new AzRecord(s, Read.ID, enabled ? AceType.Allow : AceType.Deny, securityObj.ToString());
var a = new AzRecord(s, Read.ID, enabled ? AceType.Allow : AceType.Deny, securityObj.FullId);
AuthorizationManager.AddAce(a);
}
@ -370,6 +370,8 @@ namespace ASC.Web.Core
get { return WebItemId.ToString("N"); }
}
public string FullId => AzObjectIdHelper.GetFullObjectId(this);
public bool InheritSupported
{
get { return true; }
@ -380,7 +382,6 @@ namespace ASC.Web.Core
get { return false; }
}
public static WebItemSecurityObject Create(string id, WebItemManager webItemManager)
{
if (string.IsNullOrEmpty(id))