spring-3

Login/logout in REST with Spring 3

淺唱寂寞╮ 提交于 2019-11-27 16:48:37
We are developing RESTful webservices with Spring 3 and we need to have the functionality of login/logout, something like /webservices/login/<username>/<password>/ and /webservices/logout . The session should be stored in the context until the session is timed out or logged out to allow consumption of other webservices. Any request to access webservices without session information should be rejected. Looking for state-of-the-art solution for this scenario. I am actually resurrecting the question asked here Spring Security 3 programmatically login , which is still not properly answered. Please

Uploading multiple files using Spring MVC 3.0.2 after HiddenHttpMethodFilter has been enabled

浪子不回头ぞ 提交于 2019-11-27 16:37:33
问题 Important : This question is completely useless for any Spring version higher than 3.0.4 as the issue discussed in this thread had been fixed in that version a long ago and is no longer reproducible in subsequent versions of Spring. I'm using Spring version 3.0.2. I need to upload multiple files using the multiple="multiple" attribute of a file browser such as, <input type="file" id="myFile" name="myFile" multiple="multiple"/> (and not using multiple file browsers something like the one

Best Practise of injecting applicationContext in Spring3

本秂侑毒 提交于 2019-11-27 14:07:04
问题 As in the title above, I am confused about pros cons between injecting applicationContext by directly @Autowired annnotation or implementing ApplicationContextAware interface in a singleton spring bean. Which one do you prefer in which cases and why? Thanks. 回答1: Actually, both are bad. Both of them tie your application to the Spring framework, thus inverting the whole inversion-of-control concept. In an ideal world, your application should not be aware of being managed by an

No AuthenticationProvider found for UsernamePasswordAuthenticationToken

ぐ巨炮叔叔 提交于 2019-11-27 13:02:59
问题 my web.xml config is <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> here is my security config <intercept-url pattern="/*" access="ROLE_USER" /> <intercept-url pattern="/*.ico" filters="none" /> </http> <beans:bean id="customAuthenticationProvider" class="net.spring3

determine target url based on roles in spring security 3.1

北城以北 提交于 2019-11-27 12:55:39
In spring security 3.0, we are having AuthenticationProcessingFilter class, in which we were using determineTargetUrl() method, which returned the url based on different roles. Now, we are moving to spring security 3.1.0.RC3 and I am stuck how should I now determine the url based on different roles as AuthenticationProcessingFilter class has been removed from new version. Can anyone please give me steps in brief with some code so that I can implement custom filter to redirect to different pages for different roles. The best way to determine the target url based upon roles is to specify a

No Session found for current thread (Spring 3.1.X and Hibernate 4)

血红的双手。 提交于 2019-11-27 12:49:18
I'm trying to set up my project using Spring 3.1 and Hibernate 4. I've been following some tutorials online. I'm getting a strange error that according to the spring forums should have been fixed with Spring 3.1. Spring Bug Tracker When my service calls getCurrentSession() , it throws the following exception: org.hibernate.HibernateException: **No Session found for current thread**] with root cause org.hibernate.HibernateException: No Session found for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97) at org.hibernate

Add attributes to the model of all controllers in Spring 3

天大地大妈咪最大 提交于 2019-11-27 11:39:53
问题 Every single view in my Spring 3 app has a set of attributes they can rely on. So the first line of every controller is something like: ControllerHelper.addDefaultModel(model, personManager, request); In there I'll add user object and full name retrieved from the database if person is logged in set of variables which are typically set once (e.g. imagesHost ) set of languages a visitor can switch to current language some statistics (e.g. total # of people in our system) This all allows each

How to get a method's annotation value from a ProceedingJoinPoint?

半腔热情 提交于 2019-11-27 09:40:22
问题 I have below annotation. MyAnnotation.java @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation { } SomeAspect.java public class SomeAspect{ @Around("execution(public * *(..)) && @annotation(com.mycompany.MyAnnotation)") public Object procede(ProceedingJoinPoint call) throws Throwable { //Some logic } } SomeOther.java public class SomeOther{ @MyAnnotation("ABC") public String someMethod(String name){ } } In above class am passing " ABC " with in

When use AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer?

徘徊边缘 提交于 2019-11-27 09:01:37
问题 I am working with Spring 4.0.7 I did a research about configure Spring MVC through JavaConfig. Practically until yesterday I have seen two configurations using these two options extends AbstractAnnotationConfigDispatcherServletInitializer extends WebMvcConfigurerAdapter and implements WebApplicationInitializer Note : (2) are two classes, one for extension and the other for implementation I am using (2) because I have found many examples where I am able to configure converters, formatters,

Multiple scenarios @RequestMapping produces JSON/XML together with Accept or ResponseEntity

*爱你&永不变心* 提交于 2019-11-27 04:21:51
问题 I am working with Spring 4.0.7 About Spring MVC, for research purposes, I have the following: @RequestMapping(value="/getjsonperson", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Person getJSONPerson(){ logger.info("getJSONPerson - getjsonperson"); return PersonFactory.createPerson(); } @RequestMapping(value="/getperson.json", method=RequestMethod.GET) public @ResponseBody Person getPersonJSON(){ logger.info("getPerson - getpersonJSON"); return