0
這裏有一個控制器我試圖取代:Spring集成和http入站適配器,如何提取主體用戶?
@RequestMapping("/user")
public @ResponseBody UserRsp callUserService(Principal principal) {
String authenticatedUsername = principal.getName();
return userService.getUser(authenticatedUsername);
}
我想用一個int-HTTP來替代它:入站網關,被映射到一個服務適配器。我無法找到任何這文件,但我想要做的是這樣的:
<int-http:inbound-gateway
request-channel="requests"
reply-channel="replies"
path="/user"
view-name="/user"
payload-expression="#payload.principal.name"
supported-methods="GET"/>
但payload.principal是我做的。任何想法正確的方式來做到這一點?
好極了!我現在在SPeL文檔中看到了這個功能,這是有道理的。事實證明,返回org.springframework.security.core.userdetails.User對象而不是java.security.Principal,但我可以調用.username並獲得相同的結果。 – Joe 2012-07-13 11:19:32
順便說,主要的(如果存在的話),始終映射到一個頭... \t消息>消息= messageBuilder \t \t .setHeader(org.springframework.integration.http.HttpHeaders.REQUEST_URL,請求。 getURI()。的toString()) \t \t .setHeader(org.springframework.integration.http.HttpHeaders.REQUEST_METHOD,request.getMethod()。的toString()) \t \t .setHeader(org.springframework.integration.http。 HttpHeaders.USER_PRINCIPAL,servletRequest.getUserPrincipal()) \t \t .build(); – 2012-07-13 21:35:39