Skip to content

Commit dda108d

Browse files
author
Joshua Cold
committed
Merge remote-tracking branch 'upstream/master'
# Conflicts: # rest-test-service/src/main/java/password/pwm/resttest/SmsPostResponseBody.java
2 parents 0122b91 + 73d7b1b commit dda108d

File tree

109 files changed

+2652
-2325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2652
-2325
lines changed

build/checkstyle-jsp.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
~ Password Management Servlets (PWM)
4+
~ http://www.pwm-project.org
5+
~
6+
~ Copyright (c) 2006-2009 Novell, Inc.
7+
~ Copyright (c) 2009-2018 The PWM Project
8+
~
9+
~ This program is free software; you can redistribute it and/or modify
10+
~ it under the terms of the GNU General Public License as published by
11+
~ the Free Software Foundation; either version 2 of the License, or
12+
~ (at your option) any later version.
13+
~
14+
~ This program is distributed in the hope that it will be useful,
15+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
~ GNU General Public License for more details.
18+
~
19+
~ You should have received a copy of the GNU General Public License
20+
~ along with this program; if not, write to the Free Software
21+
~ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22+
-->
23+
24+
<!DOCTYPE module PUBLIC
25+
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
26+
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
27+
28+
<!--
29+
PWM Checkstyle definition
30+
-->
31+
32+
<module name="Checker">
33+
<property name="fileExtensions" value="java, xml, jsp"/>
34+
35+
<module name="TreeWalker" >
36+
<module name="Regexp">
37+
<property name="format" value="WarnJavaScriptNotEnabledMessage"/>
38+
<property name="illegalPattern" value="true"/>
39+
</module>
40+
</module>
41+
</module>

build/checkstyle.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
<module name="Checker">
3333

34+
<property name="cacheFile" value="target/checkstyle.cache"/>
35+
3436
<module name="SuppressionFilter">
3537
<property name="file" value="${basedir}/build/checkstyle-suppression.xml" />
3638
</module>
@@ -63,7 +65,6 @@
6365
</module>
6466

6567
<module name="TreeWalker" >
66-
<property name="cacheFile" value="target/checkstyle.cache"/>
6768

6869
<!-- required for SuppressWarningsFilter (and other Suppress* rules not used here) -->
6970
<!-- see http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder -->

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<plugin>
7171
<groupId>com.github.eirslett</groupId>
7272
<artifactId>frontend-maven-plugin</artifactId>
73-
<version>1.6</version>
73+
<version>1.7.5</version>
7474
<configuration>
7575
<nodeVersion>v8.9.4</nodeVersion>
7676
<npmVersion>5.6.0</npmVersion>

data-service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
<dependency>
151151
<groupId>org.apache.httpcomponents</groupId>
152152
<artifactId>httpclient</artifactId>
153-
<version>4.5.7</version>
153+
<version>4.5.8</version>
154154
</dependency>
155155
<dependency>
156156
<groupId>log4j</groupId>

data-service/src/main/java/password/pwm/receiver/TelemetryRestReceiver.java

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@
2222

2323
package password.pwm.receiver;
2424

25-
import org.apache.commons.io.IOUtils;
26-
import password.pwm.PwmConstants;
2725
import password.pwm.bean.TelemetryPublishBean;
2826
import password.pwm.error.ErrorInformation;
2927
import password.pwm.error.PwmError;
3028
import password.pwm.error.PwmUnrecoverableException;
3129
import password.pwm.i18n.Message;
30+
import password.pwm.util.ServletUtility;
3231
import password.pwm.util.java.JsonUtil;
3332
import password.pwm.ws.server.RestResultBean;
3433

@@ -38,9 +37,6 @@
3837
import javax.servlet.http.HttpServletRequest;
3938
import javax.servlet.http.HttpServletResponse;
4039
import java.io.IOException;
41-
import java.io.InputStreamReader;
42-
import java.io.Reader;
43-
import java.io.StringWriter;
4440

