def ensure_security_manager(self, subject_context):
if (subject_context.resolve_security_manager() is not None):<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>logger.debug(msg)<EOL>return subject_context<EOL><DEDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>logger.debug(msg)<EOL>subject_context.security_manager = self<EOL>return subject_context<EOL>
Determines whether there is a ``SecurityManager`` instance in the context,
and if not, adds 'self' to the context.  This ensures that do_create_subject
will have access to a ``SecurityManager`` during Subject construction.

:param subject_context: the subject context data that may contain a
                        SecurityManager instance
:returns: the SubjectContext