-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The code of CAInfoService.java has moved to CAEngine and used for the current API and the new v2 API. Introduced a base servlet for all CA APIs and the servlet for the Info end-point. No code changes performed.
- Loading branch information
Showing
6 changed files
with
253 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
base/ca/src/main/java/org/dogtagpki/server/ca/CAServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.ca; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.ServletContext; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
public class CAServlet extends HttpServlet { | ||
public static final long serialVersionUID = 1L; | ||
|
||
|
||
public void get(HttpServletRequest request, HttpServletResponse response) throws Exception { | ||
} | ||
|
||
@Override | ||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
try { | ||
get(request, response); | ||
|
||
} catch (ServletException | IOException e) { | ||
throw e; | ||
|
||
} catch (Exception e) { | ||
throw new ServletException(e); | ||
} | ||
} | ||
|
||
public CAEngine getCAEngine() { | ||
ServletContext servletContext = getServletContext(); | ||
return (CAEngine) servletContext.getAttribute("engine"); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
base/ca/src/main/java/org/dogtagpki/server/ca/v2/CAInfoServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.dogtagpki.server.ca.v2; | ||
|
||
import java.io.PrintWriter; | ||
|
||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
|
||
import org.dogtagpki.common.CAInfo; | ||
import org.dogtagpki.server.ca.CAEngine; | ||
import org.dogtagpki.server.ca.CAServlet; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@WebServlet("/v2/info") | ||
public class CAInfoServlet extends CAServlet { | ||
private static final long serialVersionUID = 1L; | ||
private static Logger logger = LoggerFactory.getLogger(CAInfoServlet.class); | ||
|
||
public void get(HttpServletRequest request, HttpServletResponse response) throws Exception { | ||
HttpSession session = request.getSession(); | ||
logger.debug("CAInfoServlet.get(): session: " + session.getId()); | ||
|
||
CAEngine engine = getCAEngine(); | ||
CAInfo info = engine.getInfo(request.getLocale()); | ||
|
||
response.setContentType("application/json"); | ||
|
||
PrintWriter out = response.getWriter(); | ||
out.println(info.toJSON()); | ||
} | ||
} |
Oops, something went wrong.