Java 如何保护CF中的应用程序编程模型

Java 如何保护CF中的应用程序编程模型,java,s4sdk,Java,S4sdk,在我完成深度潜水之后 ,我已尝试使用本系列第7步中的说明保护该应用程序 我对获取用户感兴趣,所以修改了查询服务 @Query(serviceName = "CrudService", entity = "BusinessPartner") public QueryResponse queryCustomers(QueryRequest qryRequest) { final User currentUser = UserAccessor.getCurrentUser

在我完成深度潜水之后 ,我已尝试使用本系列第7步中的说明保护该应用程序

我对获取用户感兴趣,所以修改了查询服务

    @Query(serviceName = "CrudService", entity = "BusinessPartner")
    public QueryResponse queryCustomers(QueryRequest qryRequest) {
       final User currentUser = UserAccessor.getCurrentUser();
       System.out.println("User: " + currentUser);

       List<BusinessPartner> businessPartners = new BusinessPartnerReadCommand(new ErpConfigContext(),
            qryRequest.getTopOptionValue(), qryRequest.getSkipOptionValue(), qryRequest.getSelectProperties(),
            qryRequest.getOrderByProperties()).execute();

        QueryResponse queryResponse = QueryResponse.setSuccess().setData(businessPartners).response();
    return queryResponse;
}
@Query(serviceName=“CrudService”,entity=“BusinessPartner”)
公共查询响应查询客户(QueryRequest qryRequest){
最终用户currentUser=UserAccessor.getCurrentUser();
System.out.println(“用户:+currentUser”);
List businessPartners=新建BusinessPartnerReadCommand(新建ErpConfigContext(),
qryRequest.getTopOptionValue(),qryRequest.getSkipOptionValue(),qryRequest.getSelectProperties(),
qryRequest.getOrderByProperties()).execute();
QueryResponse QueryResponse=QueryResponse.setSuccess().setData(businessPartners.response();
返回queryResponse;
}
但是,在我通过approuter登录后,输入我的凭据,它会显示获取当前用户失败的错误:用户未通过身份验证

为什么它不允许我在登录approuter时获取UserAccessor.getCurrentUser()

这是我的github链接:

更新:日志已添加

2018-08-20T05:44:29.139+0000 [APP/PROC/WEB/0] OUT > approuter@1.0.0 start /home/vcap/app
2018-08-20T05:44:29.140+0000 [APP/PROC/WEB/0] OUT > node node_modules/@sap/approuter/approuter.js
2018-08-20T05:44:29.497+0000 [APP/PROC/WEB/0] OUT #2.0#2018 08 20 05:44:29:494#+00:00#WARNING#/LoggingLibrary################PLAIN##Dynamic log level switching not available#
2018-08-20T05:44:29.756+0000 [APP/PROC/WEB/0] OUT #2.0#2018 08 20 05:44:29:756#+00:00#INFO#/approuter################PLAIN##Application router version 5.6.3#
2018-08-20T05:44:29.772+0000 [APP/PROC/WEB/0] OUT #2.0#2018 08 20 05:44:29:772#+00:00#INFO#/Configuration################PLAIN##xs-app.json: Application does not have directory for static resources!#
2018-08-20T05:44:29.792+0000 [APP/PROC/WEB/0] OUT #2.0#2018 08 20 05:44:29:792#+00:00#ERROR#/token-utils################PLAIN##can't get access token to html5 applications repository runtime service :
2018-08-20T05:44:29.792+0000 [APP/PROC/WEB/0] OUT  [Error: html5-repo-credentials: Invalid type: null (expected object)]#
2018-08-20T05:44:29.803+0000 [APP/PROC/WEB/0] OUT #2.0#2018 08 20 05:44:29:803#+00:00#INFO#/approuter################PLAIN##Application router is listening on port: 8080#
2018-08-20T05:44:30.713+0000 [CELL/0] OUT Container became healthy
2018-08-20T05:52:34.552+0000 [RTR/6] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:34.544+0000] "GET / HTTP/1.1" 302 0 0 "https://account.hanatrial.ondemand.com/cockpit" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"4b864872-f2e8-408f-7acf-76807660a4c9" response_time:0.007873407 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"be36659af8148316" x_b3_spanid:"be36659af8148316" x_b3_parentspanid:"-"

2018-08-20T05:52:34.806+0000 [RTR/7] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:34.791+0000] "GET /index.html HTTP/1.1" 200 0 667 "https://account.hanatrial.ondemand.com/cockpit" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"ab9fd18e-ee18-4a32-7246-21b2d2328b17" response_time:0.01440516 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"217f9f15ac4efb02" x_b3_spanid:"217f9f15ac4efb02" x_b3_parentspanid:"-"

