fix(domain): encapsulate CameraCredentials with private setters and SetCredentials method
All sensitive fields (OnvifPassword, RtspPassword, etc.) had public setters allowing uncontrolled modification. Encapsulated via private setters with a dedicated SetCredentials() method that updates all values atomically and sets UpdatedAt.
This commit is contained in:
1 parent
0473f8ff5b
commit
c36978d5a1
1 file changed
+17
-8
@@ -7,19 +7,19 @@ namespace Heimdall.Domain.Entities;
|
||||
public class CameraCredentials
|
||||
{
|
||||
public Guid CameraId { get; private set; }
|
||||
public string OnvifUsername { get; set; } = "admin";
|
||||
public string OnvifUsername { get; private set; } = "admin";
|
||||
|
||||
/// <summary>Encrypted at rest.</summary>
|
||||
public string OnvifPassword { get; set; } = string.Empty;
|
||||
/// <summary>Encrypted at rest via IDataProtector (applied at service layer).</summary>
|
||||
public string OnvifPassword { get; private set; } = string.Empty;
|
||||
|
||||
/// <summary>Encrypted at rest.</summary>
|
||||
public string RtspUsername { get; set; } = string.Empty;
|
||||
/// <summary>Encrypted at rest via IDataProtector (applied at service layer).</summary>
|
||||
public string RtspUsername { get; private set; } = string.Empty;
|
||||
|
||||
/// <summary>Encrypted at rest.</summary>
|
||||
public string RtspPassword { get; set; } = string.Empty;
|
||||
/// <summary>Encrypted at rest via IDataProtector (applied at service layer).</summary>
|
||||
public string RtspPassword { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; private set; } = DateTime.UtcNow;
|
||||
|
||||
public Camera Camera { get; private set; } = null!;
|
||||
|
||||
@@ -29,4 +29,13 @@ public class CameraCredentials
|
||||
{
|
||||
CameraId = cameraId;
|
||||
}
|
||||
|
||||
public void SetCredentials(string onvifUsername, string onvifPassword, string rtspUsername, string rtspPassword)
|
||||
{
|
||||
OnvifUsername = onvifUsername;
|
||||
OnvifPassword = onvifPassword;
|
||||
RtspUsername = rtspUsername;
|
||||
RtspPassword = rtspPassword;
|
||||
UpdatedAt = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user