Skip to content

Commit 89e1fed

Browse files
author
jrivard@gmail.com
committed
add external macro resttest servlet
1 parent 5f21bed commit 89e1fed

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

rest-test-service/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@
106106
</dependency>
107107
<!-- / container dependencies -->
108108

109+
<!-- library dependencies -->
110+
<dependency>
111+
<groupId>com.google.code.gson</groupId>
112+
<artifactId>gson</artifactId>
113+
<version>2.8.5</version>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.apache.commons</groupId>
117+
<artifactId>commons-io</artifactId>
118+
<version>1.3.2</version>
119+
</dependency>
120+
<!-- / library dependencies -->
109121
</dependencies>
110122

111123
</project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Password Management Servlets (PWM)
3+
* http://www.pwm-project.org
4+
*
5+
* Copyright (c) 2006-2009 Novell, Inc.
6+
* Copyright (c) 2009-2018 The PWM Project
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*/
22+
23+
24+
package password.pwm.resttest;
25+
26+
import org.apache.commons.io.IOUtils;
27+
28+
import javax.servlet.ServletException;
29+
import javax.servlet.annotation.WebServlet;
30+
import javax.servlet.http.HttpServlet;
31+
import javax.servlet.http.HttpServletRequest;
32+
import javax.servlet.http.HttpServletResponse;
33+
import java.io.IOException;
34+
import java.io.InputStream;
35+
import java.io.PrintWriter;
36+
37+
@WebServlet(
38+
name = "NewUserServlet",
39+
urlPatterns = { "/external/macro1" }
40+
)
41+
42+
public class ExternalMacroServlet extends HttpServlet
43+
{
44+
@Override
45+
protected void doPost( final HttpServletRequest req, final HttpServletResponse resp ) throws ServletException, IOException
46+
{
47+
48+
final InputStream inputStream = req.getInputStream();
49+
final String body = IOUtils.toString( inputStream );
50+
51+
System.out.println( "input POST body: " + body );
52+
53+
54+
resp.setHeader( "Content-Type", "application/json" );
55+
56+
final PrintWriter writer = resp.getWriter();
57+
writer.write( "{\"output\":\"macro api output SPLAT!\"}" );
58+
writer.close();
59+
}
60+
}

0 commit comments

Comments
 (0)