cleanup and upgrade

This commit is contained in:
DOHA 2016-01-05 19:55:11 +02:00
parent 4a029959af
commit 6b10b326a2
10 changed files with 42 additions and 76 deletions

View File

@ -128,7 +128,6 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -164,7 +163,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
@ -174,7 +172,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration> <configuration>
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration> </configuration>
@ -183,7 +180,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration> <configuration>
<excludes> <excludes>
<!-- <exclude>**/*ProductionTest.java</exclude> --> <!-- <exclude>**/*ProductionTest.java</exclude> -->

View File

@ -31,7 +31,7 @@
<dependency> <dependency>
<groupId>io.katharsis</groupId> <groupId>io.katharsis</groupId>
<artifactId>katharsis-servlet</artifactId> <artifactId>katharsis-servlet</artifactId>
<version>1.0.0</version> <version>${katharsis.version}</version>
</dependency> </dependency>
<!-- test --> <!-- test -->
@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>com.jayway.restassured</groupId> <groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId> <artifactId>rest-assured</artifactId>
<version>2.4.0</version> <version>${restassured.version}</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -60,6 +60,8 @@
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<katharsis.version>1.0.0</katharsis.version>
<restassured.version>2.4.0</restassured.version>
</properties> </properties>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.4.RELEASE</version> <version>1.3.1.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>
@ -39,7 +39,7 @@
<!-- Is the ApacheDS server - 1.5.6 and 1.5.7 don't work --> <!-- Is the ApacheDS server - 1.5.6 and 1.5.7 don't work -->
<groupId>org.apache.directory.server</groupId> <groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-jndi</artifactId> <artifactId>apacheds-server-jndi</artifactId>
<version>1.5.5</version> <version>${apacheds.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
@ -69,41 +69,7 @@
</build> </build>
<properties> <properties>
<!-- Spring --> <apacheds.version>1.5.5</apacheds.version>
<org.springframework.version>4.2.4.RELEASE</org.springframework.version>
<org.springframework.security.version>4.0.3.RELEASE</org.springframework.security.version>
<!-- persistence -->
<hibernate.version>4.3.11.Final</hibernate.version>
<mysql-connector-java.version>5.1.37</mysql-connector-java.version>
<!-- logging -->
<org.slf4j.version>1.7.13</org.slf4j.version>
<logback.version>1.1.3</logback.version>
<!-- various -->
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
<!-- util -->
<guava.version>19.0</guava.version>
<commons-lang3.version>3.4</commons-lang3.version>
<!-- testing -->
<org.hamcrest.version>1.3</org.hamcrest.version>
<junit.version>4.12</junit.version>
<mockito.version>1.10.19</mockito.version>
<httpcore.version>4.4.1</httpcore.version>
<httpclient.version>4.5</httpclient.version>
<rest-assured.version>2.4.1</rest-assured.version>
<!-- Maven plugins -->
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -9,7 +9,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
* Security Configuration - LDAP and HTTP Authorizations. * Security Configuration - LDAP and HTTP Authorizations.
*/ */
@Configuration @Configuration
// @ImportResource({ "classpath:webSecurityConfig.xml" }) // @ImportResource({ "classpath:webSecurityConfig.xml" }) //=> uncomment to use equivalent xml config
public class SecurityConfig extends WebSecurityConfigurerAdapter { public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
@ -20,7 +20,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated(); http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated();
http.formLogin().loginPage("/login").permitAll().loginProcessingUrl("/j_spring_security_check").and().logout().logoutSuccessUrl("/"); http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/");
} }
} }

View File

@ -21,7 +21,7 @@
<p th:if="${param.logout}" class="alert">You have been logged out</p> <p th:if="${param.logout}" class="alert">You have been logged out</p>
<p th:if="${param.error}" class="alert alert-error">There was an error, please try again</p> <p th:if="${param.error}" class="alert alert-error">There was an error, please try again</p>
<h2>Login with Username and Password</h2> <h2>Login with Username and Password</h2>
<form name="form" th:action="@{/j_spring_security_check}" action="/login" method="POST"> <form name="form" th:action="@{/login}" method="POST">
<fieldset> <fieldset>
<input type="text" name="username" value="" placeholder="Username" /> <input type="text" name="username" value="" placeholder="Username" />
<input type="password" name="password" placeholder="Password" /> <input type="password" name="password" placeholder="Password" />

View File

@ -13,10 +13,7 @@
<intercept-url pattern="/login" access="permitAll"/> <intercept-url pattern="/login" access="permitAll"/>
<intercept-url pattern="/secure" access="isAuthenticated()"/> <intercept-url pattern="/secure" access="isAuthenticated()"/>
<form-login login-page='/login' default-target-url="/" <form-login login-page='/login' default-target-url="/" authentication-failure-url="/login?error" />
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password"/>
<logout logout-success-url="/" /> <logout logout-success-url="/" />
</http> </http>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version> <version>1.3.1.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>
@ -113,12 +113,12 @@
<dependency> <dependency>
<groupId>com.mysema.querydsl</groupId> <groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId> <artifactId>querydsl-apt</artifactId>
<version>3.6.2</version> <version>${querydsl.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.mysema.querydsl</groupId> <groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId> <artifactId>querydsl-jpa</artifactId>
<version>3.6.2</version> <version>${querydsl.version}</version>
</dependency> </dependency>
<!-- Rsql --> <!-- Rsql -->
@ -126,7 +126,7 @@
<dependency> <dependency>
<groupId>cz.jirutka.rsql</groupId> <groupId>cz.jirutka.rsql</groupId>
<artifactId>rsql-parser</artifactId> <artifactId>rsql-parser</artifactId>
<version>2.0.0</version> <version>${rsql.version}</version>
</dependency> </dependency>
<!-- web --> <!-- web -->
@ -144,7 +144,6 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId> <artifactId>httpcore</artifactId>
<version>${httpcore.version}</version>
</dependency> </dependency>
<!-- persistence --> <!-- persistence -->
@ -164,7 +163,7 @@
<dependency> <dependency>
<groupId>xml-apis</groupId> <groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId> <artifactId>xml-apis</artifactId>
<version>1.4.01</version> <version>${xml-apis.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javassist</groupId> <groupId>org.javassist</groupId>
@ -200,7 +199,7 @@
<dependency> <dependency>
<groupId>com.thoughtworks.xstream</groupId> <groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId> <artifactId>xstream</artifactId>
<version>1.4.8</version> <version>${xstream.version}</version>
</dependency> </dependency>
<!-- util --> <!-- util -->
@ -243,7 +242,6 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -267,7 +265,7 @@
<dependency> <dependency>
<groupId>com.jayway.restassured</groupId> <groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId> <artifactId>rest-assured</artifactId>
<version>2.4.0</version> <version>${rest-assured.version}</version>
<scope>test</scope> <scope>test</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -344,7 +342,7 @@
<plugin> <plugin>
<groupId>com.mysema.maven</groupId> <groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId> <artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version> <version>${apt-maven-plugin.version}</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@ -434,9 +432,12 @@
<mysql-connector-java.version>5.1.37</mysql-connector-java.version> <mysql-connector-java.version>5.1.37</mysql-connector-java.version>
<spring-data-jpa.version>1.7.2.RELEASE</spring-data-jpa.version> <spring-data-jpa.version>1.7.2.RELEASE</spring-data-jpa.version>
<!-- marshalling --> <rsql.version>2.0.0</rsql.version>
<querydsl.version>3.6.2</querydsl.version>
<!-- marshalling -->
<jackson.version>2.5.5</jackson.version> <jackson.version>2.5.5</jackson.version>
<xml-apis.version>1.4.01</xml-apis.version>
<!-- logging --> <!-- logging -->
<org.slf4j.version>1.7.13</org.slf4j.version> <org.slf4j.version>1.7.13</org.slf4j.version>
@ -444,6 +445,7 @@
<!-- various --> <!-- various -->
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version> <hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
<xstream.version>1.4.8</xstream.version>
<!-- util --> <!-- util -->
<guava.version>19.0</guava.version> <guava.version>19.0</guava.version>
@ -464,7 +466,7 @@
<maven-war-plugin.version>2.6</maven-war-plugin.version> <maven-war-plugin.version>2.6</maven-war-plugin.version>
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version> <cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
<apt-maven-plugin.version>1.1.3</apt-maven-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -82,14 +82,14 @@
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version> <version>${javax.servlet-api.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId> <artifactId>jstl</artifactId>
<version>1.2</version> <version>${jstl.version}</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
@ -98,7 +98,7 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.2.2</version> <version>${jackson.version}</version>
</dependency> </dependency>
<!-- util --> <!-- util -->
@ -111,7 +111,7 @@
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.1</version> <version>${commons-lang3.version}</version>
</dependency> </dependency>
<!-- logging --> <!-- logging -->
@ -171,13 +171,13 @@
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version> <version>${springfox.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId> <artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version> <version>${springfox.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
@ -263,6 +263,10 @@
<!-- various --> <!-- various -->
<hibernate-validator.version>5.2.2.Final</hibernate-validator.version> <hibernate-validator.version>5.2.2.Final</hibernate-validator.version>
<javax.servlet-api.version>3.0.1</javax.servlet-api.version>
<jstl.version>1.2</jstl.version>
<jackson.version>2.2.2</jackson.version>
<springfox.version>2.2.2</springfox.version>
<!-- util --> <!-- util -->
<guava.version>19.0</guava.version> <guava.version>19.0</guava.version>

View File

@ -35,19 +35,16 @@ public class SecurityJavaConfig extends WebSecurityConfigurerAdapter {
} }
@Override @Override
protected void configure(final HttpSecurity http) throws Exception { // @formatter:off protected void configure(final HttpSecurity http) throws Exception {// @formatter:off
http http
.csrf().disable() .csrf().disable()
.exceptionHandling() .exceptionHandling()
.authenticationEntryPoint(restAuthenticationEntryPoint) .authenticationEntryPoint(restAuthenticationEntryPoint)
.and() .and()
.authorizeRequests() .authorizeRequests()
.antMatchers("/api/foos").authenticated() .antMatchers("/api/**").authenticated()
.and() .and()
.formLogin() .formLogin()
.loginProcessingUrl("/j_spring_security_check")
.usernameParameter("j_username")
.passwordParameter("j_password")
.successHandler(authenticationSuccessHandler) .successHandler(authenticationSuccessHandler)
.failureHandler(new SimpleUrlAuthenticationFailureHandler()) .failureHandler(new SimpleUrlAuthenticationFailureHandler())
.and() .and()

View File

@ -11,7 +11,9 @@
<http use-expressions="true" entry-point-ref="restAuthenticationEntryPoint"> <http use-expressions="true" entry-point-ref="restAuthenticationEntryPoint">
<intercept-url pattern="/api/**" access="isAuthenticated()"/> <intercept-url pattern="/api/**" access="isAuthenticated()"/>
<sec:form-login authentication-success-handler-ref="mySuccessHandler" authentication-failure-handler-ref="myFailureHandler"/> <csrf disabled="true"/>
<form-login authentication-success-handler-ref="mySuccessHandler" authentication-failure-handler-ref="myFailureHandler"/>
<logout/> <logout/>
</http> </http>