protected void EnsureAuthorization()
{
AuthorizationDemandAttribute claimDemandAttrib = this.Proxy.InterceptedCallMetaData.GetMethodOrClassAttribute <AuthorizationDemandAttribute>();
if (claimDemandAttrib == null)
{
return;
}
this.LogInformationWithKey("Demanded claims/roles", "{0}: {1}",
claimDemandAttrib.DemandAny ? "ANY" : "ALL",
string.Join(", ", claimDemandAttrib.DemandedClaims)
);
if (claimDemandAttrib.IsAuthorized())
{
return;
}
this.Log(EntryType.Warning, "Authorized", false.ToString());
string errorMsg = string.Format("User \"{0}\" is not authorized to call this function.", claimDemandAttrib.Identity.Name);
this.Log(EntryType.Warning, "Authorization Failed", errorMsg);
this.ThrowAuthorizationException(errorMsg);
}