public AuthorizationException(string userId, MissingAuthorization exceptionInfo)
            : base(
                "The user with id '" + userId + "' does not have " + GenerateMissingAuthorizationMessage(exceptionInfo) +
                ".")
        {
            this.userId           = userId;
            MissingAuthorizations = new List <MissingAuthorization>();
            MissingAuthorizations.Add(exceptionInfo);

            resourceType   = exceptionInfo.ResourceType;
            PermissionName = exceptionInfo.ViolatedPermissionName;
            resourceId     = exceptionInfo.ResourceId;
        }
        /// <summary>
        ///     Generated exception message for the missing authorization.
        /// </summary>
        /// <param name="exceptionInfo"> to use </param>
        private static string GenerateMissingAuthorizationMessage(MissingAuthorization exceptionInfo)
        {
            var builder        = new StringBuilder();
            var permissionName = exceptionInfo.ViolatedPermissionName;
            var resourceType   = exceptionInfo.ResourceType;
            var resourceId     = exceptionInfo.ResourceId;

            builder.Append("'");
            builder.Append(permissionName);
            builder.Append("' permission on resource '");
            builder.Append(!ReferenceEquals(resourceId, null) ? resourceId + "' of type '" : "");
            builder.Append(resourceType);
            builder.Append("'");

            return(builder.ToString());
        }