|
| 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