public static Subject getSubject() {
        Subject subject = ThreadContext.getSubject();
        if (subject == null) {
            subject = (new Subject.Builder()).buildSubject();
            ThreadContext.bind(subject);
        }
        return subject;
    }
Returns the currently accessible {@code Subject} available to the calling code depending on
runtime environment.
<p/>
This method is provided as a way of obtaining a {@code Subject} without having to resort to
implementation-specific methods.  It also allows the Shiro team to change the underlying implementation of
this method in the future depending on requirements/updates without affecting your code that uses it.

@return the currently accessible {@code Subject} accessible to the calling code.
@throws IllegalStateException if no {@link Subject Subject} instance or
                              {@link SecurityManager SecurityManager} instance is available with which to obtain
                              a {@code Subject}, which which is considered an invalid application configuration
                              - a Subject should <em>always</em> be available to the caller.
core/src/main/java/org/apache/shiro/SecurityUtils.java