I need call a web services in an url and later modify json that I recieve, but I don't obtain the result correct. I use spring mvc.
I have this code java in the service web:
@RequestMapping("/test")
@ResponseBody
public String infoSist() throws Exception {
base = new URL("http://localhost:" + port + "/metrics");
template = new RestTemplate();
System.out.println(base);
ResponseEntity<String> infoSist = template.getForEntity(base.toString(), String.class);
System.out.printf("Exit: \n\n %s",infoSist.getBody());
return infoSist.getBody();
}
I don't show the json of request this URL, I obtained the html of login page. I supose that it is the problem with authetication, but I don´t know how solution this problem. I have to change the login user to database in the future ....
This is my config security:
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/css/**", "/js/**", "/images/**", "/data/**", "/", "/home").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
How i do the change for the call this url have permissions?
thank you very much!
Aucun commentaire:
Enregistrer un commentaire