public void Demand()
{
IPrincipal principal = Thread.CurrentPrincipal;
if (principal == null)
throw new SecurityException(SR.Security_PrincipalPermission);
if (_idArray == null)
return;
// A demand passes when the grant satisfies all entries.
foreach (IDRole idRole in _idArray)
{
// If the demand is authenticated, we need to check the identity and role
if (!idRole.Authenticated)
{
return;
}
else if (principal.Identity.IsAuthenticated &&
(idRole.ID == null || string.Equals(principal.Identity.Name, idRole.ID, StringComparison.OrdinalIgnoreCase)))
{
if (idRole.Role == null || principal.IsInRole(idRole.Role))
return;
}
}
throw new SecurityException(SR.Security_PrincipalPermission);
}