add checking for precence of token and permission parameters /commented out for ease now/, disable login method

This commit is contained in:
Marcin Michałek committed 2015-01-25 09:03:10 +01:00
1 parent 382d4118c5
commit 8d163bd84b
2 files changed
+18 -9

No files matched your search

+8 -1
View File
@@ -1,6 +1,6 @@
package hello;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@@ -27,6 +27,13 @@ public class SampleInterceptor extends HandlerInterceptorAdapter {
System.out.println("************************");
System.out.println("pre handle interceptor");
System.out.println("************************");
//
// if (request.getHeader(LoginController.TOKEN) == null || request.getHeader(LoginController.PERMISSION) == null) {
// System.out.println("No token or permission parameter in header.");
// response.sendError(HttpStatus.UNAUTHORIZED.value(), "No token or permission parameter in request header");
// return super.preHandle(request, response, handler);
// }
return super.preHandle(request, response, handler);
}
}
@@ -19,6 +19,8 @@ import org.springframework.web.client.RestTemplate;
@Controller
@RequestMapping(APIServicePaths.AUTHENTICATION_CONTROLLER)
public class LoginController {
public static final String TOKEN = "token";
public static final String PERMISSION = "permission";
RestTemplate restTemplate = new RestTemplate();
@@ -32,14 +34,14 @@ public class LoginController {
);
}
@RequestMapping(value = APIServicePaths.LOGIN_USER, method = RequestMethod.POST)
@ResponseBody
String loginUser(@RequestParam("login") String login, @RequestParam("password") String password) {
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("login", login);
map.add("password", password);
return restTemplate.postForObject(ModuleServicePaths.AUTHENTICATICATE, map, String.class);
}
// @RequestMapping(value = APIServicePaths.LOGIN_USER, method = RequestMethod.POST)
// @ResponseBody
// String loginUser(@RequestParam("login") String login, @RequestParam("password") String password) {
// MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
// map.add("login", login);
// map.add("password", password);
// return restTemplate.postForObject(ModuleServicePaths.AUTHENTICATICATE, map, String.class);
// }
@RequestMapping(value = APIServicePaths.GET_USER_FOR_TOKEN)
@ResponseBody