diff options
author | Instrumental <jcgmisc@stl.gathman.org> | 2018-03-26 13:51:48 -0700 |
---|---|---|
committer | Instrumental <jcgmisc@stl.gathman.org> | 2018-03-26 13:52:07 -0700 |
commit | 71037c39a37d3549dcfe31926832a657744fbe05 (patch) | |
tree | 78911b2b5e86e4e44228f7a27b3a8cd954b7f3e2 /auth/auth-fs | |
parent | a20accc73189d8e5454cd26049c0e6fae75da16f (diff) |
AT&T 2.0.19 Code drop, stage 3
Issue-ID: AAF-197
Change-Id: I8b02cb073ccba318ccaf6ea0276446bdce88fb82
Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'auth/auth-fs')
-rw-r--r-- | auth/auth-fs/.gitignore | 7 | ||||
-rw-r--r-- | auth/auth-fs/pom.xml | 122 | ||||
-rw-r--r-- | auth/auth-fs/src/main/config/.gitignore | 1 | ||||
-rw-r--r-- | auth/auth-fs/src/main/config/FileServer.props | 23 | ||||
-rw-r--r-- | auth/auth-fs/src/main/data/favicon.ico | bin | 0 -> 3638 bytes | |||
-rw-r--r-- | auth/auth-fs/src/main/data/test.html | 20 | ||||
-rw-r--r-- | auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java | 115 | ||||
-rw-r--r-- | auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_FileServer.java | 81 |
8 files changed, 369 insertions, 0 deletions
diff --git a/auth/auth-fs/.gitignore b/auth/auth-fs/.gitignore new file mode 100644 index 00000000..d3881782 --- /dev/null +++ b/auth/auth-fs/.gitignore @@ -0,0 +1,7 @@ +/target/ +/.classpath +/.settings +/.project +/Dockerfile +/dbuild +/drun diff --git a/auth/auth-fs/pom.xml b/auth/auth-fs/pom.xml new file mode 100644 index 00000000..11582b4b --- /dev/null +++ b/auth/auth-fs/pom.xml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 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==================================================== + * +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.aaf.auth</groupId> + <artifactId>parent</artifactId> + <version>2.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>aaf-auth-fs</artifactId> + <name>AAF Auth File Server (http)</name> + <description>Independent FileServer Component via HTTP (not S) for Public Files (i.e. CRLs) for AAF Auth</description> + + <properties> + <maven.test.failure.ignore>true</maven.test.failure.ignore> + </properties> + + <developers> + <developer> + <name>Jonathan Gathman</name> + <email>jonathan.gathman@att.com</email> + <organization>ATT</organization> + <roles> + <role>Architect</role> + <role>Lead Developer</role> + </roles> + </developer> + <developer> + <name>Gabe Maurer</name> + <email>gabe.maurer@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + <developer> + <name>Ian Howell</name> + <email>ian.howell@att.com</email> + <organization>ATT</organization> + <roles> + <role>Developer</role> + </roles> + </developer> + </developers> + + <dependencies> + <dependency> + <groupId>org.onap.aaf.auth</groupId> + <artifactId>aaf-auth-core</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.aaf.cadi</groupId> + <artifactId>aaf-cadi-core</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>appassembler-maven-plugin</artifactId> + <configuration> + <programs> + <program> + <mainClass>org.onap.aaf.auth.fs.AAF_FS</mainClass> + <name>fs</name> + <commandLineArguments> + <commandLineArgument>cadi_prop_files=${project.conf_dir}/org.osaaf.fs.props</commandLineArgument> + </commandLineArguments> + </program> + </programs> + </configuration> + </plugin> + </plugins> + <pluginManagement> + <plugins /> + </pluginManagement> + </build> + + <distributionManagement> + <repository> + <id>nexus</id> + <name>attarch-releases</name> + <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-releases</url> + </repository> + <snapshotRepository> + <id>nexus</id> + <name>attarch-snapshots</name> + <url>http://mavencentral.it.att.com:8084/nexus/content/repositories/attarch-snapshots</url> + </snapshotRepository> + </distributionManagement> +</project> diff --git a/auth/auth-fs/src/main/config/.gitignore b/auth/auth-fs/src/main/config/.gitignore new file mode 100644 index 00000000..e53ef90a --- /dev/null +++ b/auth/auth-fs/src/main/config/.gitignore @@ -0,0 +1 @@ +/log4j.properties diff --git a/auth/auth-fs/src/main/config/FileServer.props b/auth/auth-fs/src/main/config/FileServer.props new file mode 100644 index 00000000..9c123307 --- /dev/null +++ b/auth/auth-fs/src/main/config/FileServer.props @@ -0,0 +1,23 @@ +## +## AUTHZ API (authz-service) Properties +## + +hostname=_HOSTNAME_ + +## DISCOVERY (DME2) Parameters on the Command Line +AFT_LATITUDE=_AFT_LATITUDE_ +AFT_LONGITUDE=_AFT_LONGITUDE_ +AFT_ENVIRONMENT=_AFT_ENVIRONMENT_ +DEPLOYED_VERSION=_ARTIFACT_VERSION_ + +cadi_prop_files=/opt/app/aaf/common/com.att.aaf.common.props:/opt/app/aaf/common/com.att.aaf.props + +DMEServiceName=service=com.att.authz.authz-fs/version=_MAJOR_VER_._MINOR_VER_._PATCH_VER_/envContext=_ENV_CONTEXT_/routeOffer=_ROUTE_OFFER_ +AFT_DME2_PORT_RANGE=_AUTHZ_FS_PORT_RANGE_ +AFT_DME2_SSL_ENABLE=false +AFT_DME2_DISABLE_PERSISTENT_CACHE=true + +CFA_WebPath=/opt/app/aaf/public +CFA_ClearCommand=FmzYPpMY918MwE1hyacoiFSt +CFA_MaxSize=2000000 + diff --git a/auth/auth-fs/src/main/data/favicon.ico b/auth/auth-fs/src/main/data/favicon.ico Binary files differnew file mode 100644 index 00000000..3aea2722 --- /dev/null +++ b/auth/auth-fs/src/main/data/favicon.ico diff --git a/auth/auth-fs/src/main/data/test.html b/auth/auth-fs/src/main/data/test.html new file mode 100644 index 00000000..ec50246c --- /dev/null +++ b/auth/auth-fs/src/main/data/test.html @@ -0,0 +1,20 @@ +<html> + <head> <!-- begin head --> + <meta charset="utf-8"> + <title>AT&T Authentication/Authorization Tool</title> + <!-- + <link rel="stylesheet" href="_AUTHZ_GUI_URL_/theme/aaf5.css"> + <script type="text/javascript" src="_AUTHZ_GUI_URL_/theme/comm.js"></script> + <script type="text/javascript" src="_AUTHZ_GUI_URL_/theme/console.js"></script> + <script type="text/javascript" src="_AUTHZ_GUI_URL_/theme/common.js"></script> + <link rel="stylesheet" href="_AUTHZ_GUI_URL_/theme/aaf5Desktop.css"> + --> + </head> <!-- end head --> + <body> <!-- begin body --> + <header> <!-- begin header --> + <h1>AT&T Auth Tool on _ENV_CONTEXT_</h1> + <p id="version">AAF Version: _ARTIFACT_VERSION_</p> + </header> + <h1>Success for File Server Access</h1> + </body> +</html> diff --git a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java new file mode 100644 index 00000000..50791393 --- /dev/null +++ b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java @@ -0,0 +1,115 @@ +/** + * ============LICENSE_START==================================================== + * org.onap.aaf + * =========================================================================== + * Copyright (c) 2018 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.auth.fs; + +import static org.onap.aaf.auth.rserv.HttpMethods.GET; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.aaf.auth.env.AuthzEnv; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.env.AuthzTransOnlyFilter; +import org.onap.aaf.auth.rserv.CachingFileAccess; +import org.onap.aaf.auth.rserv.HttpCode; +import org.onap.aaf.auth.server.AbsService; +import org.onap.aaf.auth.server.JettyServiceStarter; +import org.onap.aaf.cadi.Access.Level; +import org.onap.aaf.cadi.CadiException; +import org.onap.aaf.cadi.LocatorException; +import org.onap.aaf.cadi.PropAccess; +import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.register.Registrant; +import org.onap.aaf.cadi.register.RemoteRegistrant; +import org.onap.aaf.misc.env.APIException; + + +public class AAF_FS extends AbsService<AuthzEnv, AuthzTrans> { + + public AAF_FS(final AuthzEnv env) throws APIException, IOException, CadiException { + super(env.access(),env); + try { + /////////////////////// + // File Server + /////////////////////// + // creates StaticSlot, needed for CachingFileAccess, and sets to public Dir + env.staticSlot(CachingFileAccess.CFA_WEB_PATH,"aaf_public_dir"); + + CachingFileAccess<AuthzTrans> cfa = new CachingFileAccess<AuthzTrans>(env); + route(env,GET,"/:key", cfa); + route(env,GET,"/:key/:cmd", cfa); + final String aaf_locate_url = access.getProperty(Config.AAF_LOCATE_URL, null); + if(aaf_locate_url == null) { + access.printf(Level.WARN, "Redirection requires property %s",Config.AAF_LOCATE_URL); + } else { + route(env,GET,"/", new Redirect(this,aaf_locate_url)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static class Redirect extends HttpCode<AuthzTrans, AAF_FS> { + private final String url; + + public Redirect(AAF_FS context,String url) { + super(context, "Redirect to HTTP/S"); + this.url = url; + } + + @Override + public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { + trans.info().printf("Redirecting %s to HTTP/S %s", req.getRemoteAddr(), req.getLocalAddr()); + resp.sendRedirect(url); + } + }; + + @Override + public Filter[] filters() throws CadiException, LocatorException { + return new Filter[] { + new AuthzTransOnlyFilter(env) + }; + } + + @SuppressWarnings("unchecked") + @Override + public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException, LocatorException { + return new Registrant[] { + new RemoteRegistrant<AuthzEnv>(aafCon(),app_name,app_version,port) + }; + } + + public static void main(final String[] args) { + PropAccess propAccess = new PropAccess(args); + try { + AAF_FS service = new AAF_FS(new AuthzEnv(propAccess)); +// env.setLog4JNames("log4j.properties","authz","fs","audit","init",null); + JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service); + jss.insecure().start(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_FileServer.java b/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_FileServer.java new file mode 100644 index 00000000..6e24f6dc --- /dev/null +++ b/auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_FileServer.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * ============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.auth.fs.test; + +import static org.junit.Assert.*; +import static org.onap.aaf.auth.rserv.HttpMethods.GET; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aaf.auth.env.AuthzEnv; +import org.onap.aaf.auth.env.AuthzTrans; +import org.onap.aaf.auth.fs.*; +import org.onap.aaf.auth.rserv.CachingFileAccess; +import org.onap.aaf.misc.env.APIException; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(MockitoJUnitRunner.class) +public class JU_FileServer { + @Mock + AuthzEnv authzEnvMock; + AuthzEnv authzEnv = new AuthzEnv(); + + @Before + public void setUp() throws APIException, IOException{ + + } + + @SuppressWarnings("static-access") + @Test + public void testMain() throws Exception{ + + String[] args = null; + Properties props = new Properties(); + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("FileServer.props").getFile()); + +//PowerMockito.whenNew(Something.class).withArguments(argument).thenReturn(mockSomething); + // env.setLog4JNames("log4j.properties","authz","fs","audit","init",null); + // PowerMockito.whenNew(AuthzEnv.class).withArguments(props).thenReturn(authzEnvMock); + // PowerMockito.doNothing().when(authzEnvMock.setLog4JNames(Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString())); + // PowerMockito.when(new AuthzEnv(props)).thenReturn(authzEnvMock); + //PowerMockito.doNothing().when(authzEnv).setLog4JNames(Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString()); + //PowerMockito.doNothing().when(authzEnvMock).setLog4JNames(" "," "," "," "," "," "); + + AAF_FS.main(args); + //assertTrue(true); + + } + +} |