Make important security entities Serializable

Partially related to issue #3061 
Please approve PR