4541
@WebServlet(
4642
name = "TelemetryRestReceiver",
@@ -58,7 +54,7 @@ protected void doPost( final HttpServletRequest req, final HttpServletResponse r
5854
try
5955
{
6056
resp.setHeader( "Content", "application/json" );
61-
final String input = readRequestBodyAsString( req, 1024 * 1024 );
57+
final String input = ServletUtility.readRequestBodyAsString( req, 1024 * 1024 );
6258
final TelemetryPublishBean telemetryPublishBean = JsonUtil.deserialize( input, TelemetryPublishBean.class );
6359
final Storage stoage = ContextManager.getContextManager( this.getServletContext() ).getApp().getStorage();
6460
stoage.store( telemetryPublishBean );
@@ -74,36 +70,4 @@ protected void doPost( final HttpServletRequest req, final HttpServletResponse r
7470
resp.getWriter().print( restResultBean.toJson() );
7571
}
7672
}
77-
78-
private static String readRequestBodyAsString( final HttpServletRequest req, final int maxChars )
79-
throws IOException, PwmUnrecoverableException
80-
{
81-
final StringWriter stringWriter = new StringWriter();
82-
final Reader readerStream = new InputStreamReader(
83-
req.getInputStream(),
84-
PwmConstants.DEFAULT_CHARSET
85-
);
86-
87-
try
88-
{
89-
IOUtils.copy( readerStream, stringWriter );
90-
}
91-
catch ( Exception e )
92-
{
93-
final String errorMsg = "error reading request body stream: " + e.getMessage();
94-
throw new PwmUnrecoverableException( new ErrorInformation( PwmError.ERROR_INTERNAL, errorMsg ) );
95-
}
96-
finally
97-
{
98-
IOUtils.closeQuietly( readerStream );
99-
}
100-
101-
final String stringValue = stringWriter.toString();
102-
if ( stringValue.length() > maxChars )
103-
{
104-
final String msg = "input request body is to big, size=" + stringValue.length() + ", max=" + maxChars;
105-
throw new PwmUnrecoverableException( new ErrorInformation( PwmError.ERROR_INTERNAL, msg ) );
106-
}
107-
return stringValue;
108-
}
10973
}

docker/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<plugin>
3535
<groupId>com.google.cloud.tools</groupId>
3636
<artifactId>jib-maven-plugin</artifactId>
37-
<version>1.0.0</version>
37+
<version>1.0.2</version>
3838
<executions>
3939
<execution>
4040
<id>make-docker-image</id>

pom.xml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<plugin>
7878
<groupId>org.apache.maven.plugins</groupId>
7979
<artifactId>maven-javadoc-plugin</artifactId>
80-
<version>3.0.1</version>
80+
<version>3.1.0</version>
8181
<executions>
8282
<execution>
8383
<goals>
@@ -99,6 +99,7 @@
9999
<Implementation-Version-Display>v${project.version} b${build.number} r${build.revision}</Implementation-Version-Display>
100100
</manifestEntries>
101101
</archive>
102+
<source>8</source>
102103
</configuration>
103104
</execution>
104105
</executions>
@@ -171,7 +172,7 @@
171172
<dependency>
172173
<groupId>com.puppycrawl.tools</groupId>
173174
<artifactId>checkstyle</artifactId>
174-
<version>8.18</version>
175+
<version>8.19</version>
175176
</dependency>
176177
</dependencies>
177178
<executions>
@@ -180,7 +181,7 @@
180181
<phase>validate</phase>
181182
<configuration>
182183
<propertyExpansion>basedir=${project.root.basedir}</propertyExpansion>
183-
<configLocation>${project.root.basedir}/build/checkstyle.xml</configLocation>
184+
<configLocation>build/checkstyle.xml</configLocation>
184185
<encoding>UTF-8</encoding>
185186
<consoleOutput>true</consoleOutput>
186187
<includeTestResources>true</includeTestResources>
@@ -215,6 +216,27 @@
215216
<goal>check</goal>
216217
</goals>
217218
</execution>
219+
<execution>
220+
<id>checkstyle-jsp</id>
221+
<phase>validate</phase>
222+
<configuration>
223+
<propertyExpansion>basedir=${project.root.basedir}</propertyExpansion>
224+
<configLocation>${project.root.basedir}/build/checkstyle-jsp.xml</configLocation>
225+
<encoding>UTF-8</encoding>
226+
<consoleOutput>true</consoleOutput>
227+
<includeTestResources>true</includeTestResources>
228+
<failsOnError>true</failsOnError>
229+
<includes>**/*.jsp</includes>
230+
<sourceDirectories>
231+
<directory>src</directory>
232+
<directory>src/test</directory>
233+
<directory>src/main/webapp</directory>
234+
</sourceDirectories>
235+
</configuration>
236+
<goals>
237+
<goal>check</goal>
238+
</goals>
239+
</execution>
218240
</executions>
219241
</plugin>
220242
<plugin>
@@ -243,25 +265,20 @@
243265
</execution>
244266
</executions>
245267
</plugin>
246-
</plugins>
247-
</build>
248-
249-
<reporting>
250-
<plugins>
251268
<plugin> <!-- checks owsp vulnerability database -->
252269
<groupId>org.owasp</groupId>
253270
<artifactId>dependency-check-maven</artifactId>
254-
<version>4.0.1</version>
255-
<reportSets>
256-
<reportSet>
257-
<reports>
258-
<report>aggregate</report>
259-
</reports>
260-
</reportSet>
261-
</reportSets>
271+
<version>5.0.0-M2</version>
272+
<executions>
273+
<execution>
274+
<goals>
275+
<goal>check</goal>
276+
</goals>
277+
</execution>
278+
</executions>
262279
</plugin>
263280
</plugins>
264-
</reporting>
281+
</build>
265282

266283
<!-- common dependencies -->
267284
<dependencies>

rest-test-service/src/main/java/password/pwm/resttest/ExternalMacroServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import java.io.IOException;
3737
import java.io.InputStream;
3838
import java.io.PrintWriter;
39-
import java.util.Date;
39+
import java.time.Instant;
4040

4141
@WebServlet(
4242
name = "NewUserServlet",
@@ -65,7 +65,7 @@ protected void doPost( final HttpServletRequest req, final HttpServletResponse r
6565
final String[] messageContent = body.split( "=" );
6666
final String message = messageContent[messageContent.length - 1];
6767
final String username = message.split( "\\+" )[0];
68-
final Date currentDate = new Date();
68+
final Instant currentDate = Instant.now();
6969
final SmsPostResponseBody messageBody = new SmsPostResponseBody( message, currentDate );
7070

7171
instance.addToMap( username, messageBody );

rest-test-service/src/main/java/password/pwm/resttest/SmsPostResponseBody.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222

2323
package password.pwm.resttest;
2424

25-
import java.util.Date;
25+
import java.time.Instant;
2626

2727
public class SmsPostResponseBody
2828
{
2929
private String messageContent;
30-
private Date date;
30+
private Instant date;
3131

32-
public SmsPostResponseBody( final String message, final Date date )
32+
public SmsPostResponseBody( final String message, final Instant date )
3333
{
3434
final String[] strings = message.split( "&" );
3535
this.messageContent = strings[strings.length - 1];
36-
this.date = new Date( date.getTime() );
36+
this.date = Instant.now();
3737
}
3838

3939
public SmsPostResponseBody( final String message )
@@ -42,9 +42,9 @@ public SmsPostResponseBody( final String message )
4242
this.messageContent = strings[strings.length - 1];
4343
}
4444

45-
public SmsPostResponseBody( final Date date )
45+
public SmsPostResponseBody( final Instant date )
4646
{
47-
this.date = new Date( date.getTime() );
47+
this.date = Instant.now();
4848
this.messageContent = "";
4949
}
5050

@@ -63,13 +63,13 @@ public void setMessageContent( final String messageContent )
6363
this.messageContent = messageContent;
6464
}
6565

66-
public Date getDate()
66+
public Instant getDate()
6767
{
68-
return new Date( this.date.getTime() );
68+
return Instant.now();
6969
}
7070

71-
public void setDate( final Date date )
71+
public void setDate( final Instant date )
7272
{
73-
this.date = new Date( this.date.getTime() );
73+
this.date = Instant.now();
7474
}
7575
}

rest-test-service/src/main/java/password/pwm/resttest/SmsResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public SmsPostResponseBody getRecentFromMap( final String username )
7777
int mostRecentIndex = 0;
7878
for ( int i = 0; i < userMessages.size(); i++ )
7979
{
80-
if ( userMessages.get( i ).getDate().getTime() > userMessages.get( mostRecentIndex ).getDate().getTime() )
80+
if ( userMessages.get( i ).getDate().toEpochMilli() > userMessages.get( mostRecentIndex ).getDate().toEpochMilli() )
8181
{
8282
mostRecentIndex = i;
8383
}

0 commit comments

Comments
 (0)