mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 23:44:54 +01:00
Enable security configuration from properties.
This commit is contained in:
parent
cb6828c08e
commit
0f605d89f0
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright [2012] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.wisemapping.webmvc;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.env.PropertySourcesPropertyResolver;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.core.io.support.ResourcePropertySource;
|
||||
import org.springframework.web.context.ConfigurableWebApplicationContext;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ApplicationContextInitializer implements org.springframework.context.ApplicationContextInitializer<ConfigurableWebApplicationContext> {
|
||||
|
||||
public void initialize(@NotNull ConfigurableWebApplicationContext ctx) {
|
||||
try {
|
||||
final Resource resource = new ServletContextResource(ctx.getServletContext(), "/WEB-INF/app.properties");
|
||||
final ResourcePropertySource resourcePropertySource = new ResourcePropertySource(resource);
|
||||
ctx.getEnvironment().getPropertySources().addFirst(resourcePropertySource);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -100,7 +100,7 @@ google.analytics.account=UA-XXXX
|
||||
google.ads.enabled=false
|
||||
|
||||
#######################################################################################
|
||||
Security Configuration Section
|
||||
# Authentication Configuration Section
|
||||
#######################################################################################
|
||||
|
||||
# Two type of security are supported:
|
||||
|
@ -22,6 +22,11 @@
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>contextInitializerClasses</param-name>
|
||||
<param-value>com.wisemapping.webmvc.ApplicationContextInitializer</param-value>
|
||||
</context-param>
|
||||
|
||||
|
||||
<!--
|
||||
- Loads the root application context of this web app at startup.
|
||||
|
@ -8,8 +8,6 @@
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
|
||||
|
||||
<bean id="encoder" class="com.wisemapping.security.CustomPasswordEncoder"/>
|
||||
|
||||
<sec:authentication-manager alias="authenticationManager">
|
||||
<sec:authentication-provider ref="dbAuthenticationProvider"/>
|
||||
<sec:authentication-provider user-service-ref="userDetailsService"/>
|
||||
|
@ -3,11 +3,8 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:sec="http://www.springframework.org/schema/security"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
|
||||
|
||||
@ -56,9 +53,9 @@
|
||||
<sec:logout logout-url="/c/logout" invalidate-session="true" logout-success-url="/c/login"/>
|
||||
</sec:http>
|
||||
|
||||
<!--<import resource="wisemapping-security-${security.type}.xml"/>-->
|
||||
<import resource="wisemapping-security-db.xml"/>
|
||||
<!--<import resource="wisemapping-security-ldap.xml"/>-->
|
||||
<bean id="encoder" class="com.wisemapping.security.CustomPasswordEncoder"/>
|
||||
|
||||
<import resource="wisemapping-security-${security.type}.xml"/>
|
||||
|
||||
<bean id="userDetailsService" class="com.wisemapping.security.UserDetailsService">
|
||||
<property name="userService" ref="userService"/>
|
||||
|
Loading…
Reference in New Issue
Block a user