aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-10-10 11:40:27 +0200
committerSébastien Determe <sebastien.determe@intl.att.com>2019-10-10 09:43:32 +0000
commit13ab11a844d840025d153f7eac9109fbbe1c6b08 (patch)
treeb133f59c17e1c1045043aa1de914b28a45c03df2
parent29b3d25ef74df7ba92f0fc6fcd70344b818625a9 (diff)
Rework the clamp cadi filter
Add test and rework the code for X509 certificate Issue-ID: CLAMP-519 Change-Id: I3c0aa05cd4bec24770243b86a4672ff3906afba5 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
-rw-r--r--src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java18
-rw-r--r--src/test/javascript/package.json46
2 files changed, 12 insertions, 52 deletions
diff --git a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
index 7e104c74b..cd141ae77 100644
--- a/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
+++ b/src/main/java/org/onap/clamp/clds/filter/ClampCadiFilter.java
@@ -144,16 +144,22 @@ public class ClampCadiFilter extends CadiFilter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
try {
- String certHeader = URLDecoder.decode(((HttpServletRequest) request).getHeader("X-SSL-Cert"),
- StandardCharsets.UTF_8.toString());
+ String certHeader = ((HttpServletRequest) request).getHeader("X-SSL-Cert");
if (certHeader != null) {
-
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) certificateFactory
- .generateCertificate(new ByteArrayInputStream(certHeader.getBytes()));
- request.setAttribute("javax.servlet.request.X509Certificate", cert);
-
+ .generateCertificate(new ByteArrayInputStream(
+ URLDecoder.decode(certHeader, StandardCharsets.UTF_8.toString()).getBytes()));
+ X509Certificate[] certifArray = ((X509Certificate[]) request
+ .getAttribute("javax.servlet.request.X509Certificate"));
+ if (certifArray == null) {
+ certifArray = new X509Certificate[] { cert };
+ request.setAttribute("javax.servlet.request.X509Certificate", certifArray);
+ } else {
+ certifArray[0] = cert;
+ }
}
+
} catch (CertificateException e) {
logger.error("Unable to inject the X.509 certificate", e);
}
diff --git a/src/test/javascript/package.json b/src/test/javascript/package.json
deleted file mode 100644
index a2f0cd2eb..000000000
--- a/src/test/javascript/package.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "scripts": {
- "test": "jest",
- "test:watch": "jest --watch",
- "test:coverage": "jest --coverage"
- },
- "jest": {
- "verbose": true,
- "coverageDirectory": "${project.build.directory}/clamp-ui/coverage",
- "collectCoverageFrom": [
- "**/designer/**/*.{js,jsx}",
- "!**/designer/lib/**"
- ],
- "rootDir": "${project.build.directory}/clamp-ui",
- "roots": [
- "${project.basedir}/src/test/javascript/",
- "<rootDir>/designer/"
- ],
- "moduleDirectories": [
- "${project.build.directory}/clamp-ui/node/node_modules",
- "${project.build.directory}/clamp-ui/node_modules",
- "<rootDir>/designer"
- ],
- "coverageReporters": [
- "lcov"
- ]
- },
- "devDependencies": {
- "angular": "1.3.2",
- "angular-resource": "1.3.2",
- "angular-cookies": "1.3.2",
- "angular-route": "1.3.2",
- "angular-mocks": "1.3.2",
- "angular-animate": "1.3.2",
- "angular-sanitize": "1.3.2",
- "angular-touch": "1.3.2",
- "angular-dialog-service": "5.3.0",
- "angular-loading-bar": "0.9.0",
- "jquery": "3.3.1",
- "popper.js": "1.14.4",
- "bootstrap": "4.1.1",
- "angular-ui-bootstrap": "2.5.6",
- "jest": "^23.6.0",
- "jest-cli": "^21.2.1"
- }
-}