feat: LdapOptions erstellt anstelle statischer (fest codierter) Konfigurationswerte, LdapOptions und Abhängigkeitsinjektionen dafür hinzugefügt
This commit is contained in:
@@ -8,11 +8,18 @@ using System.Text;
|
||||
|
||||
namespace HRD.LDAPService.JWT
|
||||
{
|
||||
public static class JwtManager
|
||||
public class JwtManager
|
||||
|
||||
{
|
||||
private const string GlbExtendedAttributes = "ExtendedAttributes_";
|
||||
|
||||
private readonly LdapAuthenticationService _ldapAuthService;
|
||||
|
||||
public JwtManager(LdapAuthenticationService ldapAuthService)
|
||||
{
|
||||
_ldapAuthService = ldapAuthService;
|
||||
}
|
||||
|
||||
public static LdapUser DecryptTokenAsLdapUser(string token)
|
||||
{
|
||||
if (string.IsNullOrEmpty(token)) { return default; }
|
||||
@@ -67,7 +74,7 @@ namespace HRD.LDAPService.JWT
|
||||
}
|
||||
}
|
||||
|
||||
public static LdapUser RenewLdapUserWithJwtToken(string token)
|
||||
public LdapUser RenewLdapUserWithJwtToken(string token)
|
||||
{
|
||||
LdapUser renewLdapUser = null;
|
||||
try
|
||||
@@ -77,7 +84,7 @@ namespace HRD.LDAPService.JWT
|
||||
throw new ArgumentNullException($"Token is missing!");
|
||||
}
|
||||
|
||||
renewLdapUser = LdapAuthenticationService.RenewIdentity(token);
|
||||
renewLdapUser = _ldapAuthService.RenewIdentity(token);
|
||||
if (renewLdapUser is null)
|
||||
{
|
||||
throw new Exception($"Can't renew from token!");
|
||||
@@ -110,7 +117,7 @@ namespace HRD.LDAPService.JWT
|
||||
}
|
||||
}
|
||||
|
||||
public static LdapUser RenewLdapUserWithJwtToken(LdapUser ldapUser)
|
||||
public LdapUser RenewLdapUserWithJwtToken(LdapUser ldapUser)
|
||||
{
|
||||
LdapUser renewLdapUser = null;
|
||||
try
|
||||
@@ -120,7 +127,7 @@ namespace HRD.LDAPService.JWT
|
||||
throw new Exception($"Token is missing (Login:{ldapUser.LoginName})");
|
||||
}
|
||||
|
||||
renewLdapUser = LdapAuthenticationService.RenewIdentity(ldapUser);
|
||||
renewLdapUser = _ldapAuthService.RenewIdentity(ldapUser);
|
||||
if (renewLdapUser is null)
|
||||
{
|
||||
return default;
|
||||
@@ -164,11 +171,11 @@ namespace HRD.LDAPService.JWT
|
||||
}
|
||||
}
|
||||
|
||||
public static bool GenerateLdapUserWithJwtToken(LdapUser ldapUser)
|
||||
public bool GenerateLdapUserWithJwtToken(LdapUser ldapUser)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!LdapAuthenticationService.CheckAndUpdateIdentityWithPassword(ldapUser))
|
||||
if (!_ldapAuthService.CheckAndUpdateIdentityWithPassword(ldapUser))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user