spring-3

spring-security - where can I find the list of ALL security filters registered when I use the <http> element?

北慕城南 提交于 2019-12-02 20:31:18
There are a default set of filters registered when we use the <http> element in our xml file. This mentions the ordering of filters (whichever we choose to apply), and just above that, it mentions : <bean id="filterChainProxy" class="org.springframework.security.web.FilterChainProxy"> <constructor-arg> <list> <sec:filter-chain pattern="/restful/**" filters=" securityContextPersistenceFilterWithASCFalse, basicAuthenticationFilter, exceptionTranslationFilter, filterSecurityInterceptor" /> <sec:filter-chain pattern="/**" filters=" securityContextPersistenceFilterWithASCTrue, formLoginFilter,

How to set 'Content-Disposition' and 'Filename' when using FileSystemResource to force a file download file?

我与影子孤独终老i 提交于 2019-12-02 18:57:40
What is the most appropriate, and standard, way to set the Content-Disposition=attachment and filename=xyz.zip using Spring 3 FileSystemResource ? The action looks like : @ResponseBody @RequestMapping(value = "/action/{abcd}/{efgh}", method = RequestMethod.GET, produces = "application/zip") @PreAuthorize("@authorizationService.authorizeMethod()") public FileSystemResource doAction(@PathVariable String abcd, @PathVariable String efgh) { File zipFile = service.getFile(abcd, efgh); return new FileSystemResource(zipFile); } Although the file is a zip file so the browser always downloads the file,

Can @PathVariable return null if it's not found?

不羁岁月 提交于 2019-12-02 17:32:19
Is it possible to make the @PathVariable to return null if the path variable is not in the url? Otherwise I need to make two handlers. One for /simple and another for /simple/{game} , but both do the same just if there is no game defined i pick first one from a list however if there is a game param defined then i use it. @RequestMapping(value = {"/simple", "/simple/{game}"}, method = RequestMethod.GET) public ModelAndView gameHandler(@PathVariable("example") String example, HttpServletRequest request) { And this is what I get when trying to open page /simple : Caused by: java.lang

How get working @Value or Environment in a class implementing the Condition/ConfigurationCondition interfaces

六月ゝ 毕业季﹏ 提交于 2019-12-02 11:06:36
问题 I am working with only JavaConfig. I have the following declaration: @Bean public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } it is mandatory for JavaConfig according with the following post: Spring 3.2 @value annotation with pure java configuration does not work, but Environment.getProperty works The following code works perfect (many @Values by testing purposes): @Configuration public class

How is constructor chosen in spring for beans defined in xml with parent?

心不动则不痛 提交于 2019-12-02 09:00:17
I am working with Spring 3.1.0. I am trying to understand the way spring is reading its xml files. I am trying to understand how spring deals with ambiguous conditions in the bean definitions. For example I have Alarm.java package com.anshbansal.alarm2; public class Alarm { private String type; private int volume; private int hour; public Alarm() { } public Alarm(String type, int volume, int hour) { this.type = type; this.volume = volume; this.hour = hour; } public Alarm(String type, int volume) { this.type = type; this.volume = volume; } public Alarm(int volume, String type) { this.type =

How get working @Value or Environment in a class implementing the Condition/ConfigurationCondition interfaces

▼魔方 西西 提交于 2019-12-02 07:26:57
I am working with only JavaConfig. I have the following declaration: @Bean public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } it is mandatory for JavaConfig according with the following post: Spring 3.2 @value annotation with pure java configuration does not work, but Environment.getProperty works The following code works perfect (many @Values by testing purposes): @Configuration public class ActiveMQServerConfiguration { @Value("${localhost.address}") private String localHost; @Value("${remotehost.address}"

spring security : Why can't we access Hibernate entitiy parameters in @PreAuthorize?

无人久伴 提交于 2019-12-01 20:24:28
问题 I have the following interface method on which I am applying @PreAuthoriz e : @PreAuthorize("doSomething(#user.id)") void something(User user, List<User> accessList); where User is a Hibernate entity object. It gives me an error : org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 13): Field or property 'id' cannot be found on null at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:204) There is no way that the

spring security : Why can't we access Hibernate entitiy parameters in @PreAuthorize?

百般思念 提交于 2019-12-01 18:46:43
I have the following interface method on which I am applying @PreAuthoriz e : @PreAuthorize("doSomething(#user.id)") void something(User user, List<User> accessList); where User is a Hibernate entity object. It gives me an error : org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 13): Field or property 'id' cannot be found on null at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:204) There is no way that the user parameter is null, as if I remove the annotation, and inspect the value of user in the method

Spring throws the error: Bean definition is abstract

删除回忆录丶 提交于 2019-12-01 18:23:30
I need some help with next topic. I have a hierarchy of beans, just like that: <bean id="father" class="myPackage.Father" abstract="true"/> <bean id="childA" class="myPackage.ChildA" parent="father"> <property name="atrib1" value="hello"></property> </bean> <bean id="childB" class="myPackage.ChildB" parent="father"> <property name="atrib2" value="bye"></property> <property name="atrib3" value="other"></property> </bean> I need to create another bean which contains a reference to the abstract class. Then at run-time, I will need to be able to initialize a variable of TYPE "myPackage.Father" and

Using the setAllowedFields() method in Spring

被刻印的时光 ゝ 提交于 2019-12-01 10:54:01
I'm using Spring 3.2.0. I have registered a few custom property editors for some basic needs as follows. import editors.DateTimeEditor; import editors.StrictNumberFormatEditor; import java.math.RoundingMode; import java.net.URL; import java.text.DecimalFormat; import java.text.NumberFormat; import org.joda.time.DateTime; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.beans.propertyeditors.URLEditor; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web