public static <SM extends SecurityManager> SM getSecurityManager(Class<SM> type) {
        Objects.requireNonNull(type, "Class argument cannot be null.");
        return unwrapSecurityManager(getSecurityManager(), type);
    }
Returns the SecurityManager, ensuring it is of the specified type.
Unwraps wrapped SecurityManagers if necessary.
Caution, since this method unwraps SecurityManagers, it is possible that
functionality of the wrapper is lost by the returned instance.

@param type the expected type of the SecurityManager
@return the SecurityManager.
@param <SM> the expected type of the SecurityManager
core/src/main/java/org/apache/shiro/SecurityUtils.java