Commit 5280bdd1 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Created config.properties example file

This file should be used to create a config file with matching values.
parent b4fbb773
.project
.classpath
.settings/*
config.properties
target/*
package de.thm.arsnova.websockets;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.apache.catalina.websocket.WsOutbound;
public class Message extends WebSocketServlet {
private static final long serialVersionUID = 1L;
private volatile int byteBufSize;
private volatile int charBufSize;
@Override
public void init() throws ServletException {
System.out.println("init();");
super.init();
byteBufSize = getInitParameterIntValue("byteBufferMaxSize", 2097152);
charBufSize = getInitParameterIntValue("charBufferMaxSize", 2097152);
}
public int getInitParameterIntValue(String name, int defaultValue) {
String val = this.getInitParameter(name);
int result;
if (null != val) {
try {
result = Integer.parseInt(val);
} catch (Exception x) {
result = defaultValue;
}
} else {
result = defaultValue;
}
return result;
}
@Override
protected StreamInbound createWebSocketInbound(String subProtocol,
HttpServletRequest request) {
// TODO Auto-generated method stub
return new MessageInboundImpl(byteBufSize, charBufSize);
}
private final static List<MessageInbound> connections = new ArrayList<MessageInbound>();
private static final class MessageInboundImpl extends MessageInbound {
public MessageInboundImpl(int byteBufferMaxSize, int charBufferMaxSize) {
super();
setByteBufferMaxSize(byteBufferMaxSize);
setCharBufferMaxSize(charBufferMaxSize);
}
@Override
protected void onOpen(WsOutbound outbound) {
connections.add(this);
super.onOpen(outbound);
}
@Override
protected void onClose(int status) {
connections.remove(this);
super.onClose(status);
}
@Override
protected void onBinaryMessage(ByteBuffer message) throws IOException {
throw new UnsupportedOperationException("Binary message not supported.");
}
@Override
protected void onTextMessage(CharBuffer message) throws IOException {
//getWsOutbound().writeTextMessage(message);
broadcast(message.toString());
}
private void broadcast(String message) {
for (MessageInbound connection : connections) {
try {
CharBuffer buffer = CharBuffer.wrap(message);
connection.getWsOutbound().writeTextMessage(buffer);
} catch (IOException ignore) {
// Ignore
}
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
......@@ -10,12 +9,23 @@
<context:component-scan base-package="de.thm.arsnova" />
<context:annotation-config />
<sec:http entry-point-ref="casEntryPoint" disable-url-rewriting="true">
<sec:intercept-url pattern="/j_spring_security_check" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="false" />
<property name="locations">
<value>config.properties</value>
</property>
</bean>
<sec:http entry-point-ref="casEntryPoint"
disable-url-rewriting="true">
<sec:intercept-url pattern="/j_spring_security_check"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<sec:intercept-url pattern="/doCasLogin" access="ROLE_USER" />
<sec:custom-filter ref="casFilter" position="CAS_FILTER" />
<sec:openid-login user-service-ref="openidUserDetailsService" default-target-url="http://localhost:8080/arsnova/doOpenIdLogin" />
<sec:openid-login user-service-ref="openidUserDetailsService"
default-target-url="${security.openid-target-url}" />
</sec:http>
<bean id="casFilter"
......@@ -35,7 +45,7 @@
<!-- TODO: Replace local URL with real world url / parameter? -->
<bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties">
<property name="service" value="http://localhost:8080/arsnova/j_spring_cas_security_check" />
<property name="service" value="${security.cas-check-url}" />
<property name="sendRenew" value="false" />
</bean>
......@@ -47,7 +57,7 @@
</property>
<property name="ticketValidator">
<bean class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator">
<constructor-arg value="https://cas.thm.de/cas" />
<constructor-arg value="${security.cas-service-url}" />
</bean>
</property>
</bean>
......
......@@ -3,9 +3,6 @@
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>
arsnova-war
</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
......@@ -16,32 +13,6 @@
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>
wsMessage
</servlet-name>
<servlet-class>
de.thm.arsnova.websockets.Message
</servlet-class>
<!--
<init-param>
<param-name>byteBufferMaxSize</param-name>
<param-value>20971520</param-value>
</init-param>
<init-param>
<param-name>charBufferMaxSize</param-name>
<param-value>20971520</param-value>
</init-param>
-->
</servlet>
<servlet-mapping>
<servlet-name>
wsMessage
</servlet-name>
<url-pattern>
/websocket/message
</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>arsnova</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
......
security.openid-target-url=http://localhost:8080/arsnova-war/doOpenIdLogin
security.cas-check-url=http://localhost:8080/arsnova-war/j_spring_cas_security_check
security.cas-service-url=https://cas.thm.de/cas
\ No newline at end of file
Markdown is supported
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