spring-java-config

In Spring-Security with Java Config, why does httpBasic POST want csrf token?

最后都变了- 提交于 2019-11-28 16:42:05
I am using Spring-Security 3.2.0.RC2 with Java config. I set up a simple HttpSecurity config that asks for basic auth on /v1/**. GET requests work but POST requests fail with: HTTP Status 403 - Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'. My security config looks like this: @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Resource private MyUserDetailsService userDetailsService; @Autowired //public void configureGlobal(AuthenticationManagerBuilder auth) public void configure

How to represent the Spring Security “custom-filter” using Java configuration?

本秂侑毒 提交于 2019-11-28 16:28:49
问题 What is the equivalent Java configuration for the Spring Security <custom-filter> tag? <http> <custom-filter position="FORM_LOGIN_FILTER" ref="myFilter"/> </http> I tried http.addFilter( new MyUsernamePasswordAuthenticationFilter() ) where the class extends the default filter, but it always employs the formLogin default. My filter: import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.security.authentication

Why @JavaConfig not working in Spring MVC?

懵懂的女人 提交于 2019-11-28 11:51:14
I'm trying to setup Spring MVC project without dispatcher xml and web xml(i.e. without any xml at all). Hence, I'm using @JavaConfig technique of Spring. However, whenever I'm trying to start the application on my server my server it's not working(without throwing any exception it's getting HTTP 404). Here is the snapshot of the project structure... And here the code snippets: WebConfig.java @EnableWebMvc @Configuration @ComponentScan({ "com.controller" }) public class WebConfig extends WebMvcConfigurerAdapter { private static final String VIEW_LOCATION = "/WEB-INF/views/"; private static

Spring-Boot + Spring-MVC + Thymeleaf + Apache Tiles

帅比萌擦擦* 提交于 2019-11-28 11:38:29
I have an already existing client module with apache tiles and thymeleaf, what works well. I wanted to convert it to spring-boot and wanted to do it step by step, but I am really stucking with it. I dont want to change to much once, I would love it when someone can tell me, what step I should do first and bring it to run. I already tried to write the servlets in javaConfig, but I am stucking then too. Maybe someone can help me please. If more information is needed, please dont hesitate to ask. Other question would be, do I need to change from xml to javaconfig? I would prefer the most easy way

Spring Security Java Config not generating logout url

我只是一个虾纸丫 提交于 2019-11-28 09:13:57
I am using Spring 4.0.5.RELEASE and Spring Security 3.2.4 . I am trying to create a simple sample app using java config (based on the Spring samples). The app starts up and the authentication works correctly, that is, I am redirected to a login form when accessing protected url /settings/profile However there is no /logout url generated? if I hit localhost:8080/logout I get a 404. I've used similar code on a previous project, so maybe has something to do with versions? Heres my Security Config @Configuration @EnableWebMvcSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter

Weblogic datasource disappears from JNDI tree

人盡茶涼 提交于 2019-11-28 08:19:37
We are using weblogic version 12C. Steps to reproduce the issue: - Create the datasource. Deploy the application to weblogic. Application works fine. Update the deployed ear with the new one. Application is not able to connect the datasource. Datasource not available in the JNDI tree. We need to create either a new datasource everytime or save the datasource setting again. Can someone please check and let me know if you know some solution for this? I had the same problem. Adding destroyMethod="" fixed it for me. Apparently if there is no destroyMethod, Spring tries to determine what the

Spring Batch - How to prevent batch from storing transactions in DB

孤街醉人 提交于 2019-11-28 05:42:41
问题 First the problem statement: I am using Spring-Batch in my DEV environment fine. When I move the code to a production environment I am running into a problem. In my DEV environment, Spring-Batch is able to create it's transaction data tables in our DB2 database server with out problem. This is not a option when we go to PROD as this is a read only job. Attempted solution: Search Stack Overflow I found this posting: Spring-Batch without persisting metadata to database? Which sounded perfect,

Spring security oauth2 and form login configuration

走远了吗. 提交于 2019-11-28 05:02:01
My project consists exposes two different parts, a JSF admin panel and a RESTfull service. I am trying to setup spring security to use different authentication methods depending on the URL the user navigates. The requirements are Users navigating to the JSF page get a login screen where they authentication using form authentication. Users navigating to the REST service use OAuth2 implicit authentication with basic authentication for the token granting. The seperate configurations work by themselves, the problem is when I try to combine both of them in one configuration, in that case it seems

Spring Boot, Java Config - No mapping found for HTTP request with URI [/…] in DispatcherServlet with name 'dispatcherServlet'

烈酒焚心 提交于 2019-11-28 03:01:32
问题 This has been a quite common problem here in stackOverflow, but none of the topics of the same problem solves mine. We have a template configuration that uses xml config, but now we're trying to move away from that and start using Java config. So I have a new project using Java config and Spring Boot. We're also using JSP and Tiles 3. Problem is: it fails to render our admin login page. Here is the code: Main config class: @SpringBootApplication @EnableScheduling @Import(OnAdminBeans.class)

Spring Security 3.2: @Autowire doesn't work with java configuration and custom AuthenticationProvider in Spring MVC application?

匆匆过客 提交于 2019-11-27 21:24:38
问题 This problem is relatively well discussed in several blog posts and SO questions. Nevertheless, I wasn't able to find one specifically addressing the problem with java configuration. I'm suspecting that I'm doing something wrong in my java configuration files, since I've found some posts indicating that the problem can be resolved by removing the debug XML tag (https://jira.springsource.org/browse/SEC-1885). I'm using 3.2.0.RELEASE of spring security, and 3.2.6.RELEASE of spring framework.