summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
authorInstrumental <jcgmisc@stl.gathman.org>2018-04-05 20:17:18 -0500
committerInstrumental <jcgmisc@stl.gathman.org>2018-04-05 20:17:25 -0500
commit924b18d7469204ceaae60d7345712ea09f75a674 (patch)
treeb4584c2731c82f484a31feadcb71d75c3613af43 /cadi
parent33e7b1a9fa15b0b699d16e359b406195b7fe87be (diff)
Add Certs, Docker Build
Issue-ID: AAF-211 Change-Id: Idc7630578155586a6e53d7af80dd16e4e0ac41ca Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/pom.xml2
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/Factory.java40
-rw-r--r--cadi/client/pom.xml2
-rw-r--r--cadi/core/pom.xml2
-rw-r--r--cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java3
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java388
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiException.java242
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiWrap.java322
-rw-r--r--cadi/pom.xml4
9 files changed, 504 insertions, 501 deletions
diff --git a/cadi/aaf/pom.xml b/cadi/aaf/pom.xml
index c2fd0b2d..5b05f3a0 100644
--- a/cadi/aaf/pom.xml
+++ b/cadi/aaf/pom.xml
@@ -110,7 +110,7 @@
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/Factory.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/Factory.java
index b7c085b0..e969fab3 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/Factory.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/cm/Factory.java
@@ -60,8 +60,6 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.Collection;
import java.util.List;
-import sun.security.pkcs11.SunPKCS11;
-
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
@@ -460,24 +458,28 @@ public class Factory {
* @throws CertException
*/
public static synchronized Provider getSecurityProvider(String providerType, String[][] params) throws CertException {
- Provider p = null;
- switch(providerType) {
- case "PKCS12":
- p = Security.getProvider(providerType);
- break;
- case "PKCS11": // PKCS11 only known to be supported by Sun
- try {
- p = new SunPKCS11(params[0][0]);
- if (p==null) {
- throw new CertException("SunPKCS11 Provider cannot be constructed for " + params[0][0]);
+ Provider p = Security.getProvider(providerType);
+ if(p!=null) {
+ switch(providerType) {
+ case "PKCS12":
+
+ break;
+ case "PKCS11": // PKCS11 only known to be supported by Sun
+ try {
+ Class<?> clsSunPKCS11 = Class.forName("sun.security.pkcs11.SunPKCS11");
+ Constructor<?> cnst = clsSunPKCS11.getConstructor(String.class);
+ Object sunPKCS11 = cnst.newInstance(params[0][0]);
+ if (sunPKCS11==null) {
+ throw new CertException("SunPKCS11 Provider cannot be constructed for " + params[0][0]);
+ }
+ Security.addProvider((Provider)sunPKCS11);
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ throw new CertException(e);
}
- Security.addProvider(p);
- } catch (SecurityException | IllegalArgumentException e) {
- throw new CertException(e);
- }
- break;
- default:
- throw new CertException(providerType + " is not a known Security Provider for your JDK.");
+ break;
+ default:
+ throw new CertException(providerType + " is not a known Security Provider for your JDK.");
+ }
}
return p;
}
diff --git a/cadi/client/pom.xml b/cadi/client/pom.xml
index 46a83677..43c20215 100644
--- a/cadi/client/pom.xml
+++ b/cadi/client/pom.xml
@@ -98,7 +98,7 @@
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
diff --git a/cadi/core/pom.xml b/cadi/core/pom.xml
index c458fc98..ff1e3455 100644
--- a/cadi/core/pom.xml
+++ b/cadi/core/pom.xml
@@ -79,7 +79,7 @@
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
index 0de6f4ef..0871a205 100644
--- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
+++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
@@ -73,7 +73,8 @@ public class Config {
public static final String HOSTNAME = "hostname";
public static final String CADI_PROP_FILES = "cadi_prop_files"; // Additional Properties files (separate with ;)
public static final String CADI_LOGLEVEL = "cadi_loglevel";
- public static final String CADI_LOGDIR = "cadi_logdir";
+ public static final String CADI_LOGDIR = "cadi_log_dir";
+ public static final String CADI_ETCDIR = "cadi_etc_dir";
public static final String CADI_LOGNAME = "cadi_logname";
public static final String CADI_KEYFILE = "cadi_keyfile";
public static final String CADI_KEYSTORE = "cadi_keystore";
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java
index fc960be8..f872a56b 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_AES.java
@@ -1,194 +1,194 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.test;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-import org.junit.*;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.lang.reflect.Field;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import javax.crypto.CipherInputStream;
-import javax.crypto.CipherOutputStream;
-import javax.crypto.SecretKey;
-
-import org.onap.aaf.cadi.AES;
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.Symm;
-
-public class JU_AES {
- private AES aes;
- private ByteArrayInputStream baisEncrypt;
- private ByteArrayInputStream baisDecrypt;
- private ByteArrayOutputStream baosEncrypt;
- private ByteArrayOutputStream baosDecrypt;
-
- private ByteArrayOutputStream errStream;
-
- @Before
- public void setup() throws Exception {
- byte[] keyBytes = new byte[AES.AES_KEY_SIZE/8];
- char[] codeset = Symm.base64.codeset;
- int offset = (Math.abs(codeset[0]) + 47) % (codeset.length - keyBytes.length);
- for(int i = 0; i < keyBytes.length; ++i) {
- keyBytes[i] = (byte)codeset[i+offset];
- }
- aes = new AES(keyBytes, 0, keyBytes.length);
-
- errStream = new ByteArrayOutputStream();
- System.setErr(new PrintStream(errStream));
- }
-
- @After
- public void tearDown() {
- System.setErr(System.err);
- }
-
- @Test
- public void newKeyTest() throws Exception {
- SecretKey secretKey = AES.newKey();
- assertThat(secretKey.getAlgorithm(), is(AES.class.getSimpleName()));
- }
-
- @Test
- public void encryptDecrpytFromBytes() throws Exception {
- String orig = "I'm a password, really";
- byte[] encrypted = aes.encrypt(orig.getBytes());
- byte[] decrypted = aes.decrypt(encrypted);
- assertThat(new String(decrypted), is(orig));
-
- Field aeskeySpec_field = AES.class.getDeclaredField("aeskeySpec");
- aeskeySpec_field.setAccessible(true);
- aeskeySpec_field.set(aes, null);
-
- try {
- aes.encrypt(orig.getBytes());
- fail("Should have thrown an exception");
- } catch (CadiException e) {
- }
- try {
- aes.decrypt(encrypted);
- fail("Should have thrown an exception");
- } catch (CadiException e) {
- }
- }
-
- @Test
- public void saveToFileTest() throws Exception {
- String filePath = "test/output_key";
- File keyfile = new File(filePath);
- aes.save(keyfile);
- assertTrue(Files.isReadable(Paths.get(filePath)));
- assertFalse(Files.isWritable(Paths.get(filePath)));
- assertFalse(Files.isExecutable(Paths.get(filePath)));
- keyfile.delete();
- }
-
- @Test
- public void encryptDecryptFromInputStream() throws Exception {
- String orig = "I'm a password, really";
- byte[] b64encrypted;
- String output;
-
- CipherInputStream cisEncrypt;
- CipherInputStream cisDecrypt;
-
- // Test CipherInputStream
- baisEncrypt = new ByteArrayInputStream(orig.getBytes());
- cisEncrypt = aes.inputStream(baisEncrypt, true);
- baosEncrypt = new ByteArrayOutputStream();
- transferFromInputStreamToOutputStream(cisEncrypt, baosEncrypt);
- cisEncrypt.close();
-
- b64encrypted = baosEncrypt.toByteArray();
-
- baisDecrypt = new ByteArrayInputStream(b64encrypted);
- cisDecrypt = aes.inputStream(baisDecrypt, false);
- baosDecrypt = new ByteArrayOutputStream();
- transferFromInputStreamToOutputStream(cisDecrypt, baosDecrypt);
- cisDecrypt.close();
-
- output = new String(baosDecrypt.toByteArray());
- assertThat(output, is(orig));
-
- Field aeskeySpec_field = AES.class.getDeclaredField("aeskeySpec");
- aeskeySpec_field.setAccessible(true);
- aeskeySpec_field.set(aes, null);
-
- assertNull(aes.inputStream(baisEncrypt, true));
- assertThat(errStream.toString(), is("Error creating Aes CipherInputStream\n"));
- }
-
- @Test
- public void encryptDecryptFromOutputStream() throws Exception {
- String orig = "I'm a password, really";
- byte[] b64encrypted;
- String output;
-
- CipherOutputStream cosEncrypt;
- CipherOutputStream cosDecrypt;
-
- // Test CipherOutputStream
- baisEncrypt = new ByteArrayInputStream(orig.getBytes());
- baosEncrypt = new ByteArrayOutputStream();
- cosEncrypt = aes.outputStream(baosEncrypt, true);
- transferFromInputStreamToOutputStream(baisEncrypt, cosEncrypt);
- cosEncrypt.close();
-
- b64encrypted = baosEncrypt.toByteArray();
-
- baosDecrypt = new ByteArrayOutputStream();
- cosDecrypt = aes.outputStream(baosDecrypt, false);
- baisDecrypt = new ByteArrayInputStream(b64encrypted);
- transferFromInputStreamToOutputStream(baisDecrypt, cosDecrypt);
- cosDecrypt.close();
-
- output = new String(baosDecrypt.toByteArray());
- assertThat(output, is(orig));
-
- Field aeskeySpec_field = AES.class.getDeclaredField("aeskeySpec");
- aeskeySpec_field.setAccessible(true);
- aeskeySpec_field.set(aes, null);
-
- assertNull(aes.outputStream(baosEncrypt, true));
- assertThat(errStream.toString(), is("Error creating Aes CipherOutputStream\n"));
- }
-
- public void transferFromInputStreamToOutputStream(InputStream is, OutputStream os) throws IOException {
- byte[] buffer = new byte[200];
- int len;
- while ((len = is.read(buffer)) != -1) {
- os.write(buffer, 0, len);
- }
- }
-
-}
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * *
+ ******************************************************************************/
+package org.onap.aaf.cadi.test;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+import org.junit.*;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.SecretKey;
+
+import org.onap.aaf.cadi.AES;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.Symm;
+
+public class JU_AES {
+ private AES aes;
+ private ByteArrayInputStream baisEncrypt;
+ private ByteArrayInputStream baisDecrypt;
+ private ByteArrayOutputStream baosEncrypt;
+ private ByteArrayOutputStream baosDecrypt;
+
+ private ByteArrayOutputStream errStream;
+
+ @Before
+ public void setup() throws Exception {
+ byte[] keyBytes = new byte[AES.AES_KEY_SIZE/8];
+ char[] codeset = Symm.base64.codeset;
+ int offset = (Math.abs(codeset[0]) + 47) % (codeset.length - keyBytes.length);
+ for(int i = 0; i < keyBytes.length; ++i) {
+ keyBytes[i] = (byte)codeset[i+offset];
+ }
+ aes = new AES(keyBytes, 0, keyBytes.length);
+
+ errStream = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(errStream));
+ }
+
+ @After
+ public void tearDown() {
+ System.setErr(System.err);
+ }
+
+ @Test
+ public void newKeyTest() throws Exception {
+ SecretKey secretKey = AES.newKey();
+ assertThat(secretKey.getAlgorithm(), is(AES.class.getSimpleName()));
+ }
+
+ @Test
+ public void encryptDecrpytFromBytes() throws Exception {
+ String orig = "I'm a password, really";
+ byte[] encrypted = aes.encrypt(orig.getBytes());
+ byte[] decrypted = aes.decrypt(encrypted);
+ assertThat(new String(decrypted), is(orig));
+
+ Field aeskeySpec_field = AES.class.getDeclaredField("aeskeySpec");
+ aeskeySpec_field.setAccessible(true);
+ aeskeySpec_field.set(aes, null);
+
+ try {
+ aes.encrypt(orig.getBytes());
+ fail("Should have thrown an exception");
+ } catch (CadiException e) {
+ }
+ try {
+ aes.decrypt(encrypted);
+ fail("Should have thrown an exception");
+ } catch (CadiException e) {
+ }
+ }
+
+ @Test
+ public void saveToFileTest() throws Exception {
+ String filePath = "test/output_key";
+ File keyfile = new File(filePath);
+ aes.save(keyfile);
+ assertTrue(Files.isReadable(Paths.get(filePath)));
+ assertFalse(Files.isWritable(Paths.get(filePath)));
+ assertFalse(Files.isExecutable(Paths.get(filePath)));
+ keyfile.delete();
+ }
+
+ @Test
+ public void encryptDecryptFromInputStream() throws Exception {
+ String orig = "I'm a password, really";
+ byte[] b64encrypted;
+ String output;
+
+ CipherInputStream cisEncrypt;
+ CipherInputStream cisDecrypt;
+
+ // Test CipherInputStream
+ baisEncrypt = new ByteArrayInputStream(orig.getBytes());
+ cisEncrypt = aes.inputStream(baisEncrypt, true);
+ baosEncrypt = new ByteArrayOutputStream();
+ transferFromInputStreamToOutputStream(cisEncrypt, baosEncrypt);
+ cisEncrypt.close();
+
+ b64encrypted = baosEncrypt.toByteArray();
+
+ baisDecrypt = new ByteArrayInputStream(b64encrypted);
+ cisDecrypt = aes.inputStream(baisDecrypt, false);
+ baosDecrypt = new ByteArrayOutputStream();
+ transferFromInputStreamToOutputStream(cisDecrypt, baosDecrypt);
+ cisDecrypt.close();
+
+ output = new String(baosDecrypt.toByteArray());
+ assertThat(output, is(orig));
+
+ Field aeskeySpec_field = AES.class.getDeclaredField("aeskeySpec");
+ aeskeySpec_field.setAccessible(true);
+ aeskeySpec_field.set(aes, null);
+
+ assertNull(aes.inputStream(baisEncrypt, true));
+ assertThat(errStream.toString(), is("Error creating Aes CipherInputStream\n"));
+ }
+
+ @Test
+ public void encryptDecryptFromOutputStream() throws Exception {
+ String orig = "I'm a password, really";
+ byte[] b64encrypted;
+ String output;
+
+ CipherOutputStream cosEncrypt;
+ CipherOutputStream cosDecrypt;
+
+ // Test CipherOutputStream
+ baisEncrypt = new ByteArrayInputStream(orig.getBytes());
+ baosEncrypt = new ByteArrayOutputStream();
+ cosEncrypt = aes.outputStream(baosEncrypt, true);
+ transferFromInputStreamToOutputStream(baisEncrypt, cosEncrypt);
+ cosEncrypt.close();
+
+ b64encrypted = baosEncrypt.toByteArray();
+
+ baosDecrypt = new ByteArrayOutputStream();
+ cosDecrypt = aes.outputStream(baosDecrypt, false);
+ baisDecrypt = new ByteArrayInputStream(b64encrypted);
+ transferFromInputStreamToOutputStream(baisDecrypt, cosDecrypt);
+ cosDecrypt.close();
+
+ output = new String(baosDecrypt.toByteArray());
+ assertThat(output, is(orig));
+
+ Field aeskeySpec_field = AES.class.getDeclaredField("aeskeySpec");
+ aeskeySpec_field.setAccessible(true);
+ aeskeySpec_field.set(aes, null);
+
+ assertNull(aes.outputStream(baosEncrypt, true));
+ assertThat(errStream.toString(), is("Error creating Aes CipherOutputStream\n"));
+ }
+
+ public void transferFromInputStreamToOutputStream(InputStream is, OutputStream os) throws IOException {
+ byte[] buffer = new byte[200];
+ int len;
+ while ((len = is.read(buffer)) != -1) {
+ os.write(buffer, 0, len);
+ }
+ }
+
+}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiException.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiException.java
index fa3b5cc4..bfcaeeab 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiException.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiException.java
@@ -1,121 +1,121 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.onap.aaf.cadi.CadiException;
-
-import static org.hamcrest.CoreMatchers.is;
-
-public class JU_CadiException {
- @Test
- public void testCadiException() {
- CadiException exception = new CadiException();
-
- assertNotNull(exception);
- }
-
- @Test
- public void testCadiExceptionString() {
- CadiException exception = new CadiException("New Exception");
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("New Exception"));
- }
-
- @Test
- public void testCadiExceptionThrowable() {
- CadiException exception = new CadiException(new Throwable("New Exception"));
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
- }
-
- @Test
- public void testCadiExceptionStringThrowable() {
- CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("New Exception"));
-
- }
-
- @Test
- public void testCadiException1() {
- CadiException exception = new CadiException();
-
- assertNotNull(exception);
- }
-
- @Test
- public void testCadiExceptionString1() {
- CadiException exception = new CadiException("New Exception");
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("New Exception"));
- }
-
- @Test
- public void testCadiExceptionThrowable1() {
- CadiException exception = new CadiException(new Throwable("New Exception"));
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
- }
-
- @Test
- public void testCadiExceptionStringThrowable1() {
- CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("New Exception"));
-
- }
-
- @Test
- public void testCadiException2() {
- CadiException exception = new CadiException();
-
- assertNotNull(exception);
- }
-
- @Test
- public void testCadiExceptionString2() {
- CadiException exception = new CadiException("New Exception");
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("New Exception"));
- }
-
- @Test
- public void testCadiExceptionThrowable2() {
- CadiException exception = new CadiException(new Throwable("New Exception"));
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
- }
-
- @Test
- public void testCadiExceptionStringThrowable2() {
- CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
- assertNotNull(exception);
- assertThat(exception.getMessage(), is("New Exception"));
-
- }
-
-
-
-}
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * *
+ ******************************************************************************/
+package org.onap.aaf.cadi.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.aaf.cadi.CadiException;
+
+import static org.hamcrest.CoreMatchers.is;
+
+public class JU_CadiException {
+ @Test
+ public void testCadiException() {
+ CadiException exception = new CadiException();
+
+ assertNotNull(exception);
+ }
+
+ @Test
+ public void testCadiExceptionString() {
+ CadiException exception = new CadiException("New Exception");
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionThrowable() {
+ CadiException exception = new CadiException(new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionStringThrowable() {
+ CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+
+ }
+
+ @Test
+ public void testCadiException1() {
+ CadiException exception = new CadiException();
+
+ assertNotNull(exception);
+ }
+
+ @Test
+ public void testCadiExceptionString1() {
+ CadiException exception = new CadiException("New Exception");
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionThrowable1() {
+ CadiException exception = new CadiException(new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionStringThrowable1() {
+ CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+
+ }
+
+ @Test
+ public void testCadiException2() {
+ CadiException exception = new CadiException();
+
+ assertNotNull(exception);
+ }
+
+ @Test
+ public void testCadiExceptionString2() {
+ CadiException exception = new CadiException("New Exception");
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionThrowable2() {
+ CadiException exception = new CadiException(new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("java.lang.Throwable: New Exception"));
+ }
+
+ @Test
+ public void testCadiExceptionStringThrowable2() {
+ CadiException exception = new CadiException("New Exception",new Throwable("New Exception"));
+ assertNotNull(exception);
+ assertThat(exception.getMessage(), is("New Exception"));
+
+ }
+
+
+
+}
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiWrap.java b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiWrap.java
index 8bcb6329..d9a4437c 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiWrap.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/test/JU_CadiWrap.java
@@ -1,161 +1,161 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * *
- ******************************************************************************/
-package org.onap.aaf.cadi.test;
-
-import org.junit.*;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.security.Principal;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.aaf.cadi.Access;
-import org.onap.aaf.cadi.CachingLur;
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.CadiWrap;
-import org.onap.aaf.cadi.Lur;
-import org.onap.aaf.cadi.Permission;
-import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.User;
-import org.onap.aaf.cadi.CachedPrincipal.Resp;
-import org.onap.aaf.cadi.filter.MapPermConverter;
-import org.onap.aaf.cadi.lur.EpiLur;
-import org.onap.aaf.cadi.principal.TaggedPrincipal;
-import org.onap.aaf.cadi.taf.TafResp;
-
-public class JU_CadiWrap {
-
- @Mock
- private HttpServletRequest request;
-
- @Mock
- private TafResp tafResp;
-
- @Mock
- private TaggedPrincipal principle;
-
- @Mock
- private Lur lur;
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- System.setOut(new PrintStream(new ByteArrayOutputStream()));
- }
-
- @After
- public void tearDown() {
- System.setOut(System.out);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void testInstantiate() throws CadiException {
- Access a = new PropAccess();
- when(tafResp.getAccess()).thenReturn(a);
-
- lur.fishAll(isA(Principal.class), (List<Permission>)isA(List.class));
-
- EpiLur lur1 = new EpiLur(lur);
-
- CadiWrap wrap = new CadiWrap(request, tafResp, lur1);
-
- assertNull(wrap.getUserPrincipal());
- assertNull(wrap.getRemoteUser());
- assertNull(wrap.getUser());
- assertEquals(wrap.getPermissions(principle).size(), 0);
- assertTrue(wrap.access() instanceof PropAccess);
-
- byte[] arr = {'1','2'};
- wrap.setCred(arr);
-
- assertEquals(arr, wrap.getCred());
-
- wrap.setUser("User1");
- assertEquals("User1", wrap.getUser());
-
- wrap.invalidate("1");
-
- assertFalse(wrap.isUserInRole(null));
-
- wrap.set(tafResp, lur);
-
- wrap.invalidate("2");
-
- assertFalse(wrap.isUserInRole("User1"));
- }
-
- @Test
- public void testInstantiateWithPermConverter() throws CadiException {
- Access a = new PropAccess();
- when(tafResp.getAccess()).thenReturn(a);
- when(tafResp.getPrincipal()).thenReturn(principle);
-
- // Anonymous object for testing purposes
- CachingLur<Permission> lur1 = new CachingLur<Permission>() {
- @Override public Permission createPerm(String p) { return null; }
- @Override public boolean fish(Principal bait, Permission pond) { return true; }
- @Override public void fishAll(Principal bait, List<Permission> permissions) { }
- @Override public void destroy() { }
- @Override public boolean handlesExclusively(Permission pond) { return false; }
- @Override public boolean handles(Principal principal) { return false; }
- @Override public void remove(String user) { }
- @Override public Resp reload(User<Permission> user) { return null; }
- @Override public void setDebug(String commaDelimIDsOrNull) { }
- @Override public void clear(Principal p, StringBuilder sb) { }
- };
-
- MapPermConverter pc = new MapPermConverter();
-
- CadiWrap wrap = new CadiWrap(request, tafResp, lur1, pc);
-
- assertNotNull(wrap.getUserPrincipal());
- assertNull(wrap.getRemoteUser());
- assertNull(wrap.getUser());
-
- byte[] arr = {'1','2'};
- wrap.setCred(arr);
-
- assertEquals(arr, wrap.getCred());
-
- wrap.setUser("User1");
- assertEquals("User1", wrap.getUser());
-
- wrap.invalidate("1");
- wrap.setPermConverter(new MapPermConverter());
-
- assertTrue(wrap.getLur() instanceof CachingLur);
- assertTrue(wrap.isUserInRole("User1"));
-
- wrap.set(tafResp, lur);
- assertFalse(wrap.isUserInRole("Perm1"));
- }
-}
+/*******************************************************************************
+ * ============LICENSE_START====================================================
+ * * org.onap.aaf
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * *
+ ******************************************************************************/
+package org.onap.aaf.cadi.test;
+
+import org.junit.*;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.security.Principal;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.CachingLur;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.CadiWrap;
+import org.onap.aaf.cadi.Lur;
+import org.onap.aaf.cadi.Permission;
+import org.onap.aaf.cadi.PropAccess;
+import org.onap.aaf.cadi.User;
+import org.onap.aaf.cadi.CachedPrincipal.Resp;
+import org.onap.aaf.cadi.filter.MapPermConverter;
+import org.onap.aaf.cadi.lur.EpiLur;
+import org.onap.aaf.cadi.principal.TaggedPrincipal;
+import org.onap.aaf.cadi.taf.TafResp;
+
+public class JU_CadiWrap {
+
+ @Mock
+ private HttpServletRequest request;
+
+ @Mock
+ private TafResp tafResp;
+
+ @Mock
+ private TaggedPrincipal principle;
+
+ @Mock
+ private Lur lur;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ System.setOut(new PrintStream(new ByteArrayOutputStream()));
+ }
+
+ @After
+ public void tearDown() {
+ System.setOut(System.out);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testInstantiate() throws CadiException {
+ Access a = new PropAccess();
+ when(tafResp.getAccess()).thenReturn(a);
+
+ lur.fishAll(isA(Principal.class), (List<Permission>)isA(List.class));
+
+ EpiLur lur1 = new EpiLur(lur);
+
+ CadiWrap wrap = new CadiWrap(request, tafResp, lur1);
+
+ assertNull(wrap.getUserPrincipal());
+ assertNull(wrap.getRemoteUser());
+ assertNull(wrap.getUser());
+ assertEquals(wrap.getPermissions(principle).size(), 0);
+ assertTrue(wrap.access() instanceof PropAccess);
+
+ byte[] arr = {'1','2'};
+ wrap.setCred(arr);
+
+ assertEquals(arr, wrap.getCred());
+
+ wrap.setUser("User1");
+ assertEquals("User1", wrap.getUser());
+
+ wrap.invalidate("1");
+
+ assertFalse(wrap.isUserInRole(null));
+
+ wrap.set(tafResp, lur);
+
+ wrap.invalidate("2");
+
+ assertFalse(wrap.isUserInRole("User1"));
+ }
+
+ @Test
+ public void testInstantiateWithPermConverter() throws CadiException {
+ Access a = new PropAccess();
+ when(tafResp.getAccess()).thenReturn(a);
+ when(tafResp.getPrincipal()).thenReturn(principle);
+
+ // Anonymous object for testing purposes
+ CachingLur<Permission> lur1 = new CachingLur<Permission>() {
+ @Override public Permission createPerm(String p) { return null; }
+ @Override public boolean fish(Principal bait, Permission pond) { return true; }
+ @Override public void fishAll(Principal bait, List<Permission> permissions) { }
+ @Override public void destroy() { }
+ @Override public boolean handlesExclusively(Permission pond) { return false; }
+ @Override public boolean handles(Principal principal) { return false; }
+ @Override public void remove(String user) { }
+ @Override public Resp reload(User<Permission> user) { return null; }
+ @Override public void setDebug(String commaDelimIDsOrNull) { }
+ @Override public void clear(Principal p, StringBuilder sb) { }
+ };
+
+ MapPermConverter pc = new MapPermConverter();
+
+ CadiWrap wrap = new CadiWrap(request, tafResp, lur1, pc);
+
+ assertNotNull(wrap.getUserPrincipal());
+ assertNull(wrap.getRemoteUser());
+ assertNull(wrap.getUser());
+
+ byte[] arr = {'1','2'};
+ wrap.setCred(arr);
+
+ assertEquals(arr, wrap.getCred());
+
+ wrap.setUser("User1");
+ assertEquals("User1", wrap.getUser());
+
+ wrap.invalidate("1");
+ wrap.setPermConverter(new MapPermConverter());
+
+ assertTrue(wrap.getLur() instanceof CachingLur);
+ assertTrue(wrap.isUserInRole("User1"));
+
+ wrap.set(tafResp, lur);
+ assertFalse(wrap.isUserInRole("Perm1"));
+ }
+}
diff --git a/cadi/pom.xml b/cadi/pom.xml
index b6f12625..dbf692b3 100644
--- a/cadi/pom.xml
+++ b/cadi/pom.xml
@@ -260,8 +260,8 @@
<dependency>
<groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
</dependency>
<dependency>