public static <SM extends SecurityManager> SM
    unwrapSecurityManager(SecurityManager securityManager, Class<SM> type) {
        return unwrapSecurityManager(securityManager, type, type::isAssignableFrom);
    }
Unwraps wrapped SecurityManagers if necessary.
@param securityManager the SecurityManager to unwrap
@param type the expected type of the SecurityManager
@return the unwrapped SecurityManager
@param <SM> Type of the SecurityManager
core/src/main/java/org/apache/shiro/SecurityUtils.java