Avoid NullPointerExceptions for null accounts in SecurityFunctions

Wraps the return value of getAuthenticatedAccount in an Optional to enforce understanding that it may be null.