diff --git a/smp-docker/images/tomcat-mysql/Dockerfile b/smp-docker/images/tomcat-mysql/Dockerfile index 7a862ae190c2fcc6fb9f5f0725f80f014e7c3135..24c41f9e40c4fb7ffee4f31307a86be7320eb1c7 100755 --- a/smp-docker/images/tomcat-mysql/Dockerfile +++ b/smp-docker/images/tomcat-mysql/Dockerfile @@ -14,7 +14,7 @@ ENV SMP_HOME=/opt/smp \ DB_USER_PASSWORD=smp \ MYSQL_ROOT_PASSWORD=root -EXPOSE 3306 8080 6400 +EXPOSE 3306 8080 6901 # Exposing ports used in entrypoint.sh .. # - 3306 Mysql port # - 6400 JaCoCo port @@ -30,9 +30,12 @@ RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ mysql-server \ openjdk-8-jdk \ - locales\ - curl \ - unzip \ + locales\ + curl \ + unzip \ + vim \ + squid \ + apache2-utils \ && rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ # set user @@ -49,6 +52,7 @@ RUN apt-get update \ && rm tomcat.zip \ && mkdir -p $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf/ \ && echo "export CLASSPATH=$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf" > $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/bin/setenv.sh \ + && echo "export JAVA_OPTS=-Djdk.http.auth.tunneling.disabledSchemes=" >> $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/bin/setenv.sh \ && sed -i -e "s/<\/Context>/<Resource name=\"jdbc\/eDeliverySmpDs\" auth=\"Container\" type=\"javax.sql.DataSource\" maxTotal=\"100\" maxIdle=\"30\" maxWaitMillis=\"10000\" username=\"$DB_USER\" password=\"$DB_USER\" driverClassName=\"com.mysql.jdbc.Driver\" url=\"jdbc:mysql:\/\/localhost:3306\/$DB_SCHEMA?useSSL=false\&characterEncoding=UTF-8\&useUnicode=true\"\/><\/Context>/g" "$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/conf/context.xml" \ && sed -i -e "s/<Connector /<Connector URIEncoding=\"UTF-8\" /g" "$SMP_HOME/apache-tomcat-$TOMCAT_VERSION/conf/server.xml" \ && echo "datasource.jndi=java:comp/env/jdbc/eDeliverySmpDs" > $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf/smp.config.properties \ @@ -56,6 +60,7 @@ RUN apt-get update \ && echo "\nauthentication.blueCoat.enabled=true" >> $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf/smp.config.properties \ && echo "\nsmp.truststore.password={DEC}{test123}" >> $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf/smp.config.properties \ && echo "\nsmp.keystore.password={DEC}{test123}" >> $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf/smp.config.properties \ + && echo "\nsmp.property.refresh.cronJobExpression=0 */2 * * * *" >> $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/smp/conf/smp.config.properties \ && sed -i -e "s/127.0.0.1/0.0.0.0/g" /etc/mysql/mysql.conf.d/mysqld.cnf \ && mkdir /opt/jacoco \ && curl -o /opt/jacoco/jacoco-agent.jar http://central.maven.org/maven2/org/jacoco/org.jacoco.agent/$JACOCO_VERSION/org.jacoco.agent-$JACOCO_VERSION-runtime.jar diff --git a/smp-docker/images/tomcat-mysql/entrypoint.sh b/smp-docker/images/tomcat-mysql/entrypoint.sh index 3bf0bc3a9dba1855b524261719f447b5151e7c83..f487758b8cb389caefb058a27ce7606e4772d594 100755 --- a/smp-docker/images/tomcat-mysql/entrypoint.sh +++ b/smp-docker/images/tomcat-mysql/entrypoint.sh @@ -12,7 +12,10 @@ DATA_DIR=/smp/data MYSQL_DATA_DIR=${DATA_DIR}/mysql TOMCAT_DIR=${DATA_DIR}/tomcat TOMCAT_HOME=${SMP_HOME}/apache-tomcat-$TOMCAT_VERSION/ - +SQUID_CONFIG=/etc/squid/squid.smp.conf +SQUID_USERS=/etc/squid/passwd +SQUID_USER="proxyuser" +SQUID_PASSWORD="test123" if [ ! -d ${DATA_DIR} ]; then mkdir -p ${DATA_DIR} @@ -20,7 +23,7 @@ fi init_tomcat() { # add java code coverage angent to image - export JAVA_OPTS="-javaagent:/opt/jacoco/jacoco-agent.jar=output=tcpserver,address=*,port=6400" + export JAVA_OPTS="-javaagent:/opt/jacoco/jacoco-agent.jar=output=tcpserver,address=*,port=6901" echo "[INFO] init tomcat folders: $tfile" @@ -109,13 +112,35 @@ init_mysql() { fi sleep 5s - # start mysql - + # start mysql +} + +init_squid() { +echo '[INFO] start squid' +# create squid property file + echo "auth_param basic program /usr/lib/squid3/basic_ncsa_auth $SQUID_USERS" > $SQUID_CONFIG + echo "auth_param basic children 1" >> $SQUID_CONFIG + echo "auth_param basic credentialsttl 1 minute" >> $SQUID_CONFIG + echo "auth_param basic casesensitive off" >> $SQUID_CONFIG + echo "" >> $SQUID_CONFIG + echo "acl auth proxy_auth REQUIRED" >> $SQUID_CONFIG + echo "http_access allow auth" >> $SQUID_CONFIG + echo "http_access deny all" >> $SQUID_CONFIG + echo "" >> $SQUID_CONFIG +# just to make sure this configuration is loaded :) + echo "http_port 3127" >> $SQUID_CONFIG + + # create a user + htpasswd -b -c $SQUID_USERS $SQUID_USER $SQUID_PASSWORD + + $(which squid) -N -f /etc/squid/squid.conf -z + { nohup $(which squid) -f /etc/squid/squid.smp.conf -NYCd 1 &> /var/log/squid/squid.out & } + } init_mysql init_tomcat - +init_squid echo '[INFO] start running SMP' chmod u+x $SMP_HOME/apache-tomcat-$TOMCAT_VERSION/bin/*.sh diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java index 7226dc1d1c01d5e30bbb3f691ee3696e7b8d93cb..19c6008e7dea7b44b142aa39a0fccda342928d2c 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/sml/SmlConnector.java @@ -428,14 +428,16 @@ public class SmlConnector implements ApplicationContextAware { String proxyPassword = configurationService.getProxyCredentialToken(); - LOG.info("Configuring proxy for BDMSL integration client: {}:{}@{}:{}", proxyUser, "########", proxyServer, proxyPort.isPresent() ? proxyPort.get() : ""); + LOG.info("Configuring proxy for BDMSL integration client: {}:{}@{}:{}", proxyUser, "******", proxyServer, proxyPort.isPresent() ? proxyPort.get() : ""); httpConduit.getClient().setProxyServerType(ProxyServerType.HTTP); httpConduit.getClient().setProxyServer(proxyServer); if (proxyPort.isPresent()) { httpConduit.getClient().setProxyServerPort(proxyPort.get()); } - ProxyAuthorizationPolicy proxyAuth = new ProxyAuthorizationPolicy(); + if (!StringUtils.isBlank(proxyUser)){ + ProxyAuthorizationPolicy proxyAuth = new ProxyAuthorizationPolicy(); + proxyAuth.setAuthorizationType("Basic"); LOG.debug("Set proxy authentication {}", proxyUser); proxyAuth.setUserName(proxyUser); proxyAuth.setPassword(proxyPassword);