diff --git a/base/ca/src/main/java/org/dogtagpki/server/ca/rest/v2/CertRequestServlet.java b/base/ca/src/main/java/org/dogtagpki/server/ca/rest/v2/CertRequestServlet.java index a2e67028ccd..57d9ff9d5c6 100644 --- a/base/ca/src/main/java/org/dogtagpki/server/ca/rest/v2/CertRequestServlet.java +++ b/base/ca/src/main/java/org/dogtagpki/server/ca/rest/v2/CertRequestServlet.java @@ -49,6 +49,7 @@ import com.netscape.certsrv.request.RequestId; import com.netscape.certsrv.request.RequestNotFoundException; import com.netscape.certsrv.util.JSONSerializer; +import com.netscape.cms.authentication.DirBasedAuthentication; import com.netscape.cms.profile.common.Profile; import com.netscape.cms.servlet.cert.CertRequestInfoFactory; import com.netscape.cms.servlet.cert.EnrollmentProcessor; @@ -227,17 +228,18 @@ private CertRequestInfos submitRequest( CertRequestInfos ret = new CertRequestInfos(); AuthCredentials credentials = new AuthCredentials(); - String uid = data.getAttribute("uid"); + String uid = data.getAttribute(DirBasedAuthentication.CRED_UID); if (uid != null) { - credentials.set("uid", uid); + credentials.set(DirBasedAuthentication.CRED_UID, uid); } - String password = data.getAttribute("pwd"); + String password = data.getAttribute(DirBasedAuthentication.CRED_PWD); if (password != null) { - credentials.set("pwd", password); + credentials.set(DirBasedAuthentication.CRED_PWD, password); + } + String pin = data.getAttribute(DirBasedAuthentication.CRED_PIN); + if (pin != null) { + credentials.set(DirBasedAuthentication.CRED_PIN, pin); } - - CAEngine engine = CAEngine.getInstance(); - HashMap results = null; if (data.isRenewal()) { RenewalProcessor processor = new RenewalProcessor("caProfileSubmit", request.getLocale()); diff --git a/base/server/src/main/java/org/dogtagpki/server/rest/v2/PKIServlet.java b/base/server/src/main/java/org/dogtagpki/server/rest/v2/PKIServlet.java index 002de6acb34..09c03bb87ce 100644 --- a/base/server/src/main/java/org/dogtagpki/server/rest/v2/PKIServlet.java +++ b/base/server/src/main/java/org/dogtagpki/server/rest/v2/PKIServlet.java @@ -14,6 +14,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.security.Principal; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -163,6 +164,7 @@ public Method getActionMethod(HttpMethod met, String path) { String keyRegex = key.replace("{}", "([^/]+)"); return reqMethod.matches(keyRegex); } ). + sorted(Comparator.naturalOrder()). findFirst(). orElse(null); return keyPath == null ? null : webActions.get(keyPath); @@ -187,7 +189,9 @@ public String getAllowedMethods(String path) { } StringBuilder methods = new StringBuilder(); for (String k: keyPaths) { - methods.append(k.substring(0, k.indexOf(":"))).append(", "); + if (methods.indexOf(k) == -1) { + methods.append(k.substring(0, k.indexOf(":"))).append(", "); + } } return methods.substring(0, methods.lastIndexOf(",")); } diff --git a/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/ACLFilter.java b/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/ACLFilter.java index 79a29b8b2f1..0d9eca9fcbd 100644 --- a/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/ACLFilter.java +++ b/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/ACLFilter.java @@ -14,7 +14,6 @@ import java.security.Principal; import java.util.Comparator; import java.util.Map; -import java.util.Optional; import java.util.Properties; import javax.servlet.FilterChain; @@ -55,8 +54,7 @@ * * key= : * - * The method is one of the HTTP method as defined in Java servlet request (e.g. GET, POST, etc.). If the ACL has to be applied for all - * the methods then it can be replaced with the symbol '*'. + * The method is one of the HTTP method as defined in Java servlet request (e.g. GET, POST, etc.). * The path is the endpoint in the associated servlet where the ACL has to be applied. If there is a REST path param this can be indicated * with the sequence "{}". * @@ -97,15 +95,16 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha path = req.getPathInfo() != null ? req.getPathInfo().substring(1) : ""; final String aclSearch = method + ":" + path; if (aclMap!=null) { - Optional aclKey = aclMap.keySet().stream(). + String aclKey = aclMap.keySet().stream(). filter( key -> { - String keyRegex = key.replaceFirst("\\*", ".*").replace("{}", "([^/]+)"); + String keyRegex = key.replace("{}", "([^/]+)"); return aclSearch.matches(keyRegex); } ). sorted(Comparator.reverseOrder()). - findFirst(); - if (aclKey.isPresent()) { - acl = aclMap.get(aclKey.get()); + findFirst(). + orElse(null); + if (aclKey != null) { + acl = aclMap.get(aclKey); } } try { diff --git a/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/AuthMethodFilter.java b/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/AuthMethodFilter.java index 5c7bc0c1f91..ce8830e3259 100644 --- a/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/AuthMethodFilter.java +++ b/base/server/src/main/java/org/dogtagpki/server/rest/v2/filters/AuthMethodFilter.java @@ -16,7 +16,6 @@ import java.util.Comparator; import java.util.HashSet; import java.util.Map; -import java.util.Optional; import java.util.Properties; import javax.servlet.FilterChain; @@ -47,8 +46,7 @@ * * key= : * - * The method is one of the HTTP method as defined in Java servlet request (e.g. GET, POST, etc.). If the ACL has to be applied for all - * the methods then it can be replaced with the symbol '*'. + * The method is one of the HTTP method as defined in Java servlet request (e.g. GET, POST, etc.). * The path is the endpoint in the associated servlet where the ACL has to be applied. If there is a REST path param this can be indicated * with the sequence "{}". * @@ -84,15 +82,16 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha path = req.getPathInfo() != null ? req.getPathInfo().substring(1) : ""; final String authMethodSearch = method + ":" + path; if (authMethodMap!=null) { - Optional autMethodKey = authMethodMap.keySet().stream(). + String autMethodKey = authMethodMap.keySet().stream(). filter( key -> { - String keyRegex = key.replaceFirst("\\*", ".*").replace("{}", "([^/]+)"); + String keyRegex = key.replace("{}", "([^/]+)"); return authMethodSearch.matches(keyRegex); } ). - sorted(Comparator.reverseOrder()). - findFirst(); - if (autMethodKey.isPresent()) { - authMethod = authMethodMap.get(autMethodKey.get()); + sorted(Comparator.naturalOrder()). + findFirst(). + orElse(null); + if (autMethodKey != null) { + authMethod = authMethodMap.get(autMethodKey); } } try {