From 6d469611d86642bc0b74ce51af72cc36d2af962d Mon Sep 17 00:00:00 2001 From: Instrumental Date: Mon, 26 Mar 2018 12:04:27 -0700 Subject: Remove Code from cadi, it is now in authz Issue-ID: AAF-193 Change-Id: Ib7abdb15ba8a7445a3875cf8c6bb48b7d563f424 Signed-off-by: Instrumental --- .../onap/aaf/cadi/aaf/JU_AAFPermissionTest.java | 211 -------- .../onap/aaf/cadi/aaf/JU_AAFTransmutateTest.java | 118 ----- .../onap/aaf/cadi/aaf/JU_CertExceptionTest.java | 237 --------- .../aaf/cadi/aaf/client/JU_ErrMessageTest.java | 131 ----- .../aaf/cadi/aaf/marshal/JU_CertsMarshalTest.java | 54 -- .../onap/aaf/cadi/aaf/v2_0/JU_AAFAuthnTest.java | 155 ------ .../org/onap/aaf/cadi/lur/aaf/test/JU_JMeter.java | 144 ------ .../onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java | 574 --------------------- .../cadi/lur/aaf/test/JU_MultiThreadPermHit.java | 145 ------ .../onap/aaf/cadi/lur/aaf/test/JU_PermEval.java | 107 ---- .../onap/aaf/cadi/lur/aaf/test/JU_TestAccess.java | 122 ----- .../test/java/org/onap/aaf/content/JU_Content.java | 83 --- .../java/org/onap/aaf/example/JU_CadiTest.java | 58 --- .../org/onap/aaf/example/JU_ExampleAuthCheck.java | 57 -- .../org/onap/aaf/example/JU_ExamplePerm2_0.java | 113 ---- .../onap/aaf/example/JU_ExamplePerm2_0_DME2.java | 113 ---- .../java/org/onap/aaf/example/JU_X509Test.java | 89 ---- aaf/src/test/resources/cadi.properties | 52 -- aaf/src/test/resources/log4j.properties | 57 -- aaf/src/test/resources/logging.props | 38 -- 20 files changed, 2658 deletions(-) delete mode 100644 aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFPermissionTest.java delete mode 100644 aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFTransmutateTest.java delete mode 100644 aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/JU_CertsMarshalTest.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthnTest.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_JMeter.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_MultiThreadPermHit.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_PermEval.java delete mode 100644 aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_TestAccess.java delete mode 100644 aaf/src/test/java/org/onap/aaf/content/JU_Content.java delete mode 100644 aaf/src/test/java/org/onap/aaf/example/JU_CadiTest.java delete mode 100644 aaf/src/test/java/org/onap/aaf/example/JU_ExampleAuthCheck.java delete mode 100644 aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0.java delete mode 100644 aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0_DME2.java delete mode 100644 aaf/src/test/java/org/onap/aaf/example/JU_X509Test.java delete mode 100644 aaf/src/test/resources/cadi.properties delete mode 100644 aaf/src/test/resources/log4j.properties delete mode 100644 aaf/src/test/resources/logging.props (limited to 'aaf/src/test') diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFPermissionTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFPermissionTest.java deleted file mode 100644 index a809a0d..0000000 --- a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFPermissionTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.onap.aaf.cadi.aaf; -import static org.junit.Assert.*; - -import org.junit.Test; - - - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.lur.LocalPermission; - -public class JU_AAFPermissionTest { - - private static final String INSTANCE = "*"; - private static final String ACTION = "*"; - private static final String TYPE = "Auth"; - private static final String KEY =TYPE + '|' + INSTANCE + '|' + ACTION; - - private String STRINGVALUE = - "AAFPermission:\n\tType: " + TYPE + - "\n\tInstance: " + INSTANCE + - "\n\tAction: " + ACTION + - "\n\tKey: " + KEY; - - @Mock - private LocalPermission localPermission; - - @Mock - private LocalPermission localPermission2; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - when(localPermission.getKey()).thenReturn(TYPE); - when(localPermission2.getKey()).thenReturn(TYPE+" Default"); - } - - @Test - public void test() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - @Test - public void test4() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - @Test - public void test1() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - @Test - public void test2() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - - @Test - public void test3() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - @Test - public void test5() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - @Test - public void test6() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } - - @Test - public void test7() { - AAFPermission permission = new AAFPermission(TYPE, INSTANCE, ACTION); - - assertTrue("This should Match",permission.match(permission)); - - assertTrue("This should Match", permission.match(localPermission)); - - assertFalse("This should Not Match", permission.match(localPermission2)); - - assertThat(permission.getKey(), is(KEY)); - - assertThat(permission.permType(), is("AAF")); - - assertThat(permission.toString(), is(STRINGVALUE)); - - } -} diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFTransmutateTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFTransmutateTest.java deleted file mode 100644 index 5b0df09..0000000 --- a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_AAFTransmutateTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.onap.aaf.cadi.aaf; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.security.Principal; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.aaf.AAFTransmutate; -import org.onap.aaf.cadi.lur.ConfigPrincipal; -import org.onap.aaf.cadi.principal.BasicPrincipal; - -public class JU_AAFTransmutateTest { - - @Mock - Principal principal ; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - when(principal.getName()).thenReturn("Value"); - } - - @Test - public void testMutate() throws IOException { - BasicPrincipal p = new BasicPrincipal("content", "domain"); - AAFTransmutate transmutate = new AAFTransmutate(); -// assertNotNull(transmutate.mutate(p)); - - ConfigPrincipal cp = new ConfigPrincipal("content", "cred"); -// assertNotNull(transmutate.mutate(cp)); - - assertNull(transmutate.mutate(principal)); - } - - - @Test - public void testMutate4() throws IOException { - BasicPrincipal p = new BasicPrincipal("content", "domain"); - AAFTransmutate transmutate = new AAFTransmutate(); -// assertNotNull(transmutate.mutate(p)); - - ConfigPrincipal cp = new ConfigPrincipal("content", "cred"); -// assertNotNull(transmutate.mutate(cp)); - - assertNull(transmutate.mutate(principal)); - } - - - @Test - public void testMutate1() throws IOException { - BasicPrincipal p = new BasicPrincipal("content", "domain"); - AAFTransmutate transmutate = new AAFTransmutate(); -// assertNotNull(transmutate.mutate(p)); - - ConfigPrincipal cp = new ConfigPrincipal("content", "cred"); -// assertNotNull(transmutate.mutate(cp)); - - assertNull(transmutate.mutate(principal)); - } - - - @Test - public void testMutate2() throws IOException { - BasicPrincipal p = new BasicPrincipal("content", "domain"); - AAFTransmutate transmutate = new AAFTransmutate(); -// assertNotNull(transmutate.mutate(p)); - - ConfigPrincipal cp = new ConfigPrincipal("content", "cred"); -// assertNotNull(transmutate.mutate(cp)); - - assertNull(transmutate.mutate(principal)); - } - - - @Test - public void testMutate3() throws IOException { - BasicPrincipal p = new BasicPrincipal("content", "domain"); - AAFTransmutate transmutate = new AAFTransmutate(); -// assertNotNull(transmutate.mutate(p)); - - ConfigPrincipal cp = new ConfigPrincipal("content", "cred"); -// assertNotNull(transmutate.mutate(cp)); - - assertNull(transmutate.mutate(principal)); - } - -} diff --git a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java b/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java deleted file mode 100644 index 5b61d59..0000000 --- a/aaf/src/test/java/com/onap/aaf/cadi/aaf/JU_CertExceptionTest.java +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package com.onap.aaf.cadi.aaf; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; -import org.onap.aaf.cadi.cm.CertException; - -public class JU_CertExceptionTest { - - @Before - public void setUp() throws Exception { - } - - @Test - public void test() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - @Test - public void test3() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - - @Test - public void test1() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - - @Test - public void test2() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - @Test - public void test4() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - @Test - public void test5() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - @Test - public void test6() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - @Test - public void test7() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - - @Test - public void test8() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - @Test - public void test9() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - - @Test - public void test10() { - CertException ex = new CertException(); - assertNotNull(ex); - - ex = new CertException("Exception Message"); - assertNotNull(ex); - assertEquals(ex.getMessage(),"Exception Message"); - - ex = new CertException(new Throwable()); - assertNotNull(ex); - assertNotNull(ex.getCause()); - - ex = new CertException("Exception Message1", new Throwable()); - assertNotNull(ex.getCause()); - assertEquals(ex.getMessage(),"Exception Message1"); - } - -} \ No newline at end of file diff --git a/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java b/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java deleted file mode 100644 index 46fe3d4..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/aaf/client/JU_ErrMessageTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.aaf.client; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import java.io.PrintStream; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Answers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.stubbing.Answer; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.inno.env.APIException; -import org.onap.aaf.inno.env.Data.TYPE; -import org.onap.aaf.rosetta.env.RosettaDF; -import org.onap.aaf.rosetta.env.RosettaEnv; - -import aaf.v2_0.Error; - -public class JU_ErrMessageTest { - - @Mock - private RosettaEnv env; - - @Mock(answer=Answers.RETURNS_DEEP_STUBS) - private RosettaDF errDF; - - private ErrMessage errMessage; - - private String attErrJson = "key:value"; - - private Error error; - - private Future future; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - when(env.newDataFactory(Error.class)).thenReturn(errDF); - - future = new Future() { - - @Override - public boolean get(int timeout) throws CadiException { - return false; - } - - @Override - public int code() { - return 0; - } - - @Override - public String body() { - return "Body"; - } - - @Override - public String header(String tag) { - return "header"; - } - }; - - error = new Error(); - error.setMessageId("Error Message Id"); - error.setText("Error Text"); - errMessage = new ErrMessage(env); - - - } - - @Test - public void testPrintErrMessage() throws APIException { - when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error); - - errMessage.printErr(System.out, attErrJson); - } - - @Test - public void testToMsgJsonErrAttribute() throws APIException { - when(errDF.newData().in(TYPE.JSON).load(attErrJson).asObject()).thenReturn(error); - - StringBuilder sb = new StringBuilder(); - errMessage.toMsg(sb,attErrJson); - - assertEquals(sb.toString(),"Error Message Id Error Text"); - } - - @Test - public void testToMsgFuture() { - StringBuilder sb = errMessage.toMsg(future); - - assertEquals(sb.toString(), "0: Body"); - } - - - @Test - public void testToMsgFutureWithoutException() throws APIException { - when(errDF.newData().in(TYPE.JSON).load(future.body()).asObject()).thenReturn(error); - - StringBuilder sb = errMessage.toMsg(future); - - assertEquals(sb.toString(), "Error Message Id Error Text"); - } -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/JU_CertsMarshalTest.java b/aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/JU_CertsMarshalTest.java deleted file mode 100644 index a3c12d3..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/aaf/marshal/JU_CertsMarshalTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.aaf.marshal; -import static org.junit.Assert.*; - -import org.junit.Test; - - - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.onap.aaf.rosetta.ParseException; - -public class JU_CertsMarshalTest { - - @Test - public void test() throws ParseException { - CertsMarshal marshal = new CertsMarshal(); - assertNotNull(marshal); - } - - @Test - public void test2() throws ParseException { - CertsMarshal marshal = new CertsMarshal(); - assertNotNull(marshal); - } - - @Test - public void test3() throws ParseException { - CertsMarshal marshal = new CertsMarshal(); - assertNotNull(marshal); - } -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthnTest.java b/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthnTest.java deleted file mode 100644 index 9d95a6e..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/aaf/v2_0/JU_AAFAuthnTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.aaf.v2_0; -import static org.junit.Assert.*; - -import org.junit.Test; - - - -import static org.junit.Assert.*; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Mockito.when; - - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Answers; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.AbsUserCache; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.inno.env.APIException; - -import com.att.aft.dme2.internal.jersey.api.client.Client; - -public class JU_AAFAuthnTest { - - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private AAFCon con; - - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private Future fp; - - @Mock(answer = Answers.RETURNS_DEEP_STUBS) - private AbsUserCache cache; - - - @Before - public void setup() throws APIException, CadiException { - MockitoAnnotations.initMocks(this); - when(con.client(AAFCon.AAF_LATEST_VERSION).read("/authn/basicAuth", "text/plain")).thenReturn(fp); - } - - @Test - public void testAAFAuthnAAFConOfCLIENT() throws Exception { - when(fp.get(anyInt())).thenReturn(false); - when(fp.code()).thenReturn(401); - when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\""); - AAFAuthn auth = new AAFAuthn(con); - - assertNotNull(auth.validate("NewUser", "New Password"));; - } - - @Test - public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission() throws Exception { - AAFAuthn auth = new AAFAuthn(con,cache); - } - - @Test - public void testAAFAuthnAAFConOfCLIENT1() throws Exception { - when(fp.get(anyInt())).thenReturn(false); - when(fp.code()).thenReturn(401); - when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\""); - AAFAuthn auth = new AAFAuthn(con); - - assertNotNull(auth.validate("NewUser1", "New Password1"));; - } - - @Test - public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission1() throws Exception { - AAFAuthn auth = new AAFAuthn(con,cache); - } - - @Test - public void testAAFAuthnAAFConOfCLIENT2() throws Exception { - when(fp.get(anyInt())).thenReturn(false); - when(fp.code()).thenReturn(401); - when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\""); - AAFAuthn auth = new AAFAuthn(con); - - assertNotNull(auth.validate("NewUser2", "New Password2"));; - } - - @Test - public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission2() throws Exception { - AAFAuthn auth = new AAFAuthn(con,cache); - } - - @Test - public void testAAFAuthnAAFConOfCLIENT3() throws Exception { - when(fp.get(anyInt())).thenReturn(false); - when(fp.code()).thenReturn(401); - when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\""); - AAFAuthn auth = new AAFAuthn(con); - - assertNotNull(auth.validate("NewUser3", "New Password3"));; - } - - @Test - public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission3() throws Exception { - AAFAuthn auth = new AAFAuthn(con,cache); - } - - @Test - public void testAAFAuthnAAFConOfCLIENT4() throws Exception { - when(fp.get(anyInt())).thenReturn(false); - when(fp.code()).thenReturn(401); - when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\""); - AAFAuthn auth = new AAFAuthn(con); - - assertNotNull(auth.validate("NewUser4", "New Password4"));; - } - - @Test - public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission4() throws Exception { - AAFAuthn auth = new AAFAuthn(con,cache); - } - - @Test - public void testAAFAuthnAAFConOfCLIENT5() throws Exception { - when(fp.get(anyInt())).thenReturn(false); - when(fp.code()).thenReturn(401); - when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\""); - AAFAuthn auth = new AAFAuthn(con); - - assertNotNull(auth.validate("NewUser5", "New Password5"));; - } - - @Test - public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission5() throws Exception { - AAFAuthn auth = new AAFAuthn(con,cache); - } -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_JMeter.java b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_JMeter.java deleted file mode 100644 index 69c9688..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_JMeter.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.lur.aaf.test; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.HttpURLConnection; -import java.security.Principal; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.aaf.v2_0.AAFTaf; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.locator.DNSLocator; -import org.onap.aaf.cadi.principal.CachedBasicPrincipal; - -import junit.framework.Assert; - -public class JU_JMeter { - private static AAFConHttp aaf; - private static AAFAuthn aafAuthn; - private static AAFLurPerm aafLur; - private static ArrayList perfIDs; - - private static AAFTaf aafTaf; - private static PropAccess access; - - @BeforeClass - public static void before() throws Exception { - if(aafLur==null) { - Properties props = System.getProperties(); - props.setProperty("AFT_LATITUDE", "32.780140"); - props.setProperty("AFT_LONGITUDE", "-96.800451"); - props.setProperty("DME2_EP_REGISTRY_CLASS","DME2FS"); - props.setProperty("AFT_DME2_EP_REGISTRY_FS_DIR","/Volumes/Data/src/authz/dme2reg"); - props.setProperty("AFT_ENVIRONMENT", "AFTUAT"); - props.setProperty("SCLD_PLATFORM", "NON-PROD"); - props.setProperty(Config.AAF_URL,"https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE"); - props.setProperty(Config.AAF_READ_TIMEOUT, "2000"); - int timeToLive = 3000; - props.setProperty(Config.AAF_CLEAN_INTERVAL, Integer.toString(timeToLive)); - props.setProperty(Config.AAF_HIGH_COUNT, "4"); - - String aafPerfIDs = props.getProperty("AAF_PERF_IDS"); - perfIDs = new ArrayList(); - File perfFile = null; - if(aafPerfIDs!=null) { - perfFile = new File(aafPerfIDs); - } - - access = new PropAccess(); - aaf = new AAFConHttp(access, new DNSLocator(access,"https","localhost","8100")); - aafTaf = new AAFTaf(aaf,false); - aafLur = aaf.newLur(aafTaf); - aafAuthn = aaf.newAuthn(aafTaf); - aaf.basicAuth("testid@aaf.att.com", "whatever"); - - if(perfFile==null||!perfFile.exists()) { - perfIDs.add(new CachedBasicPrincipal(aafTaf, - "Basic dGVzdGlkOndoYXRldmVy", - "aaf.att.com",timeToLive)); - perfIDs.add(new Princ("ab1234@aaf.att.com")); // Example of Local ID, which isn't looked up - } else { - BufferedReader ir = new BufferedReader(new FileReader(perfFile)); - try { - String line; - while((line = ir.readLine())!=null) { - if((line=line.trim()).length()>0) - perfIDs.add(new Princ(line)); - } - } finally { - ir.close(); - } - } - Assert.assertNotNull(aafLur); - } - } - - private static class Princ implements Principal { - private String name; - public Princ(String name) { - this.name = name; - } - public String getName() { - return name; - } - - }; - - private static int index = -1; - - private synchronized Principal getIndex() { - if(perfIDs.size()<=++index)index=0; - return perfIDs.get(index); - } - @Test - public void test() { - try { - aafAuthn.validate("testid@aaf.att.com", "whatever"); - List perms = new ArrayList(); - aafLur.fishAll(getIndex(), perms); -// Assert.assertFalse(perms.isEmpty()); -// for(Permission p : perms) { -// //access.log(Access.Level.AUDIT, p.permType()); -// } - } catch (Exception e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - Assert.assertFalse(sw.toString(),true); - } - } - -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java deleted file mode 100644 index 1beef2c..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java +++ /dev/null @@ -1,574 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.lur.aaf.test; - -import static org.junit.Assert.assertEquals; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.security.Principal; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.AsyncContext; -import javax.servlet.DispatcherType; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.servlet.http.Part; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Lur; -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.Taf.LifeForm; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.aaf.v2_0.AAFTaf; -import org.onap.aaf.cadi.locator.DNSLocator; -import org.onap.aaf.cadi.lur.ConfigPrincipal; -import org.onap.aaf.cadi.lur.LocalPermission; -import org.onap.aaf.cadi.taf.TafResp; - -public class JU_Lur2_0Call { - private static AAFConHttp aaf; - private static PropAccess access; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - access = new PropAccess(); - aaf = new AAFConHttp(access,new DNSLocator(access,"https","localhost","8100")); - aaf.basicAuth("testid", "whatever"); - } - - @Test - public void test() throws Exception { - - AAFLurPerm aafLur = aaf.newLur(); - - Principal pri = new ConfigPrincipal("testid@aaf.att.com","whatever"); - for (int i = 0; i < 10; ++i) { - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|write"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kumquat|write"),false); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kumquat|read"),true); - - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","write"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","kumquat","write"),false); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","read"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","kumquat","read"),true); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum.*|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance"),true); - - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!kum.*","read"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","!wr*"),true); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum[Qq]uat|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my[iI]nstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my[iI]nstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|!wr*"),true); - - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!kum[Qq]uat","read"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!my[iI]nstance","!wr*"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","!my[iI]nstance","!wr*"),true); - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service","myInstance","!wr*"),true); - - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!my.nstance|!wr*"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|my.nstance|!wr*"),false); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|my.nstance|!wr*"),false); - - //Maitrayee, aren't we going to have issues if we do RegExp with "."? - //Is it too expensive to only do Reg Ex in presence of special characters, []{}*, etc? Not sure this helps for GRID. - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|kum.quat|read"),true); - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|!kum..uat|read"),true); - - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance"),true); // ok if Stored Action is "*" - - // Key Evaluations - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*:!my.*|write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*|write"),false); // not ok if key lengths don't match "*" - print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|:myCluster:*:myCF|write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*:!my.*","write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*:myCF","write"),true); // ok if Stored Action is "*" - print(aafLur, pri, new AAFPermission("com.test.JU_Lur2_0Call.service",":myCluster:*","write"),false); // not ok if key lengths don't match - - } - - print(aafLur, pri, new LocalPermission("bogus"),false); - -// try { -// Thread.sleep(7000); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } - for (int i = 0; i < 10; ++i) - print(aafLur, pri, new LocalPermission("supergroup"),false); - - System.out.println("All Done"); - } - @Test - public void testTaf() throws Exception { - AAFTaf aaft = new AAFTaf(aaf,true); - - TafResp resp; - // No Header - resp = aaft.validate(LifeForm.CBLF, new Req(), null); - assertEquals(TafResp.RESP.TRY_AUTHENTICATING, resp.isAuthenticated()); - - String auth = "Basic " + Symm.base64.encode("testid:whatever"); - resp = aaft.validate(LifeForm.CBLF, new Req("Authorization",auth), null); - assertEquals(TafResp.RESP.IS_AUTHENTICATED, resp.isAuthenticated()); - - } -// @Test -// public void testRole() throws CadiException { -// TestAccess ta = new TestAccess(); -// AAFLurRole1_0 aafLur = new AAFLurRole1_0( -// ta, -//// "http://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=1.0.0/envContext=UAT/routeOffer=BAU_SE", -// "http://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=1.0.0/envContext=DEV/routeOffer=D1", -// "m12345", "m12345pass", 50000, // dme Time -// // 5*60000); // 5 minutes User Expiration -// 50000, // 5 seconds after Expiration -// 200); // High Count of items.. These do not take much memory -// -// Principal pri = new ConfigPrincipal("xy1234","whatever"); -// for (int i = 0; i < 10; ++i) { -//// print(aafLur, pri, new LocalPermission("*|*|*|com.att.authz")); -// print(aafLur, pri, new LocalPermission("service|myInstance|write"),false); -// print(aafLur, pri, new LocalPermission("com.test.JU_Lur2_0Call.service|myInstance|write"),false); -// print(aafLur, pri, new LocalPermission("com.att.cadi"),true); -// print(aafLur, pri, new LocalPermission("global"),true); -// print(aafLur, pri, new LocalPermission("kumquat"),false); -// } -// -// print(aafLur, pri, new LocalPermission("bogus"),false); -// -// for (int i = 0; i < 10; ++i) -// print(aafLur, pri, new LocalPermission("supergroup"),false); -// -// System.out.println("All Done"); -// } - - - private void print(Lur aafLur, Principal pri, Permission perm, boolean shouldBe) - throws CadiException { - long start = System.nanoTime(); - - // The Call - boolean ok = aafLur.fish(pri, perm); - - assertEquals(shouldBe,ok); - float ms = (System.nanoTime() - start) / 1000000f; - if (ok) { - System.out.println("Yes, part of " + perm.getKey() + " (" + ms - + "ms)"); - } else { - System.out.println("No, not part of " + perm.getKey() + " (" + ms - + "ms)"); - } - } - - @SuppressWarnings("rawtypes") - public class Req implements HttpServletRequest { - private String[] headers; - - public Req(String ... headers) { - this.headers = headers; - } - - public Object getAttribute(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getAttributeNames() { - // TODO Auto-generated method stub - return null; - } - - public String getCharacterEncoding() { - // TODO Auto-generated method stub - return null; - } - - public void setCharacterEncoding(String env) - throws UnsupportedEncodingException { - // TODO Auto-generated method stub - - } - - public int getContentLength() { - // TODO Auto-generated method stub - return 0; - } - - public String getContentType() { - // TODO Auto-generated method stub - return null; - } - - public ServletInputStream getInputStream() throws IOException { - // TODO Auto-generated method stub - return null; - } - - public String getParameter(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getParameterNames() { - // TODO Auto-generated method stub - return null; - } - - public String[] getParameterValues(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Map getParameterMap() { - // TODO Auto-generated method stub - return null; - } - - public String getProtocol() { - // TODO Auto-generated method stub - return null; - } - - public String getScheme() { - // TODO Auto-generated method stub - return null; - } - - public String getServerName() { - // TODO Auto-generated method stub - return null; - } - - public int getServerPort() { - // TODO Auto-generated method stub - return 0; - } - - public BufferedReader getReader() throws IOException { - // TODO Auto-generated method stub - return null; - } - - public String getRemoteAddr() { - // TODO Auto-generated method stub - return null; - } - - public String getRemoteHost() { - // TODO Auto-generated method stub - return null; - } - - public void setAttribute(String name, Object o) { - // TODO Auto-generated method stub - - } - - public void removeAttribute(String name) { - // TODO Auto-generated method stub - - } - - public Locale getLocale() { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getLocales() { - // TODO Auto-generated method stub - return null; - } - - public boolean isSecure() { - // TODO Auto-generated method stub - return false; - } - - public RequestDispatcher getRequestDispatcher(String path) { - // TODO Auto-generated method stub - return null; - } - - public String getRealPath(String path) { - // TODO Auto-generated method stub - return null; - } - - public int getRemotePort() { - // TODO Auto-generated method stub - return 0; - } - - public String getLocalName() { - // TODO Auto-generated method stub - return null; - } - - public String getLocalAddr() { - // TODO Auto-generated method stub - return null; - } - - public int getLocalPort() { - // TODO Auto-generated method stub - return 0; - } - - public String getAuthType() { - // TODO Auto-generated method stub - return null; - } - - public Cookie[] getCookies() { - // TODO Auto-generated method stub - return null; - } - - public long getDateHeader(String name) { - // TODO Auto-generated method stub - return 0; - } - - public String getHeader(String name) { - for(int i=1;i getParts() throws IOException, ServletException { - // TODO Auto-generated method stub - return null; - } - - @Override - public Part getPart(String name) throws IOException, ServletException { - // TODO Auto-generated method stub - return null; - } - - } -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_MultiThreadPermHit.java b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_MultiThreadPermHit.java deleted file mode 100644 index 3779b4f..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_MultiThreadPermHit.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.lur.aaf.test; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.List; - -import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.locator.PropertyLocator; - -public class JU_MultiThreadPermHit { - public static void main(String args[]) { - // Link or reuse to your Logging mechanism - PropAccess myAccess = new PropAccess(); // - - // - try { - AAFConHttp con = new AAFConHttp(myAccess,new PropertyLocator("https://mithrilcsp.sbc.com:8100")); - - // AAFLur has pool of DME clients as needed, and Caches Client lookups - final AAFLurPerm aafLur = con.newLur(); - aafLur.setDebug("m12345@aaf.att.com"); - - // Note: If you need both Authn and Authz construct the following: - AAFAuthn aafAuthn = con.newAuthn(aafLur); - - // Do not set Mech ID until after you construct AAFAuthn, - // because we initiate "401" info to determine the Realm of - // of the service we're after. - final String id = myAccess.getProperty(Config.AAF_MECHID,null); - final String pass = myAccess.decrypt(myAccess.getProperty(Config.AAF_MECHPASS,null),false); - if(id!=null && pass!=null) { - try { - - // Normally, you obtain Principal from Authentication System. - // // For J2EE, you can ask the HttpServletRequest for getUserPrincipal() - // // If you use CADI as Authenticator, it will get you these Principals from - // // CSP or BasicAuth mechanisms. - // String id = "cluster_admin@gridcore.att.com"; - // - // // If Validate succeeds, you will get a Null, otherwise, you will a String for the reason. - String ok; - ok = aafAuthn.validate(id, pass); - if(ok!=null) { - System.out.println(ok); - } - - List pond = new ArrayList(); - for(int i=0;i<20;++i) { - pond.clear(); - aafLur.fishAll(i+id, pond); - if(ok!=null && i%1000==0) { - System.out.println(i + " " + ok); - } - } - - for(int i=0;i<1000000;++i) { - ok = aafAuthn.validate( i+ id, "wrongPass"); - if(ok!=null && i%1000==0) { - System.out.println(i + " " + ok); - } - } - - final AAFPermission perm = new AAFPermission("com.att.aaf.access","*","*"); - - // Now you can ask the LUR (Local Representative of the User Repository about Authorization - // With CADI, in J2EE, you can call isUserInRole("com.att.mygroup|mytype|write") on the Request Object - // instead of creating your own LUR - for(int i=0;i<4;++i) { - if(aafLur.fish(id, perm)) { - System.out.println("Yes, " + id + " has permission for " + perm.getKey()); - } else { - System.out.println("No, " + id + " does not have permission for " + perm.getKey()); - } - } - - - // Or you can all for all the Permissions available - List perms = new ArrayList(); - - - aafLur.fishAll(id,perms); - System.out.println("Perms for " + id); - for(Permission prm : perms) { - System.out.println(prm.getKey()); - } - - System.out.println("Press any key to continue"); - System.in.read(); - - for(int j=0;j<5;++j) { - new Thread(new Runnable() { - @Override - public void run() { - for(int i=0;i<20;++i) { - if(aafLur.fish(id, perm)) { - System.out.println("Yes, " + id + " has permission for " + perm.getKey()); - } else { - System.out.println("No, " + id + " does not have permission for " + perm.getKey()); - } - } - } - }).start(); - } - - - } finally { - aafLur.destroy(); - } - } else { // checked on IDs - System.err.println(Config.AAF_MECHID + " and/or " + Config.AAF_MECHPASS + " are not set."); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_PermEval.java b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_PermEval.java deleted file mode 100644 index d60eedb..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_PermEval.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.lur.aaf.test; - -import static org.junit.Assert.*; - -import org.junit.AfterClass; -import org.junit.Test; -import org.onap.aaf.cadi.aaf.PermEval; - -public class JU_PermEval { - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Test - public void test() { - assertTrue(PermEval.evalInstance(":com.att.temp:role:write",":!com.att.*:role:write")); - - // TRUE - assertTrue(PermEval.evalAction("fred","fred")); - assertTrue(PermEval.evalAction("fred,wilma","fred")); - assertTrue(PermEval.evalAction("barney,betty,fred,wilma","fred")); - assertTrue(PermEval.evalAction("*","fred")); - - assertTrue(PermEval.evalInstance("fred","fred")); - assertTrue(PermEval.evalInstance("fred,wilma","fred")); - assertTrue(PermEval.evalInstance("barney,betty,fred,wilma","fred")); - assertTrue(PermEval.evalInstance("*","fred")); - - assertTrue(PermEval.evalInstance(":fred:fred",":fred:fred")); - assertTrue(PermEval.evalInstance(":fred:fred,wilma",":fred:fred")); - assertTrue(PermEval.evalInstance(":fred:barney,betty,fred,wilma",":fred:fred")); - assertTrue(PermEval.evalInstance("*","fred")); - assertTrue(PermEval.evalInstance(":*:fred",":fred:fred")); - assertTrue(PermEval.evalInstance(":fred:*",":fred:fred")); - assertTrue(PermEval.evalInstance(":fred:fred",":!f.*:fred")); - assertTrue(PermEval.evalInstance(":fred:fred",":fred:!f.*")); - - /// FALSE - assertFalse(PermEval.evalInstance("fred","wilma")); - assertFalse(PermEval.evalInstance("fred,barney,betty","wilma")); - assertFalse(PermEval.evalInstance(":fred:fred",":fred:wilma")); - assertFalse(PermEval.evalInstance(":fred:fred",":wilma:fred")); - assertFalse(PermEval.evalInstance(":fred:fred",":wilma:!f.*")); - assertFalse(PermEval.evalInstance(":fred:fred",":!f.*:wilma")); - assertFalse(PermEval.evalInstance(":fred:fred",":!w.*:!f.*")); - assertFalse(PermEval.evalInstance(":fred:fred",":!f.*:!w.*")); - - assertFalse(PermEval.evalInstance(":fred:fred",":fred:!x.*")); - - // MSO Tests 12/3/2015 - assertFalse(PermEval.evalInstance("/v1/services/features/*","/v1/services/features")); - assertFalse(PermEval.evalInstance(":v1:services:features:*",":v1:services:features")); - assertTrue(PermEval.evalInstance("/v1/services/features/*","/v1/services/features/api1")); - assertTrue(PermEval.evalInstance(":v1:services:features:*",":v1:services:features:api2")); - // MSO - Xue Gao - assertTrue(PermEval.evalInstance(":v1:requests:*",":v1:requests:test0-service")); - - - - // Same tests, with Slashes - assertTrue(PermEval.evalInstance("/fred/fred","/fred/fred")); - assertTrue(PermEval.evalInstance("/fred/fred,wilma","/fred/fred")); - assertTrue(PermEval.evalInstance("/fred/barney,betty,fred,wilma","/fred/fred")); - assertTrue(PermEval.evalInstance("*","fred")); - assertTrue(PermEval.evalInstance("/*/fred","/fred/fred")); - assertTrue(PermEval.evalInstance("/fred/*","/fred/fred")); - assertTrue(PermEval.evalInstance("/fred/fred","/!f.*/fred")); - assertTrue(PermEval.evalInstance("/fred/fred","/fred/!f.*")); - - /// FALSE - assertFalse(PermEval.evalInstance("fred","wilma")); - assertFalse(PermEval.evalInstance("fred,barney,betty","wilma")); - assertFalse(PermEval.evalInstance("/fred/fred","/fred/wilma")); - assertFalse(PermEval.evalInstance("/fred/fred","/wilma/fred")); - assertFalse(PermEval.evalInstance("/fred/fred","/wilma/!f.*")); - assertFalse(PermEval.evalInstance("/fred/fred","/!f.*/wilma")); - assertFalse(PermEval.evalInstance("/fred/fred","/!w.*/!f.*")); - assertFalse(PermEval.evalInstance("/fred/fred","/!f.*/!w.*")); - - assertFalse(PermEval.evalInstance("/fred/fred","/fred/!x.*")); - - } - -} diff --git a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_TestAccess.java b/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_TestAccess.java deleted file mode 100644 index f3d66a6..0000000 --- a/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_TestAccess.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi.lur.aaf.test; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; - -import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.Symm; -import org.onap.aaf.cadi.config.Config; - -public class JU_TestAccess implements Access { - private Symm symm; - private PrintStream out; - - public JU_TestAccess(PrintStream out) { - this.out = out; - InputStream is = ClassLoader.getSystemResourceAsStream("cadi.properties"); - try { - System.getProperties().load(is); - } catch (IOException e) { - e.printStackTrace(out); - } finally { - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(out); - } - } - - String keyfile = System.getProperty(Config.CADI_KEYFILE); - if(keyfile==null) { - System.err.println("No " + Config.CADI_KEYFILE + " in Classpath"); - } else { - try { - is = new FileInputStream(keyfile); - try { - symm = Symm.obtain(is); - } finally { - is.close(); - } - } catch (IOException e) { - e.printStackTrace(out); - } - } - - - - } - - public void log(Level level, Object... elements) { - boolean first = true; - for(int i=0;i errDF = env.newDataFactory(aaf.v2_0.Error.class); - errDF.in(RosettaData.TYPE.JSON); - errDF.out(RosettaData.TYPE.JSON); - RosettaData data = errDF.newData(); - data.load(err); - System.out.println(data.asString()); - - data.load(new StringReader(msg)); - err = data.asObject(); - System.out.println(err.getText()); - } - - -} diff --git a/aaf/src/test/java/org/onap/aaf/example/JU_CadiTest.java b/aaf/src/test/java/org/onap/aaf/example/JU_CadiTest.java deleted file mode 100644 index 17fd827..0000000 --- a/aaf/src/test/java/org/onap/aaf/example/JU_CadiTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.example; - -import java.net.HttpURLConnection; -import java.net.URI; - -import org.onap.aaf.cadi.Access; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.config.SecurityInfoC; -import org.onap.aaf.cadi.http.HClient; -import org.onap.aaf.cadi.http.HX509SS; - -public class JU_CadiTest { - public static void main(String args[]) { - Access access = new PropAccess(); - try { - SecurityInfoC si = new SecurityInfoC(access); - HClient hclient = new HClient( - new HX509SS(si), - new URI("https://mithrilcsp.sbc.com:8085"),3000); - hclient.setMethod("OPTIONS"); - hclient.setPathInfo("/gui/cadi/log/toggle/INFO"); - hclient.send(); - Future future = hclient.futureReadString(); - if(future.get(5000)) { - System.out.println(future.value); - } else { - System.out.printf("Error: %d-%s", future.code(),future.body()); - } - - } catch (Exception e) { - e.printStackTrace(); - } - - } -} diff --git a/aaf/src/test/java/org/onap/aaf/example/JU_ExampleAuthCheck.java b/aaf/src/test/java/org/onap/aaf/example/JU_ExampleAuthCheck.java deleted file mode 100644 index cb4e48f..0000000 --- a/aaf/src/test/java/org/onap/aaf/example/JU_ExampleAuthCheck.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.example; - -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.locator.DNSLocator; - -public class JU_ExampleAuthCheck { - public static void main(String args[]) { - // Link or reuse to your Logging mechanism - PropAccess myAccess = new PropAccess(); // - - try { - AAFConHttp acon = new AAFConHttp(myAccess, new DNSLocator( - myAccess,"https","localhost","8100")); - AAFAuthn authn = acon.newAuthn(); - long start; - for (int i=0;i<10;++i) { - start = System.nanoTime(); - String err = authn.validate("", "gritty"); - if(err!=null) System.err.println(err); - else System.out.println("I'm ok"); - - err = authn.validate("bogus", "gritty"); - if(err!=null) System.err.println(err + " (correct error)"); - else System.out.println("I'm ok"); - - System.out.println((System.nanoTime()-start)/1000000f + " ms"); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } -} diff --git a/aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0.java b/aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0.java deleted file mode 100644 index 652cadb..0000000 --- a/aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.example; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.List; - -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn; -import org.onap.aaf.cadi.aaf.v2_0.AAFCon; -import org.onap.aaf.cadi.aaf.v2_0.AAFConDME2; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; - -public class JU_ExamplePerm2_0 { - public static void main(String args[]) { - - // Link or reuse to your Logging mechanism - PropAccess myAccess = new PropAccess(); - - // - try { - AAFCon acon = new AAFConDME2(myAccess); - - // AAFLur has pool of DME clients as needed, and Caches Client lookups - AAFLurPerm aafLur = acon.newLur(); - - // Note: If you need both Authn and Authz construct the following: - AAFAuthn aafAuthn = acon.newAuthn(aafLur); - - // Do not set Mech ID until after you construct AAFAuthn, - // because we initiate "401" info to determine the Realm of - // of the service we're after. - acon.basicAuth("mc0897@aaf.att.com", "XXXXXX"); - - try { - - // Normally, you obtain Principal from Authentication System. - // For J2EE, you can ask the HttpServletRequest for getUserPrincipal() - // If you use CADI as Authenticator, it will get you these Principals from - // CSP or BasicAuth mechanisms. - String id = "mc0897@aaf.att.com"; //"cluster_admin@gridcore.att.com"; - - // If Validate succeeds, you will get a Null, otherwise, you will a String for the reason. - String ok = aafAuthn.validate(id, "XXXXXX"); - if(ok!=null)System.out.println(ok); - - ok = aafAuthn.validate(id, "wrongPass"); - if(ok!=null)System.out.println(ok); - - - // AAF Style permissions are in the form - // Type, Instance, Action - AAFPermission perm = new AAFPermission("com.att.grid.core.coh",":dev_cluster", "WRITE"); - - // Now you can ask the LUR (Local Representative of the User Repository about Authorization - // With CADI, in J2EE, you can call isUserInRole("com.att.mygroup|mytype|write") on the Request Object - // instead of creating your own LUR - System.out.println("Does " + id + " have " + perm); - if(aafLur.fish(id, perm)) { - System.out.println("Yes, you have permission"); - } else { - System.out.println("No, you don't have permission"); - } - - System.out.println("Does Bogus have " + perm); - if(aafLur.fish("Bogus", perm)) { - System.out.println("Yes, you have permission"); - } else { - System.out.println("No, you don't have permission"); - } - - // Or you can all for all the Permissions available - List perms = new ArrayList(); - - aafLur.fishAll(id,perms); - for(Permission prm : perms) { - System.out.println(prm.getKey()); - } - - // It might be helpful in some cases to clear the User's identity from the Cache - aafLur.remove(id); - } finally { - aafLur.destroy(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } -} diff --git a/aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0_DME2.java b/aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0_DME2.java deleted file mode 100644 index 88e2936..0000000 --- a/aaf/src/test/java/org/onap/aaf/example/JU_ExamplePerm2_0_DME2.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.example; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.List; - -import org.onap.aaf.cadi.Permission; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.AAFPermission; -import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.locator.DNSLocator; - -public class JU_ExamplePerm2_0_DME2 { - public static void main(String args[]) { - // Link or reuse to your Logging mechanism - PropAccess myAccess = new PropAccess(); - - // - try { - AAFConHttp acon = new AAFConHttp(myAccess, new DNSLocator( - myAccess,"https","localhost","8100")); - - // AAFLur has pool of DME clients as needed, and Caches Client lookups - AAFLurPerm aafLur = acon.newLur(); - - // Note: If you need both Authn and Authz construct the following: - AAFAuthn aafAuthn = acon.newAuthn(aafLur); - - // Do not set Mech ID until after you construct AAFAuthn, - // because we initiate "401" info to determine the Realm of - // of the service we're after. - acon.basicAuth("mc0897@aaf.att.com", "XXXXXX"); - - try { - - // Normally, you obtain Principal from Authentication System. - // For J2EE, you can ask the HttpServletRequest for getUserPrincipal() - // If you use CADI as Authenticator, it will get you these Principals from - // CSP or BasicAuth mechanisms. - String id = "mc0897@aaf.att.com"; //"cluster_admin@gridcore.att.com"; - - // If Validate succeeds, you will get a Null, otherwise, you will a String for the reason. - String ok = aafAuthn.validate(id, "XXXXXX"); - if(ok!=null)System.out.println(ok); - - ok = aafAuthn.validate(id, "wrongPass"); - if(ok!=null)System.out.println(ok); - - - // AAF Style permissions are in the form - // Type, Instance, Action - AAFPermission perm = new AAFPermission("com.att.grid.core.coh",":dev_cluster", "WRITE"); - - // Now you can ask the LUR (Local Representative of the User Repository about Authorization - // With CADI, in J2EE, you can call isUserInRole("com.att.mygroup|mytype|write") on the Request Object - // instead of creating your own LUR - System.out.println("Does " + id + " have " + perm); - if(aafLur.fish(id, perm)) { - System.out.println("Yes, you have permission"); - } else { - System.out.println("No, you don't have permission"); - } - - System.out.println("Does Bogus have " + perm); - if(aafLur.fish("Bogus", perm)) { - System.out.println("Yes, you have permission"); - } else { - System.out.println("No, you don't have permission"); - } - - // Or you can all for all the Permissions available - List perms = new ArrayList(); - - aafLur.fishAll(id,perms); - for(Permission prm : perms) { - System.out.println(prm.getKey()); - } - - // It might be helpful in some cases to clear the User's identity from the Cache - aafLur.remove(id); - } finally { - aafLur.destroy(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } -} diff --git a/aaf/src/test/java/org/onap/aaf/example/JU_X509Test.java b/aaf/src/test/java/org/onap/aaf/example/JU_X509Test.java deleted file mode 100644 index e756f6d..0000000 --- a/aaf/src/test/java/org/onap/aaf/example/JU_X509Test.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * ============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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.example; - -import java.security.Principal; - -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp; -import org.onap.aaf.cadi.aaf.v2_0.AAFLurPerm; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.locator.DNSLocator; -import org.onap.aaf.cadi.lur.LocalPermission; - -public class JU_X509Test { - public static void main(String args[]) { - // Link or reuse to your Logging mechanism - - PropAccess myAccess = new PropAccess(); - - // - try { - AAFConHttp con = new AAFConHttp(myAccess, - new DNSLocator(myAccess,"https","mithrilcsp.sbc.com","8100")); - - // AAFLur has pool of DME clients as needed, and Caches Client lookups - AAFLurPerm aafLur = con.newLur(); - - // Note: If you need both Authn and Authz construct the following: -// AAFAuthn aafAuthn = con.newAuthn(aafLur); - - // con.x509Alias("aaf.att"); // alias in keystore - - try { - - // Normally, you obtain Principal from Authentication System. -// // For J2EE, you can ask the HttpServletRequest for getUserPrincipal() -// // If you use CADI as Authenticator, it will get you these Principals from -// // CSP or BasicAuth mechanisms. -// String id = "cluster_admin@gridcore.att.com"; -// -// // If Validate succeeds, you will get a Null, otherwise, you will a String for the reason. - Future fs = - con.client("2.0").read("/authz/perms/com.att.aaf.ca","application/Perms+json"); - if(fs.get(3000)) { - System.out.println(fs.value); - } else { - System.out.println("Error: " + fs.code() + ':' + fs.body()); - } - - // Check on Perms with LUR - if(aafLur.fish(new Principal() { - @Override - public String getName() { - return "m12345@aaf.att.com"; - } - }, new LocalPermission("com.att.aaf.ca|aaf|request"))) { - System.out.println("Has Perm"); - } else { - System.out.println("Does NOT Have Perm"); - } - } finally { - aafLur.destroy(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } -} diff --git a/aaf/src/test/resources/cadi.properties b/aaf/src/test/resources/cadi.properties deleted file mode 100644 index 8f1209a..0000000 --- a/aaf/src/test/resources/cadi.properties +++ /dev/null @@ -1,52 +0,0 @@ -#------------------------------------------------------------------------------- -# ============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==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- -############################################################################### -# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -############################################################################### -## -## AUTHZ API (authz-service) Properties -## - -cadi_prop_file=com.att.aaf.props;com.att.aaf.common.props - -#cadi_trust_all_x509=true -#cadi_alias=aaf.att -https.protocols=TLSv1.1,TLSv1.2 - -cm_url=https://XXX:8150 - -basic_realm=localized -basic_warn=false -localhost_deny=false - -cass_group_name=com.att.aaf -cass_cluster_name=mithrilcsp.sbc.com -aaf_default_realm=com.att.csp - -aaf_url=https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE -aaf_id=??? -aaf_password=enc:XXX - -aaf_user_expires=3000 -aaf_clean_interval=4000 - diff --git a/aaf/src/test/resources/log4j.properties b/aaf/src/test/resources/log4j.properties deleted file mode 100644 index c4686fd..0000000 --- a/aaf/src/test/resources/log4j.properties +++ /dev/null @@ -1,57 +0,0 @@ -#------------------------------------------------------------------------------- -# ============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==================================================== -# * -# * ECOMP is a trademark and service mark of AT&T Intellectual Property. -# * -#------------------------------------------------------------------------------- -############################################################################### -# Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. -############################################################################### -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] %m %n - -# General Apache libraries -log4j.rootLogger=WARN,stdout -log4j.logger.org.apache=WARN,stdout -log4j.logger.dme2=WARN,stdout -log4j.logger.init=INFO,stdout -log4j.logger.authz=INFO,stdout -log4j.logger.audit=WARN,stdout - - - diff --git a/aaf/src/test/resources/logging.props b/aaf/src/test/resources/logging.props deleted file mode 100644 index 9a30a2a..0000000 --- a/aaf/src/test/resources/logging.props +++ /dev/null @@ -1,38 +0,0 @@ -| ############################################################ -# Default Logging Configuration File -# -# You can use a different file by specifying a filename -# with the java.util.logging.config.file system property. -# For example java -Djava.util.logging.config.file=myfile -############################################################ - -############################################################ -# Global properties -############################################################ - -# "handlers" specifies a comma separated list of log Handler -# classes. These handlers will be installed during VM startup. -# Note that these classes must be on the system classpath. -# By default we only configure a ConsoleHandler, which will only -# show messages at the INFO and above levels. -handlers=java.util.logging.FileHandler - -# Default global logging level. -# This specifies which kinds of events are logged across -# all loggers. For any given facility this global level -# can be overriden by a facility specific level -# Note that the ConsoleHandler also has a separate level -# setting to limit messages printed to the console. -.level=INFO - -############################################################ -# Handler specific properties. -# Describes specific configuration info for Handlers. -############################################################ -java.util.logging.FileHandler.properties=autoFlush,fileName,dataPattern,name -java.util.logging.FileHandler.fileName=%h/.aaf/dme2.log -java.util.logging.FileHandlerFileHandler.autoFlush=true -java.util.logging.FileHandlerFileHandler.name=DailyRollingFileHandler -java.util.logging.FileHandlerFileHandler.datePattern='.'yyyy-MM-dd -com.att.aft.dme2.events.server.summary=INFO - -- cgit 1.2.3-korg