diff options
author | Instrumental <jcgmisc@stl.gathman.org> | 2018-03-26 14:07:37 -0700 |
---|---|---|
committer | Instrumental <jcgmisc@stl.gathman.org> | 2018-03-26 14:07:42 -0700 |
commit | 10027f3cd15afd2c8ef341e5cd92de911e07965e (patch) | |
tree | 33982e04750074d4f123eeb960b5302522223f4b /cadi | |
parent | 71037c39a37d3549dcfe31926832a657744fbe05 (diff) |
AT&T 2.0.19 Code drop, stage 4
Issue-ID: AAF-197
Change-Id: Ibe14fed4b583966dca5559710bced7bec868eae9
Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'cadi')
-rw-r--r-- | cadi/aaf/pom.xml | 2 | ||||
-rw-r--r-- | cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java | 573 | ||||
-rw-r--r-- | cadi/client/pom.xml | 2 | ||||
-rw-r--r-- | cadi/core/pom.xml | 2 | ||||
-rw-r--r-- | cadi/pom.xml | 4 |
5 files changed, 5 insertions, 578 deletions
diff --git a/cadi/aaf/pom.xml b/cadi/aaf/pom.xml index d7b6f550..368d02a6 100644 --- a/cadi/aaf/pom.xml +++ b/cadi/aaf/pom.xml @@ -85,7 +85,7 @@ <dependency> <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> + <artifactId>servlet-api</artifactId> <scope>provided</scope> </dependency> </dependencies> diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java deleted file mode 100644 index ddc7f001..00000000 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/lur/aaf/test/JU_Lur2_0Call.java +++ /dev/null @@ -1,573 +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==================================================== - * * - * * - ******************************************************************************/ -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<HttpURLConnection>(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("org.osaaf.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<headers.length;i=i+2) { - if(headers[i-1].equals(name)) return headers[i]; - } - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getHeaders(String name) { - // TODO Auto-generated method stub - return null; - } - - @SuppressWarnings("unchecked") - public Enumeration getHeaderNames() { - // TODO Auto-generated method stub - return null; - } - - public int getIntHeader(String name) { - // TODO Auto-generated method stub - return 0; - } - - public String getMethod() { - // TODO Auto-generated method stub - return null; - } - - public String getPathInfo() { - // TODO Auto-generated method stub - return null; - } - - public String getPathTranslated() { - // TODO Auto-generated method stub - return null; - } - - public String getContextPath() { - // TODO Auto-generated method stub - return null; - } - - public String getQueryString() { - // TODO Auto-generated method stub - return null; - } - - public String getRemoteUser() { - // TODO Auto-generated method stub - return null; - } - - public boolean isUserInRole(String role) { - // TODO Auto-generated method stub - return false; - } - - public Principal getUserPrincipal() { - // TODO Auto-generated method stub - return null; - } - - public String getRequestedSessionId() { - // TODO Auto-generated method stub - return null; - } - - public String getRequestURI() { - // TODO Auto-generated method stub - return null; - } - - public StringBuffer getRequestURL() { - // TODO Auto-generated method stub - return null; - } - - public String getServletPath() { - // TODO Auto-generated method stub - return null; - } - - public HttpSession getSession(boolean create) { - // TODO Auto-generated method stub - return null; - } - - public HttpSession getSession() { - // TODO Auto-generated method stub - return null; - } - - public boolean isRequestedSessionIdValid() { - // TODO Auto-generated method stub - return false; - } - - public boolean isRequestedSessionIdFromCookie() { - // TODO Auto-generated method stub - return false; - } - - public boolean isRequestedSessionIdFromURL() { - // TODO Auto-generated method stub - return false; - } - - public boolean isRequestedSessionIdFromUrl() { - // TODO Auto-generated method stub - return false; - } - - @Override - public ServletContext getServletContext() { - // TODO Auto-generated method stub - return null; - } - - @Override - public AsyncContext startAsync() throws IllegalStateException { - // TODO Auto-generated method stub - return null; - } - - @Override - public AsyncContext startAsync(ServletRequest servletRequest, - ServletResponse servletResponse) throws IllegalStateException { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isAsyncStarted() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isAsyncSupported() { - // TODO Auto-generated method stub - return false; - } - - @Override - public AsyncContext getAsyncContext() { - // TODO Auto-generated method stub - return null; - } - - @Override - public DispatcherType getDispatcherType() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean authenticate(HttpServletResponse response) - throws IOException, ServletException { - // TODO Auto-generated method stub - return false; - } - - @Override - public void login(String username, String password) - throws ServletException { - // TODO Auto-generated method stub - - } - - @Override - public void logout() throws ServletException { - // TODO Auto-generated method stub - - } - - @Override - public Collection<Part> 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/cadi/client/pom.xml b/cadi/client/pom.xml index 1081ab09..a553b1b0 100644 --- a/cadi/client/pom.xml +++ b/cadi/client/pom.xml @@ -72,7 +72,7 @@ <dependency> <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> + <artifactId>servlet-api</artifactId> <scope>compile</scope> </dependency> </dependencies> diff --git a/cadi/core/pom.xml b/cadi/core/pom.xml index 1e8ea1c9..5ad6baac 100644 --- a/cadi/core/pom.xml +++ b/cadi/core/pom.xml @@ -54,7 +54,7 @@ <dependencies> <dependency> <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> + <artifactId>servlet-api</artifactId> <scope>provided</scope> </dependency> </dependencies> diff --git a/cadi/pom.xml b/cadi/pom.xml index 7fecc035..0634cc69 100644 --- a/cadi/pom.xml +++ b/cadi/pom.xml @@ -233,8 +233,8 @@ <dependency> <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.0.1</version> + <artifactId>servlet-api</artifactId> + <version>2.5</version> </dependency> <dependency> |