2018-08-20T05:52:34.810+0000 [APP/PROC/WEB/0] OUT #2.0#2018 08 20 05:52:34:809#+00:00#INFO#/Auth/OAuth2#########iIr1URai6N8Fuw2lXip84QQsHwL2At3p######ab9fd18e-ee18-4a32-7246-21b2d2328b17#PLAIN##sending page with client-side redirect to https://<S-userID>trial.authentication.us10.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-srv-trial!t1085&redirect_uri=https%3A%2F%2F<S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com%2Flogin%2Fcallback#
2018-08-20T05:52:36.394+0000 [RTR/0] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:36.129+0000] "GET /login/callback?code=tVzjsTi4Dx HTTP/1.1" 302 0 0 "https://<S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"ee3b4a5a-e516-449d-6c2d-19a6b0807290" response_time:0.264528818 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"3bdde9c593640d7a" x_b3_spanid:"3bdde9c593640d7a" x_b3_parentspanid:"-"

2018-08-20T05:52:37.241+0000 [RTR/5] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:36.630+0000] "GET /index.html HTTP/1.1" 200 0 130 "https://<S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"abf37d40-60a4-4e2b-401c-6681496dde90" response_time:0.610696859 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"c263e6426f743085" x_b3_spanid:"c263e6426f743085" x_b3_parentspanid:"-"

2018-08-20T05:52:37.628+0000 [RTR/5] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:37.581+0000] "GET /odata/v2/ HTTP/1.1" 200 0 272 "https://<S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"4f25431d-6dcb-428c-632c-f6c3b552735e" response_time:0.046654482 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"7910f69eb99867d5" x_b3_spanid:"7910f69eb99867d5" x_b3_parentspanid:"-"

2018-08-20T05:52:39.796+0000 [RTR/4] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:39.461+0000] "GET /odata/v2/CrudService HTTP/1.1" 200 0 382 "https://<S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/odata/v2/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"1597c70b-ba9f-4f51-50c9-6a1824357a96" response_time:0.33434942 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"6446d121365bf3e3" x_b3_spanid:"6446d121365bf3e3" x_b3_parentspanid:"-"

