Skip to content
Snippets Groups Projects
Commit df62a3bb authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Major changes is Spring application configuration

With this changeset the spring servlet configuration is separeted from the
application configuration. This will result in a main context and a servlet
context, holding only spring mvc information.

This change has a very nice side effekt: Spring AOP beans will be loaded
only once in application context, not a second time in mvc servlet context.
parent 51ec6042
No related merge requests found
......@@ -11,7 +11,7 @@ import de.thm.arsnova.services.IUserService;
@Aspect
public class AuthorizationAdviser {
private static IUserService userService;
private IUserService userService;
public final void setUserService(final IUserService uService) {
userService = uService;
......@@ -43,6 +43,6 @@ public class AuthorizationAdviser {
*/
@Before("execution(public * de.thm.arsnova.services.*.*(..)) && @annotation(authenticated) && this(object)")
public final void checkSessionMembership(final Authenticated authenticated, final Object object) {
/// TODO: Implement check based on session membership lists
/// TODO Implement check based on session membership lists
}
}
......@@ -104,8 +104,10 @@ public class LoginController extends AbstractController {
} else {
username = "Guest" + Sha512DigestUtils.shaHex(request.getSession().getId()).substring(0, 10);
}
org.springframework.security.core.userdetails.User user = new org.springframework.security.core.userdetails.User(
username, "", true, true, true, true, authorities);
org.springframework.security.core.userdetails.User user =
new org.springframework.security.core.userdetails.User(
username, "", true, true, true, true, authorities
);
Authentication token = new UsernamePasswordAuthenticationToken(user, null, authorities);
SecurityContextHolder.getContext().setAuthentication(token);
......
......@@ -159,7 +159,7 @@ public class Question {
@Override
public final String toString() {
return "Question type '" + this.type + "': " + this.subject + ";\n" + this.text +
this.possibleAnswers;
return "Question type '" + this.type + "': " + this.subject + ";\n"
+ this.text + this.possibleAnswers;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
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">
<!-- ARSnova Root Context: defines shared resources visible to all OTHER web components -->
<!-- ARSnova Servlet Context -->
<context:component-scan base-package="de.thm.arsnova.controller" />
<context:annotation-config />
<aop:aspectj-autoproxy>
<aop:include name="authorizationAdviser" />
</aop:aspectj-autoproxy>
<mvc:annotation-driven />
<mvc:resources mapping="/**" location="/" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json" />
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="prefixJson" value="false"/>
</bean>
</list>
</property>
</bean>
</beans>
......@@ -30,48 +30,7 @@
<context:component-scan base-package="de.thm.arsnova" />
<context:annotation-config />
<aop:aspectj-autoproxy>
<aop:include name="authorizationAdviser" />
</aop:aspectj-autoproxy>
<mvc:annotation-driven />
<mvc:resources mapping="/**" location="/" />
<task:annotation-driven />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json" />
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="prefixJson" value="false"/>
</bean>
</list>
</property>
</bean>
<bean id="socketServer" class="de.thm.arsnova.socket.ARSnovaSocketIOServer"
init-method="startServer" destroy-method="stopServer" scope="singleton"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment