Skip to content

Commit 0f9ba3d

Browse files
author
eugenp
committed
upgrade and cleanup work
1 parent 2f0197d commit 0f9ba3d

32 files changed

Lines changed: 117 additions & 106 deletions

‎api/src/main/java/org/rest/sec/security/RestAuthenticationProvider.java‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434

3535
/**
3636
* - note: the original is DaoAuthenticationProvider <br/>
37-
* An {@link AuthenticationProvider} implementation that retrieves user details from a {@link UserDetailsService}.
37+
* An {@link AuthenticationProvider} implementation that retrieves user details
38+
* from a {@link UserDetailsService}.
3839
*/
3940
@Component
4041
@Profile("client")
@@ -44,7 +45,8 @@ public class RestAuthenticationProvider extends AbstractUserDetailsAuthenticatio
4445
@Qualifier("authenticationRestTemplate")
4546
private AuthenticationRestTemplate authenticationApi;
4647

47-
// ~ Instance fields ================================================================================================
48+
// ~ Instance fields
49+
// ================================================================================================
4850

4951
private PasswordEncoder passwordEncoder = new PlaintextPasswordEncoder();
5052

@@ -54,7 +56,8 @@ public RestAuthenticationProvider() {
5456
super();
5557
}
5658

57-
// ~ Methods ========================================================================================================
59+
// ~ Methods
60+
// ========================================================================================================
5861

5962
@Override
6063
@SuppressWarnings("deprecation")
@@ -68,15 +71,15 @@ protected void additionalAuthenticationChecks(final UserDetails userDetails, fin
6871
if (authentication.getCredentials() == null) {
6972
logger.debug("Authentication failed: no credentials provided");
7073

71-
throw new BadCredentialsException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), userDetails);
74+
throw new BadCredentialsException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
7275
}
7376

7477
final String presentedPassword = authentication.getCredentials().toString();
7578

7679
if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), presentedPassword, salt)) {
7780
logger.debug("Authentication failed: password does not match stored value");
7881

79-
throw new BadCredentialsException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), userDetails);
82+
throw new BadCredentialsException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
8083
}
8184
}
8285

@@ -88,7 +91,9 @@ protected final UserDetails retrieveUser(final String name, final UsernamePasswo
8891
try {
8992
final ResponseEntity<User> authenticationResponse = authenticationApi.authenticate(name, password);
9093
if (authenticationResponse.getStatusCode().value() == 401) {
91-
// temporary - the idea here is to generate the not authorized exception - not by hand, but by returning wrong credentials which in turn will be refused later
94+
// temporary - the idea here is to generate the not authorized
95+
// exception - not by hand, but by returning wrong credentials
96+
// which in turn will be refused later
9297
return new org.springframework.security.core.userdetails.User("wrongUsername", "wrongPass", Lists.<GrantedAuthority> newArrayList());
9398
}
9499

@@ -111,13 +116,18 @@ protected final UserDetails retrieveUser(final String name, final UsernamePasswo
111116
}
112117

113118
/**
114-
* Sets the PasswordEncoder instance to be used to encode and validate passwords. If not set, the password will be compared as plain text.
119+
* Sets the PasswordEncoder instance to be used to encode and validate
120+
* passwords. If not set, the password will be compared as plain text.
115121
* <p/>
116-
* For systems which are already using salted password which are encoded with a previous release, the encoder should be of type {@code org.springframework.security.authentication.encoding.PasswordEncoder}. Otherwise, the recommended
117-
* approach is to use {@code org.springframework.security.crypto.password.PasswordEncoder}.
118-
*
122+
* For systems which are already using salted password which are encoded
123+
* with a previous release, the encoder should be of type
124+
* {@code org.springframework.security.authentication.encoding.PasswordEncoder}
125+
* . Otherwise, the recommended approach is to use
126+
* {@code org.springframework.security.crypto.password.PasswordEncoder}.
127+
*
119128
* @param passwordEncoderToSet
120-
* must be an instance of one of the {@code PasswordEncoder} types.
129+
* must be an instance of one of the {@code PasswordEncoder}
130+
* types.
121131
*/
122132
public void setPasswordEncoder(final Object passwordEncoderToSet) {
123133
Assert.notNull(passwordEncoderToSet, "passwordEncoder cannot be null");
@@ -158,12 +168,18 @@ protected PasswordEncoder getPasswordEncoder() {
158168
}
159169

160170
/**
161-
* The source of salts to use when decoding passwords. <code>null</code> is a valid value, meaning the <code>DaoAuthenticationProvider</code> will present <code>null</code> to the relevant <code>PasswordEncoder</code>.
171+
* The source of salts to use when decoding passwords. <code>null</code> is
172+
* a valid value, meaning the <code>DaoAuthenticationProvider</code> will
173+
* present <code>null</code> to the relevant <code>PasswordEncoder</code>.
162174
* <p/>
163-
* Instead, it is recommended that you use an encoder which uses a random salt and combines it with the password field. This is the default approach taken in the {@code org.springframework.security.crypto.password} package.
164-
*
175+
* Instead, it is recommended that you use an encoder which uses a random
176+
* salt and combines it with the password field. This is the default
177+
* approach taken in the
178+
* {@code org.springframework.security.crypto.password} package.
179+
*
165180
* @param saltSourceToSet
166-
* to use when attempting to decode passwords via the <code>PasswordEncoder</code>
181+
* to use when attempting to decode passwords via the
182+
* <code>PasswordEncoder</code>
167183
*/
168184
public void setSaltSource(final SaltSource saltSourceToSet) {
169185
saltSource = saltSourceToSet;

‎common-client/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187

188188
<dependency>
189189
<groupId>junit</groupId>
190-
<artifactId>junit-dep</artifactId>
190+
<artifactId>junit</artifactId>
191191
<version>${junit.version}</version>
192192
<scope>test</scope>
193193
</dependency>

‎common-client/src/main/java/org/rest/common/client/template/AbstractNamedClientRestTemplate.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.rest.common.util.SearchField;
99

1010
@SuppressWarnings({ "unchecked" })
11-
public abstract class AbstractNamedClientRestTemplate<T extends INameableEntity> extends AbstractClientRestTemplate<T> implements IClientTemplate<T> {
11+
public abstract class AbstractNamedClientRestTemplate<T extends INameableEntity> extends AbstractClientRestTemplate<T>implements IClientTemplate<T> {
1212

1313
public AbstractNamedClientRestTemplate(final Class<T> clazzToSet) {
1414
super(clazzToSet);

‎common/eclipse/CURRENT.launch‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<booleanAttribute key="M2_OFFLINE" value="false"/>
77
<stringAttribute key="M2_PROFILES" value=""/>
88
<listAttribute key="M2_PROPERTIES"/>
9-
<stringAttribute key="M2_RUNTIME" value="/opt/maven/apache-maven-3.2.1"/>
9+
<stringAttribute key="M2_RUNTIME" value="C:\opt\maven\apache-maven-3.2.1"/>
1010
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
1111
<intAttribute key="M2_THREADS" value="1"/>
1212
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>

‎common/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295

296296
<dependency>
297297
<groupId>junit</groupId>
298-
<artifactId>junit-dep</artifactId>
298+
<artifactId>junit</artifactId>
299299
<version>${junit.version}</version>
300300
<scope>test</scope>
301301
</dependency>

‎common/src/main/java/org/rest/common/persistence/service/AbstractRawService.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public List<T> searchPaginated(final String queryString, final int page, final i
8686
return Lists.newArrayList(resultPage.getContent());
8787
}
8888

89-
@SuppressWarnings("null")
9089
@Override
9190
public List<T> searchAll(final Triple<String, ClientOperation, String>... constraints) {
9291
Preconditions.checkState(constraints != null);
@@ -103,7 +102,6 @@ public List<T> searchAll(final Triple<String, ClientOperation, String>... constr
103102
return getSpecificationExecutor().findAll(specifications);
104103
}
105104

106-
@SuppressWarnings("null")
107105
@Override
108106
public T searchOne(final Triple<String, ClientOperation, String>... constraints) {
109107
Preconditions.checkState(constraints != null);

‎common/src/main/java/org/rest/common/persistence/service/AbstractService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import org.rest.common.persistence.model.INameableEntity;
44

5-
public abstract class AbstractService<T extends INameableEntity> extends AbstractRawService<T> implements IService<T> {
5+
public abstract class AbstractService<T extends INameableEntity> extends AbstractRawService<T>implements IService<T> {
66

77
public AbstractService(final Class<T> clazzToSet) {
88
super(clazzToSet);

‎common/src/test/java/org/rest/common/web/event/PaginatedResultsRetrievedDiscoverabilityListenerUnitTest.java‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ public final void givenThreePages_whenNotifierToAddLinkForFirstPage_thenNextAndL
6767
listener.onApplicationEvent(new PaginatedResultsRetrievedEvent<Integer>(RESOURCE_CLASS, uriComponentsBuilder, httpServletResponse, pageToSet, totalPagesToSet, PAGE_SIZE_TO_SET));
6868

6969
// then
70-
verify(httpServletResponse).addHeader(
71-
eq(HttpHeaders.LINK),
72-
eq(LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (pageToSet + 1) + "&size=" + PAGE_SIZE_TO_SET, "next") + ", "
73-
+ LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (totalPagesToSet - 1) + "&size=" + PAGE_SIZE_TO_SET, "last")));
70+
verify(httpServletResponse).addHeader(eq(HttpHeaders.LINK), eq(LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (pageToSet + 1) + "&size=" + PAGE_SIZE_TO_SET, "next") + ", "
71+
+ LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (totalPagesToSet - 1) + "&size=" + PAGE_SIZE_TO_SET, "last")));
7472
}
7573

7674
@Test
@@ -83,10 +81,8 @@ public final void givenThreePages_whenNotifiedToAddLinkForThirdPage_thenPrevious
8381
listener.onApplicationEvent(new PaginatedResultsRetrievedEvent<Integer>(RESOURCE_CLASS, uriComponentsBuilder, httpServletResponse, pageToSet, totalPagesToSet, PAGE_SIZE_TO_SET));
8482

8583
// then
86-
verify(httpServletResponse).addHeader(
87-
eq(HttpHeaders.LINK),
88-
eq(LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (pageToSet - 1) + "&size=" + PAGE_SIZE_TO_SET, "prev") + ", "
89-
+ LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=0&size=" + PAGE_SIZE_TO_SET, "first")));
84+
verify(httpServletResponse).addHeader(eq(HttpHeaders.LINK), eq(LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (pageToSet - 1) + "&size=" + PAGE_SIZE_TO_SET, "prev") + ", "
85+
+ LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=0&size=" + PAGE_SIZE_TO_SET, "first")));
9086
}
9187

9288
@Test
@@ -99,8 +95,7 @@ public final void givenThreePages_whenNotifiedToAddLinkForSecondPage_thenAllLink
9995
listener.onApplicationEvent(new PaginatedResultsRetrievedEvent<Integer>(RESOURCE_CLASS, uriComponentsBuilder, httpServletResponse, pageToSet, totalPagesToSet, PAGE_SIZE_TO_SET));
10096

10197
// then
102-
verify(httpServletResponse).addHeader(
103-
eq(HttpHeaders.LINK),
98+
verify(httpServletResponse).addHeader(eq(HttpHeaders.LINK),
10499
eq(LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (pageToSet + 1) + "&size=" + PAGE_SIZE_TO_SET, "next") + ", "
105100
+ LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=" + (pageToSet - 1) + "&size=" + PAGE_SIZE_TO_SET, "prev") + ", "
106101
+ LinkUtil.createLinkHeader(RESOURCE_HTTP_LOCATION + "/" + RESOURCE_CLASS.getSimpleName().toLowerCase() + "?page=0&size=" + PAGE_SIZE_TO_SET, "first") + ", "

‎pom.xml‎

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,60 +59,59 @@
5959
<properties>
6060

6161
<!-- Spring related -->
62-
<spring.version>4.0.4.RELEASE</spring.version>
63-
<spring-security.version>3.2.3.RELEASE</spring-security.version>
64-
<javassist.version>3.18.1-GA</javassist.version>
65-
<aspectjweaver.version>1.8.0</aspectjweaver.version>
62+
<spring.version>4.2.0.RELEASE</spring.version>
63+
<spring-security.version>4.0.2.RELEASE</spring-security.version>
64+
<javassist.version>3.20.0-GA</javassist.version>
65+
<aspectjweaver.version>1.8.6</aspectjweaver.version>
6666

6767
<!-- web -->
68-
<javax.servlet-api.version>3.0.1</javax.servlet-api.version>
68+
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
6969

7070
<!-- marshalling -->
71-
<jackson.version>2.2.3</jackson.version>
72-
<jaxb-api.version>2.2.11</jaxb-api.version>
73-
<xstream.version>1.4.7</xstream.version>
71+
<jackson.version>2.6.0</jackson.version>
72+
<jaxb-api.version>2.2.12</jaxb-api.version>
73+
<xstream.version>1.4.8</xstream.version>
7474

7575
<!-- commons and utils -->
76-
<commons-lang3.version>3.3.2</commons-lang3.version>
77-
<guava.version>17.0</guava.version>
76+
<commons-lang3.version>3.4</commons-lang3.version>
77+
<guava.version>18.0</guava.version>
7878

7979
<!-- UNSORTED -->
80-
<commons-codec.version>1.9</commons-codec.version>
80+
<commons-codec.version>1.10</commons-codec.version>
8181

8282
<!-- persistence -->
83-
<mysql-connector-java.version>5.1.30</mysql-connector-java.version> <!-- latest version on: 06.05.2014 - http://dev.mysql.com/downloads/connector/j/ -->
84-
<hibernate.version>4.3.0.Final</hibernate.version>
85-
<hibernate-jpamodelgen.version>4.3.5.Final</hibernate-jpamodelgen.version>
83+
<mysql-connector-java.version>5.1.36</mysql-connector-java.version> <!-- latest version on: 10.08.2015 - http://dev.mysql.com/downloads/connector/j/ -->
84+
<hibernate.version>4.3.11.Final</hibernate.version>
85+
<hibernate-jpamodelgen.version>4.3.11.Final</hibernate-jpamodelgen.version>
8686
<commons-dbcp.version>1.4</commons-dbcp.version>
87-
<querydsl.version>3.3.3</querydsl.version>
88-
<spring-data-jpa.version>1.5.2.RELEASE</spring-data-jpa.version>
87+
<querydsl.version>4.0.3</querydsl.version>
88+
<spring-data-jpa.version>1.8.2.RELEASE</spring-data-jpa.version>
8989

90-
<h2.version>1.4.178</h2.version>
91-
<hsqldb.version>2.3.2</hsqldb.version>
90+
<h2.version>1.4.187</h2.version>
91+
<hsqldb.version>2.3.3</hsqldb.version>
9292

9393
<validation-api.version>1.1.0.Final</validation-api.version>
94-
<hibernate-validator.version>5.1.1.Final</hibernate-validator.version>
94+
<hibernate-validator.version>5.2.1.Final</hibernate-validator.version>
9595

9696
<!-- logging -->
97-
<org.slf4j.version>1.7.7</org.slf4j.version>
98-
<logback.version>1.1.2</logback.version>
97+
<org.slf4j.version>1.7.12</org.slf4j.version>
98+
<logback.version>1.1.3</logback.version>
9999

100100
<!-- testing -->
101101
<org.hamcrest.version>1.3</org.hamcrest.version>
102-
<junit.version>4.11</junit.version>
103-
<mockito.version>1.9.5</mockito.version>
102+
<junit.version>4.12</junit.version>
103+
<mockito.version>1.10.19</mockito.version>
104104

105-
<httpcore.version>4.3.2</httpcore.version>
106-
<httpclient.version>4.3.3</httpclient.version>
105+
<httpcore.version>4.4.1</httpcore.version>
106+
<httpclient.version>4.5</httpclient.version>
107107

108-
<rest-assured.version>2.3.1</rest-assured.version>
108+
<rest-assured.version>2.5.0</rest-assured.version>
109109

110110
<!-- maven plugins -->
111-
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
112-
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
113-
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
114-
<jrebel-maven-plugin.version>1.1.5</jrebel-maven-plugin.version>
115-
<cargo-maven2-plugin.version>1.4.8</cargo-maven2-plugin.version>
111+
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
112+
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
113+
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
114+
<cargo-maven2-plugin.version>1.4.15</cargo-maven2-plugin.version>
116115

117116
</properties>
118117

@@ -137,7 +136,7 @@
137136

138137
<modules>
139138
<module>common-client</module>
140-
139+
141140
<module>common</module>
142141
<module>test</module>
143142

‎sec/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
<dependency>
6969
<groupId>junit</groupId>
70-
<artifactId>junit-dep</artifactId>
70+
<artifactId>junit</artifactId>
7171
<version>${junit.version}</version>
7272
<scope>test</scope>
7373
</dependency>

0 commit comments

Comments
 (0)