自建controller 报错

image

按这个配的https://doc.cuba-platform.com/manual-6.9/rest_api_v2_custom_auth.html

看错误描述是没有设置 security context 。参见:

我是想把文件下载接口重新了,然后就报这个错误了,security context 也设置了
image

不是setAuthorizationRequired,是下面这段:

        TrustedClientService trustedClientService = (TrustedClientService) AppBeans.get(TrustedClientService.NAME);
        UserSession systemSession = null;
        try{
            systemSession = trustedClientService.getSystemSession(AppBeans.get(Configuration.class).getConfig(WebAuthConfig.class).getTrustedClientPassword());
        }catch (LoginException e){
            logger.error("Unable to obtain system session", e);
        }
        AppContext.withSecurityContext(new SecurityContext(systemSession), () ->{
            //在这里访问数据
        });
    }

已解决