Skip to content

Commit 437e617

Browse files
committed
create lib-data and lib-util submodules and begin move of appropriate code to submodules
1 parent 2cc5e1a commit 437e617

File tree

209 files changed

+1594
-1190
lines changed

Some content is hidden

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

209 files changed

+1594
-1190
lines changed

data-service/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@
144144
</reporting>
145145

146146
<dependencies>
147+
<dependency>
148+
<groupId>${project.groupId}</groupId>
149+
<artifactId>pwm-lib-data</artifactId>
150+
<version>${project.version}</version>
151+
</dependency>
152+
<dependency>
153+
<groupId>${project.groupId}</groupId>
154+
<artifactId>pwm-lib-util</artifactId>
155+
<version>${project.version}</version>
156+
</dependency>
157+
158+
147159
<dependency>
148160
<groupId>${project.groupId}</groupId>
149161
<artifactId>pwm-server</artifactId>
@@ -152,6 +164,7 @@
152164
</dependency>
153165

154166

167+
155168
<!-- container dependencies -->
156169
<dependency>
157170
<groupId>javax.servlet</groupId>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import javax.servlet.annotation.WebServlet;
2424

2525
@WebServlet(
26-
name = "TelemetryViewer",
26+
name = "CsvDownloadServlet",
2727
urlPatterns = {
2828
"/csv",
2929
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,33 @@
2121
package password.pwm.receiver;
2222

2323
import java.time.Instant;
24+
import java.time.temporal.ChronoUnit;
2425

2526
public class Logger
2627
{
2728
private final String name;
2829

29-
private Logger( final Class classname )
30+
private Logger( final Class<?> classname )
3031
{
3132
this.name = classname.getName();
3233
}
3334

34-
public static Logger createLogger( final Class classname )
35+
public static Logger createLogger( final Class<?> classname )
3536
{
3637
return new Logger( classname );
3738
}
3839

3940
public void info( final CharSequence input )
4041
{
41-
System.out.println( "PwmReceiver: " + Instant.now().toString() + ", INFO , " + name + ", " + input );
42+
System.out.println( "PwmReceiver: "
43+
+ Instant.now().truncatedTo( ChronoUnit.SECONDS ).toString()
44+
+ ", INFO , " + name + ", " + input );
4245
}
4346

4447
public void debug( final CharSequence input )
4548
{
46-
System.out.println( "PwmReceiver: " + Instant.now().toString() + ", DEBUG, " + name + ", " + input );
49+
System.out.println( "PwmReceiver: "
50+
+ Instant.now().toString()
51+
+ ", DEBUG, " + name + ", " + input );
4752
}
4853
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Password Management Servlets (PWM)
3+
* http://www.pwm-project.org
4+
*
5+
* Copyright (c) 2006-2009 Novell, Inc.
6+
* Copyright (c) 2009-2021 The PWM Project
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package password.pwm.receiver;
22+
23+
public class PwmReceiverConstants
24+
{
25+
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020

2121
package password.pwm.receiver;
2222

23-
import lombok.Getter;
24-
import lombok.Setter;
23+
import lombok.Data;
2524

2625
import java.time.Instant;
2726

28-
@Getter
29-
@Setter
27+
@Data
3028
public class Status
3129
{
3230
private String errorState;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import password.pwm.util.java.TimeDuration;
3030

3131
import java.time.Duration;
32+
import java.time.Instant;
3233
import java.util.Iterator;
3334
import java.util.Map;
3435
import java.util.TreeMap;
@@ -48,7 +49,7 @@ public class SummaryBean
4849
private Map<String, Integer> javaCount;
4950
private Map<String, Integer> appVersionCount;
5051

51-
static SummaryBean fromStorage( final Storage storage, final TimeDuration maxAge )
52+
static SummaryBean fromStorage( final Storage storage, final Duration maxAge )
5253
{
5354

5455
final String naText = "n/a";
@@ -67,9 +68,9 @@ static SummaryBean fromStorage( final Storage storage, final TimeDuration maxAge
6768
for ( Iterator<TelemetryPublishBean> iterator = storage.iterator(); iterator.hasNext(); )
6869
{
6970
final TelemetryPublishBean bean = iterator.next();
70-
final TimeDuration age = TimeDuration.fromCurrent( bean.getTimestamp() );
71+
final Duration age = Duration.between( Instant.now(), bean.getTimestamp() );
7172

72-
if ( bean.getAbout() != null && age.isShorterThan( maxAge ) )
73+
if ( bean.getAbout() != null && age.toMillis() < maxAge.toMillis() )
7374
{
7475
serverCount++;
7576
final String hashID = bean.getInstanceHash();

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
package password.pwm.receiver;
2222

2323
import password.pwm.util.java.StringUtil;
24-
import password.pwm.util.java.TimeDuration;
2524

2625
import javax.servlet.ServletException;
2726
import javax.servlet.annotation.WebServlet;
2827
import javax.servlet.http.HttpServlet;
2928
import javax.servlet.http.HttpServletRequest;
3029
import javax.servlet.http.HttpServletResponse;
3130
import java.io.IOException;
31+
import java.time.Duration;
32+
import java.time.temporal.ChronoUnit;
3233

3334
@WebServlet(
3435
name = "TelemetryViewer",
@@ -44,7 +45,8 @@ public class TelemetryViewerServlet extends HttpServlet
4445
public static final String SUMMARY_ATTR = "SummaryBean";
4546

4647
@Override
47-
protected void doGet( final HttpServletRequest req, final HttpServletResponse resp ) throws ServletException, IOException
48+
protected void doGet( final HttpServletRequest req, final HttpServletResponse resp )
49+
throws ServletException, IOException
4850
{
4951
LOGGER.debug( "http request for viewer" );
5052
final String daysString = req.getParameter( PARAM_DAYS );
@@ -64,7 +66,7 @@ protected void doGet( final HttpServletRequest req, final HttpServletResponse re
6466
}
6567

6668
final Storage storage = app.getStorage();
67-
final SummaryBean summaryBean = SummaryBean.fromStorage( storage, TimeDuration.of( days, TimeDuration.Unit.DAYS ) );
69+
final SummaryBean summaryBean = SummaryBean.fromStorage( storage, Duration.of( days, ChronoUnit.DAYS ) );
6870
req.setAttribute( SUMMARY_ATTR, summaryBean );
6971
req.getServletContext().getRequestDispatcher( "/WEB-INF/jsp/telemetry-viewer.jsp" ).forward( req, resp );
7072
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Password Management Servlets (PWM)
3+
* http://www.pwm-project.org
4+
*
5+
* Copyright (c) 2006-2009 Novell, Inc.
6+
* Copyright (c) 2009-2021 The PWM Project
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
package password.pwm.receiver;
22+
23+
import javax.servlet.ServletException;
24+
import javax.servlet.annotation.WebServlet;
25+
import javax.servlet.http.HttpServlet;
26+
import javax.servlet.http.HttpServletRequest;
27+
import javax.servlet.http.HttpServletResponse;
28+
import java.io.IOException;
29+
30+
@WebServlet( urlPatterns = "/testServlet" )
31+
public class TestServlet extends HttpServlet
32+
{
33+
@Override
34+
protected void doGet( final HttpServletRequest req, final HttpServletResponse resp )
35+
throws ServletException, IOException
36+
{
37+
resp.getWriter().write( "yeppers" );
38+
}
39+
}

data-service/src/main/webapp/WEB-INF/jsp/telemetry-viewer.jsp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<html>
3535
<head>
3636
<title>Telemetry Data</title>
37+
<link href="data-service-style.css" rel="stylesheet" type="text/css"/>
3738
</head>
3839
<body>
3940
<div>
@@ -62,7 +63,7 @@
6263
</form>
6364

6465
<h2>Versions</h2>
65-
<table border="1">
66+
<table>
6667
<tr>
6768
<td><b>Version</b></td>
6869
<td><b>Count</b></td>
@@ -75,7 +76,7 @@
7576
<% } %>
7677
</table>
7778
<h2>LDAP Vendors</h2>
78-
<table border="1">
79+
<table>
7980
<tr>
8081
<td><b>Ldap</b></td>
8182
<td><b>Count</b></td>
@@ -88,7 +89,7 @@
8889
<% } %>
8990
</table>
9091
<h2>App Servers</h2>
91-
<table border="1">
92+
<table>
9293
<tr>
9394
<td><b>App Server Info</b></td>
9495
<td><b>Count</b></td>
@@ -101,7 +102,7 @@
101102
<% } %>
102103
</table>
103104
<h2>OS Vendors</h2>
104-
<table border="1">
105+
<table>
105106
<tr>
106107
<td><b>OS Vendor</b></td>
107108
<td><b>Count</b></td>
@@ -114,7 +115,7 @@
114115
<% } %>
115116
</table>
116117
<h2>DB Vendors</h2>
117-
<table border="1">
118+
<table>
118119
<tr>
119120
<td><b>DB Vendor</b></td>
120121
<td><b>Count</b></td>
@@ -127,7 +128,7 @@
127128
<% } %>
128129
</table>
129130
<h2>Java VMs</h2>
130-
<table border="1">
131+
<table>
131132
<tr>
132133
<td><b>Java VM</b></td>
133134
<td><b>Count</b></td>
@@ -140,7 +141,7 @@
140141
<% } %>
141142
</table>
142143
<h2>Settings</h2>
143-
<table border="1">
144+
<table>
144145
<tr>
145146
<td><b>Setting</b></td>
146147
<td><b>Count</b></td>
@@ -153,7 +154,7 @@
153154
<% } %>
154155
</table>
155156
<h2>Statistics</h2>
156-
<table border="1">
157+
<table>
157158
<tr>
158159
<td><b>Statistic</b></td>
159160
<td><b>Count</b></td>
@@ -166,8 +167,9 @@
166167
<% } %>
167168
</table>
168169
<br/>
170+
<%--
169171
<h2>Summary Data</h2>
170-
<table border="1">
172+
<table>
171173
<tr>
172174
<td><b>SiteHash</b></td>
173175
<td><b>Description</b></td>
@@ -198,6 +200,7 @@
198200
</tr>
199201
<% } %>
200202
</table>
203+
--%>
201204
</div>
202205
</body>
203206
</html>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*!
2+
* Password Management Servlets (PWM)
3+
* http://www.pwm-project.org
4+
*
5+
* Copyright (c) 2006-2009 Novell, Inc.
6+
* Copyright (c) 2009-2021 The PWM Project
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
@import url("https://cdn.jsdelivr.net/npm/@xz/fonts@1/serve/source-code-pro.min.css");
22+
23+
body {
24+
font-family: 'Source Code Pro', sans-serif;
25+
}
26+
27+
table, td, th {
28+
border: 1px solid;
29+
border-collapse: collapse;
30+
}
31+

0 commit comments

Comments
 (0)