spring-mvc

How to add a parameter to login page and access in loadUserByUsername method spring security 4

主宰稳场 提交于 2020-01-05 15:15:30
问题 While user tries to login I want to pass an extra parameter userAccountID, and access in loadUserByUsername for querying db user with name and userAccountID. userDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException; How can I achieve this above user case? Thanks in advance. Below is my login Java configuration but it not working empty login page in coming @Bean public AuthenticationSuccessHandlerImpl getAuthenticationSuccessHandlerImpl() throws

Accessing URL with params in Spring Security

允我心安 提交于 2020-01-05 15:02:53
问题 I am new in Spring Security and have an issue with authenticating specific URLs with path variables or parameters. Let's say I have some URL: /messages/1 where 1 is an user's ID. What I want to do is to let ONLY user with ID=1 accessing page with this URL. Spring Security allows accessing some content if user is authenticated, but how can I make authentication more narrow? 回答1: Assuming that you have an id property in your UserDetails : @RequestMapping(value="/messages/{userId}", method

Accessing URL with params in Spring Security

陌路散爱 提交于 2020-01-05 15:00:12
问题 I am new in Spring Security and have an issue with authenticating specific URLs with path variables or parameters. Let's say I have some URL: /messages/1 where 1 is an user's ID. What I want to do is to let ONLY user with ID=1 accessing page with this URL. Spring Security allows accessing some content if user is authenticated, but how can I make authentication more narrow? 回答1: Assuming that you have an id property in your UserDetails : @RequestMapping(value="/messages/{userId}", method

Spring restful service test case fail HTTP status is 500

岁酱吖の 提交于 2020-01-05 14:28:31
问题 I want to implement test case for spring restful web services which return a json MY controller test class is : @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {WebAppContext.class,JpaTestConfiguration.class }) @WebAppConfiguration public class DominProfileRestControllerTest { private MockMvc mockMvc; @Autowired private WebApplicationContext webApplicationContext; private MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION

Want to include relationships in Spring REST API

非 Y 不嫁゛ 提交于 2020-01-05 14:10:10
问题 I am new in Spring. I have three entity Invoice, Line and Product . (1) If I call GET /invoices then I want output like, { "invoices": [ { "id": "101", "date": "2013-02-14" }, { "id": "102", "date": "2013-02-18" } ] } I have done this, I am able to do this but not able to include relations in the get request. (2) I want to GET call something like this which include relations. GET /invoices?include=invoice.lines:embed,invoice_line.product:sideload I want output like { "invoices": [ { "id":

sharing session attribute between two subdomains in tomcat

删除回忆录丶 提交于 2020-01-05 12:23:27
问题 I am using tomcat 7.0 and java 6. I want to share session between domains and subdomain for examples.com and abc.examples.com so in context.xml put tag <Context antiResourceLocking="false" privileged="true" sessionCookieDomain=".examples.com" sessionCookiePath="/" > successfully share Cookies JSESSIONID but when i set attribute in examples.com logger.info( "Demo1 : "+httpSession.getId()); httpSession.setAttribute("data", "subhash lamba"); logger.info(" Demo1 data"+ httpSession.getAttribute(

org.springframework.expression-3.1.0.M2.jar has no source attachment

我是研究僧i 提交于 2020-01-05 12:18:32
问题 I am working on spring mvc 3.0 that integrated spring-social-facebook. When I debug the code, there is an error at line List<Connection<?>> connections = connectionRepository.findConnections(providerId); in the following method @RequestMapping(value="/{providerId}", method=RequestMethod.GET) public String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model) {...} and controller is ConnectController Eclipse shows Source not found And when i keep the line

org.springframework.expression-3.1.0.M2.jar has no source attachment

北战南征 提交于 2020-01-05 12:18:19
问题 I am working on spring mvc 3.0 that integrated spring-social-facebook. When I debug the code, there is an error at line List<Connection<?>> connections = connectionRepository.findConnections(providerId); in the following method @RequestMapping(value="/{providerId}", method=RequestMethod.GET) public String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model) {...} and controller is ConnectController Eclipse shows Source not found And when i keep the line

org.springframework.expression-3.1.0.M2.jar has no source attachment

梦想与她 提交于 2020-01-05 12:18:07
问题 I am working on spring mvc 3.0 that integrated spring-social-facebook. When I debug the code, there is an error at line List<Connection<?>> connections = connectionRepository.findConnections(providerId); in the following method @RequestMapping(value="/{providerId}", method=RequestMethod.GET) public String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model) {...} and controller is ConnectController Eclipse shows Source not found And when i keep the line

response code 500 when returning an object using @ResponseBody

岁酱吖の 提交于 2020-01-05 11:02:50
问题 I'm fairly new to spring Restful programming The requirement to use the controller method as a rest service, so I'm trying to return an object in a JSON format, but for some reason I'm getting a response code as 500 with no errors and exceptions in log files. But it is successfully working if I the return type is of a string rather an object I'm using the jackson dependencies and I'm configuring in context file and in a assumption that converts the object to json format and puts in the