-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make v2 WebAnnotation and ACLFilter paths relatives
All paths defined in WebAnnotation and ACLFilter for routing and chacking the ACL are relatives to the servlet context
- Loading branch information
Showing
18 changed files
with
90 additions
and
65 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package com.netscape.certsrv.base; | ||
|
||
import static java.lang.annotation.ElementType.METHOD; | ||
|
@@ -8,6 +13,17 @@ | |
|
||
import org.dogtagpki.server.rest.v2.PKIServlet; | ||
|
||
/** | ||
* Implement basic routing for REST APIs | ||
* | ||
* If a servlet extends PKIServlet this annotation can specify the method to use for handle a | ||
* specific REST API. It has two parameter associating the HTTP operation and the path to be | ||
* handled by this method. The paths are relative and inside the servlet context. | ||
* | ||
* | ||
* @see PKIServlet | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
@Target(METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface WebAction { | ||
|
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
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 |
---|---|---|
|
@@ -44,6 +44,10 @@ | |
|
||
/** | ||
* Implement the basic class to handle REST APIs | ||
* | ||
* API are routed to method in subclasses implementing specific actions annotated with WebAction | ||
* | ||
* @see WebAction | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public abstract class PKIServlet extends HttpServlet { | ||
|
@@ -178,9 +182,9 @@ private void doOperation(HttpMethod method, HttpServletRequest request, HttpServ | |
public Method getActionMethod(HttpMethod met, String path) { | ||
final String reqMethod; | ||
if (path == null) { | ||
reqMethod = met.toString() + ":/"; | ||
reqMethod = met.toString() + ":"; | ||
} else { | ||
reqMethod = met.toString() + ":" + path; | ||
reqMethod = met.toString() + ":" + (path.startsWith("/") ? path.substring(1) : path); | ||
} | ||
String keyPath = webActions.keySet().stream(). | ||
filter( key -> { | ||
|
@@ -193,7 +197,12 @@ public Method getActionMethod(HttpMethod met, String path) { | |
} | ||
|
||
public String getAllowedMethods(String path) { | ||
final String matchingPath = path == null ? "/" : path; | ||
final String matchingPath; | ||
if (path == null) { | ||
matchingPath = ""; | ||
} else { | ||
matchingPath = path.startsWith("/") ? path.substring(1) : path; | ||
} | ||
List<String> keyPaths = webActions.keySet().stream(). | ||
filter( key -> { | ||
String keyRegex = key.substring(key.indexOf(":") + 1); | ||
|
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
Oops, something went wrong.