2018-08-20T05:52:46.325+0000 [RTR/7] OUT <S-userID>trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com - [2018-08-20T05:52:46.196+0000] "GET /odata/v2/CrudService/BusinessPartner?$top=1 HTTP/1.1" 500 0 690 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" "-" "10.0.73.48:61203" x_forwarded_for:"-" x_forwarded_proto:"https" vcap_request_id:"6f2914a8-165e-4ca8-7a02-5c00ed07e7c8" response_time:0.129068343 app_id:"c994cd7b-bc35-4459-b72e-49e5eb9ec849" app_index:"0" x_b3_traceid:"723916a7a592ec08" x_b3_spanid:"723916a7a592ec08" x_b3_parentspanid:"-"
2018-08-20T05:44:29.139+0000[APP/PROC/WEB/0]OUT>approuter@1.0.0启动/主页/vcap/应用程序
2018-08-20T05:44:29.140+0000[APP/PROC/WEB/0]OUT>node node_modules/@sap/approuter/approuter.js
2018-08-20T05:44:29.497+0000[APP/PROC/WEB/0]OUT#2.0#2018-08 20 05:44:29:494#+00:00#警告#/日志库#动态日志级别不可用##
2018-08-20T05:44:29.756+0000[APP/PROC/WEB/0]OUT#2.0#2018-08 20 05:44:29:756#+00:00#INFO#/approuter#approuter#approuter#approuter#
2018-08-20T05:44:29.772+0000[APP/PROC/WEB/0]OUT#2.0#2018-08 20 05:44:29:772#+00:00#INFO#/Configuration########################################35#
2018-08-20T05:44:29.792+0000[APP/PROC/WEB/0]OUT#2.0#2018-08 20 05:44:29:792#+00:00#ERROR#/token utils####################################错误###错误
2018-08-20T05:44:29.792+0000[APP/PROC/WEB/0]OUT[错误:html5回购凭证:无效类型:null(预期对象)]#
2018-08-20T05:44:29.803+0000[APP/PROC/WEB/0]OUT#2.0#2018-08 20 05:44:29:803#+00:00#INFO#/approuter#approuter#approuter#approuter#
2018-08-20T05:44:30.713+0000[CELL/0]外容器变得健康
2018-08-20T05:52:34.552+0000[RTR/6]OUT-trial-dev-approuter.cfapps.us10.hana.ondemand.com-[2018-08-20T05:52:34.544+0000]“GET/HTTP/1.1”3020https://account.hanatrial.ondemand.com/cockpit“Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/68.0.3440.106 Safari/537.36”-“10.0.73.48:61203”转发请求id:“4b864872-f2e8-408f-7acf-76807660a4c9”响应时间:0.007873407应用id:“c994cd7b-bc35-4459-b72e-49e5eb9ec849”应用索引:“0”x b3跟踪id:“BE36659F8148316”x b3\u spanid:“BE36659A148316”x b3\u spanid:“BE36659A148316”
2018-08-20T05:52:34.806+0000[RTR/7]OUT-trial-dev-approter.cfapps.us10.hana.ondemand.com-[2018-08-20T05:52:34.791+0000]“GET/index.html HTTP/1.1”200 0 667https://account.hanatrial.ondemand.com/cockpit“Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/68.0.3440.106 Safari/537.36”“10.0.73.48:61203”x_forwarded_for:“-”x_forwarded_proto:“https”vcap_请求_id:“ab9fd18e-ee18-4a32-7246-21b2d2328b17”响应时间:0.01440516应用id:“c994cd7b-bc35-4459-b72e-49e5eb9ec849”应用索引:“0”x_b3跟踪id:“217f9f15ac4efb02”XspanID:“217F9F15EFB02”父项
2018-08-20T05:52:34.810+0000[APP/PROC/WEB/0]2.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5#将带有客户端重定向的页面发送到https://trial.authentication.us10.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-srv试用版!t1085&redirect_uri=https%3A%2F%2F试用版开发-approuter.cfapps.us10.hana.ondemand.com%2Flogin%2Fcallback#
2018-08-20T05:52:36.394+0000[RTR/0]OUT-trial-dev-approuter.cfapps.us10.hana.ondemand.com-[2018-08-20T05:52:36.129+0000]“GET/login/callback?code=tVzjsTi4Dx HTTP/1.1”3020 0https://trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/index.html“”Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/68.0.3440.106 Safari/537.36“-”10.0.73.48:61203“x”转发协议:“https”vcap请求id:“ee3b4a5a-e516-449d-6c2d-19a6b0807290”响应时间:0.264528818应用id:“c994cd7b-bc35-4459-b72e-49E59EC849”应用程序索引:“0”x B3U跟踪id:“3B4DE9C57A”家长id:“BD9C57A”家长id:“BD937A”
2018-08-20T05:52:37.241+0000[RTR/5]OUT-trial-dev-approuter.cfapps.us10.hana.ondemand.com-[2018-08-20T05:52:36.630+0000]“GET/index.html HTTP/1.1”200 0 130https://trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/index.html“”Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/68.0.3440.106 Safari/537.36”“-“10.0.73.48:61203”x_forwarded_for:“-”x_forwarded_proto:“https”vcap_request_id:“abf37d40-60a4-4e2b-401c-6681496dde90”响应时间:0.61069696959 app_id:“c994cd7b-bc35-4459-b72e-49e5eb9ec849”app_索引:“0”x_B38;跟踪id:“C263E642; C2746B3”SPANu id:“家长id:”C2638;
2018-08-20T05:52:37.628+0000[RTR/5]OUT-trial-dev-approter.cfapps.us10.hana.ondemand.com-[2018-08-20T05:52:37.581+0000]“GET/odata/v2/HTTP/1.1”200 0 272https://trial-trial-dev-approuter.cfapps.us10.hana.ondemand.com/index.html“”Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/68.0.3440.106 Safari/537.36“-”10.0.73.48:61203“x_转发”用于:“-”x_转发协议:“https”vcap_请求id:“4f25431d-6dcb-428c-632c-f6c3b552735e”响应