Can anybody tell me what is replacement of
<bean id="authenticationSuccessHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"/>
in Spring Security 2.0.2.
any help would be appreciated.
The same class in the same package is still there. If you use the namespace configuration, you don't have to declare this bean manually, because the <security:form-login> element will wire it up by default.
Related
I have a project, work with Vaadin 8.6 and Spring 5, and vaadin-spring 3.1.1
In this, there is MainUI extends UI that a bean with scope="prototype" initialized in web-application-context.xml
Problem: when we connect to project from more than one client (browser), there is only one session available.
we search and find some manuals, but we can not use it in our project
<bean id="mainUI" class="ir.fanap.fanitoring.ui.MainUI" scope="prototype">
Vaadin Spring Add-on
how can we solve this problem? we did not use annotations for beans and all beans initialized in web-application-context.xml
We have an existing Spring MVC application (non Spring-boot application) with all (or most) of the beans configured in the XML. We wanted to use this as a Spring Cloud Config Client (we have a Spring Boot application acting as config server).
In this regard, what is the XML equivalent of configuring the beans in XML with refresh scope (same as #RefreshScope annotation). Tried configuring the RefreshScope as bean and using scope="refresh" but could see that the beans are not reflected with new values after peforming /refresh endpoint (from actuator)
Any help on this is highly appreciated
As pointed out in other answers 'refresh' scope is just another scope. However there's an issue where the bean properties are not updated with new values after /refresh call - if you define and inject properties in XML. More on the issue here. However the bean (i.e. actually the proxy) is instantiated after each /refresh call - but you need "aop:scoped-proxy" config since bean to which you inject the 'refresh' scoped bean, could be on a different scope. i.e.
<bean name="xmlValueBean" class="me.fahimfarook.xml.XMLValueBean" scope="refresh">
<aop:scoped-proxy proxy-target-class="true" />
</bean>
Well if you want to use #RefreshScope in core Spring(also Spring MVC) as people already pointed out, you have to implement the scope yourself also.
I also had the same dilemma and I did, I also wrote a blog about it, you can find there all the implementation details.
You can also use Spring Boot Configuration Server with your Spring MVC application, if you like to.
#RefreshScope for Spring MVC
#RefreshScope is just another scope. Look at how the RefreshScope class is implemented. It is creating a new scope named "refresh".
That means you should be able to use the new scope in your XML configuration, like this.
<bean id = "..." class = "..." scope = "refresh">
</bean>
I have a fully functional Restlet app that I am trying to add Spring Data Jpa + Hibernate.
Firstly I need to get Spring and Restlet playing together.
The example below is from the Restlet docs, it is trying to set a root property on the Application Class, I can not find this root property, it must be from and old version of the API.
Can someone please post an example of Spring and Restlet 2.2 config, this is very frustrating.
<bean id="basecampAppliction" class="classpath to Application class">
<property name="root" ref="router" />
</bean>
Also, all the examples I have found rely on Spring doing the routing, I would like to keep the routing in the Application code if that is possible.
The docs on the Restlet web site are out of date, please see fix above.
I'm using Spring 3.1 JSF 2.2.
Annoting Bean with ViewScoped introduced by JSF 2.2 not work.
#javax.inject.Named
#javax.faces.view.ViewScoped
public class TestBean {
#PostConstruct
public void init(){sysout("Why spring invoke this when initializing context :-( ");}
}
In my applicationContext.xml there is an annotation component-scan tag
<context:component-scan base-package="com.test"/>
Spring 3.1 detect and deal with CDI annotation but #javax.faces.view.ViewScoped not work. I know there is another solution by creating my own ViewScoped implementation but i want to know why #javax.faces.view.ViewScoped not work
Best solution was removing spring and using a Java EE implementation of CDI
You should notice that JSF annotations will nor work for Spring beans, because JSF beans located in different context.
But view scope implementation is pretty simple. I've created an artifact to solve this problem.
See my github javaplugs/spring-jsf repository.
javax.faces.view.ViewScoped will only work for JSF Managed Bean and not for CDI.
Use javax.faces.bean.ManagedBean annotation if you want to have a correct behavior with View scope instead of javax.inject.Named.
Regards
I have been able to implement the #Secured annotation in one controller of my application. Yet, #Secured('ROLE_ADMIN') will NOT work anywhere else within the project.
It will only specifically work anywhere within my program controller and no where else.
For example, if I use it as so;
#Secured('ROLE_ADMIN')
The IDE gives me;
Multiple markers at this line
- Groovy:class Secured is not an annotation in #Secured
- Groovy:unable to resolve class Secured , unable to find class for
I have even tried checking the Spring Security Config file to check if annotations were set correctly (which seemingly they were).
Any ideas? Please help.
Thanks.
You are probably missing the required import.
At the top of each controller where you need the annotations use the grails import for Secured. Then you can use the annotations for the class or method as needed.
import grails.plugin.springsecurity.annotation.Secured
//import grails.plugins.springsecurity.Secured; - this is in older version,
// grails 2.0 and older
#Secured(['ROLE_ADMIN', 'ROLE_USER', 'ROLE_SUPERVISOR'])
class myClass {
}
Hope this helps.
Try this:
#PreAuthorize("hasRole('ROLE_ADMIN')" )
And add annotation support in spring configuration:
<!-- Allow configuration annotation (#Annotation-based configuration)-->
<context:annotation-config />
<!-- Enable scan classes -->
<context:component-scan base-package="com.your.package" />