spring-java-config

Spring Security Java Config

守給你的承諾、 提交于 2019-11-29 15:01:40
问题 I'm trying to use JavaConfig instead of XML configuration for Spring Security. I would like to use @PreAuthorization for declaring access rights. My Spring Security Config looks like this: @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity( prePostEnabled = true ) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void registerAuthentication( AuthenticationManagerBuilder auth ) throws Exception { auth .inMemoryAuthentication() .withUser( "user" )

How to redirect HTTP requests to HTTPS using Spring Security Java configuration?

三世轮回 提交于 2019-11-29 14:06:54
问题 I have a Spring Security version 3.2.3 application that listens to both HTTP and HTTPS. I want any request to the HTTP port to be redirected to HTTPS. How do I configure that using Java only? Spring Security javadoc for HttpSecurity proposes the following solution (trimmed to the essential): public class WebSecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) { http.channelSecurity().anyRequest().requiresSecure(); } } However that doesn't work

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 12:07:24
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, so I added @Bean public ResourcelessTransactionManager transactionManager() { return new

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

荒凉一梦 提交于 2019-11-29 09:30:56
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) public class AppConfig extends SpringBootServletInitializer { public static void main(String[] args) {

Spring Security Java Config for Siteminder

纵然是瞬间 提交于 2019-11-29 03:50:38
问题 I have an inMemoryAuthentication configuration that works: @Configuration @EnableWebMvcSecurity public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure( AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { authenticationManagerBuilder // .inMemoryAuthentication() // .withUser("employee") // .password("employee") // .roles("RoleEmployee") ; } @Override public void configure(WebSecurity webSecurity) throws

Apache CXF + Spring Java config (no XML)

我们两清 提交于 2019-11-29 03:13:35
Trying to deploy a JAX-WS endpoint using Tomcat 7 Maven plugin and CXF 2.7.8. As a matter of preference, I don't want to have any XML config for Spring or CXF. I see several blogs, articles, posts using cxf-servlet.xml and CXFServlet but none whatsoever completely using Java config. Looking into the CXFServlet source code, it looks for the cxf-servlet.xml or anything in the servlet context under the key 'config-location' . I tried programmatically registering the endpoint instead of in cxf-servlet.xml , but it doesn't work; I get a 404 when accessing the service. Any ideas? @Configuration

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

ε祈祈猫儿з 提交于 2019-11-29 00:13:10
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. Below the main files used in the spring security/mvc configuration and the custom

JavaConfiguration for Spring 4.0 + Security 3.2 + j_spring_security_check

て烟熏妆下的殇ゞ 提交于 2019-11-28 23:42:57
Create a login page <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Test</title> <script src="static/js/jquery-1.10.2.min.js"></script> <script src="static/js/app-controller.js"></script> </head> <body> <div>Login</div> <form name="f" action="<c:url value="/j_spring_security_check"/>" method="POST"> <label for="password">Username</label> <input type="text" id="j_username" name="j_username"><br/> <label for="password">Password</label> <input type="password" id="j_password" name="j_password"><br/> <input type=

Spring Java Config with Multiple Dispatchers

我怕爱的太早我们不能终老 提交于 2019-11-28 20:53:33
I've some experience Spring now and also have some pure java config web-apps in use. However, these are usually based on a quiet simple setup: application config for services / repositories dispatcher config for one dispatcher (and some controllers) (optional) spring security to secure the access For my current project I need to have separate dispatcher contexts with different configuration. That's not a problem with the XML based configuration as we have a dedicated ContextLoaderListener that's independent from Dispatcher Configuration. But with java config I'm not sure if what I'm doing is

Custom Authentication provider with Spring Security and Java Config

折月煮酒 提交于 2019-11-28 20:29:29
How can I define a custom Authentication provider by using Spring Security with Java Configurations? I would like to perform a login checking credentials on my own database. The following does what you need ( CustomAuthenticationProvider is your implementation which needs to be managed by Spring) @Configuration @EnableWebMvcSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private CustomAuthenticationProvider customAuthenticationProvider; @Override protected void configure(HttpSecurity http) throws Exception { /** * Do your stuff here */ } @Override