* По умолчанию
, мой фильтр входа в систему выглядит следующим образом:
"role": "ROLE_ABC",
"succeed": "Success!",
"id": 123,
"username": "111222333",
"token": "xxxxx"
Теперь я хочу ввести вывод rest tempalte, вывод шаблона rest как этот:
{
"ResponseHeader": {
"ErrorCode": "0",
"ErrorDescription": "Success",
"TrxId": "123"
},
"UserInfo": {
"UserId": "111222333",
"FullName": ""
}
}
теперь я хочу добавить выходные данные шаблона отдыха в мой фильтр входа в систему по умолчанию.
это мой код, я не понимаю, как я могу отправить шаблон Тела запроса отдыха внутри фильтра входа в систему
@Autowired
RestTemplate restTemplate;
@Override
protected void successfulAuthentication(final HttpServletRequest req, final HttpServletResponse res, final FilterChain chain,
final Authentication auth) throws IOException, ServletException {
logger.info("successfulAuthentication");
logger.info(auth);
Set<String> roles = AuthorityUtils.authorityListToSet(auth.getAuthorities());
String hasil=roles.toString().replace("[","").replace("]", "");
AuthenticationService.addToken(res, auth.getName());
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Authorization", "Basic uYycjhow9iJOFOJj=");
HttpEntity<vwCredentials> entity = new HttpEntity<vwCredentials>(product,headers);
->variable "product" is request body,
i confuse where should i put this code "@RequestBody vwCredentials product"
ResponseEntity<vwJWTLDAP> respon = restTemplate.exchange(
"http://123/LDAP/", HttpMethod.POST, entity, vwJWTLDAP.class);
HashMap<String, Object> map = new HashMap<>();
String email = auth.getName();
User user = repository.findByEmail(email);
map.put("id", user.getId());
map.put("username", auth.getName());
map.put("role", hasil);
//map.put("LDAP", respon); -> I WANT TO CALL LIKE THIS WAY
map.put("token", AuthenticationService.addToken(auth.getName()));
map.put("succeed", "Success !");
String authString = new Gson().toJson(map);
PrintWriter out = res.getWriter();
res.setContentType("application/json");
res.setCharacterEncoding("UTF-8");
out.print(authString);
out.flush();
}
}
как я могу так звонить. //map.put("LDAP ", ответ); -> Я хочу позвонить, как этот путь