Improved the security code. Now it won't fail if securing is enabled and the user is not logged: with anonymous users we don't have an UserDetails object but the "anonymous" String, so the older code gave a casting error.
Added methods needed to complete #73536
Merge pull request #117 from luisromangz/73536-NewMethodsNeededByLayerCleaningTask

73536 new methods needed by layer cleaning task