class JaasUtils {

    public static Subject getCurrentSubject() {
        final Subject subject = Subject.getSubject(AccessController.getContext());
        if (subject == null)
            throw new IllegalStateException("No subject found in current context.");

        return subject;
    }

}