summaryrefslogtreecommitdiffstats
path: root/auth/auth-fs/src
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-fs/src')
-rw-r--r--auth/auth-fs/src/main/config/.gitignore1
-rw-r--r--auth/auth-fs/src/main/config/FileServer.props23
-rw-r--r--auth/auth-fs/src/main/data/favicon.icobin0 -> 3638 bytes
-rw-r--r--auth/auth-fs/src/main/data/test.html20
-rw-r--r--auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java115
-rw-r--r--auth/auth-fs/src/test/java/org/onap/aaf/auth/fs/test/JU_FileServer.java81
6 files changed, 240 insertions, 0 deletions
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
new file mode 100644
index 00000000..3aea2722
--- /dev/null
+++ b/auth/auth-fs/src/main/data/favicon.ico
Binary files differ
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&amp;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&amp;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);
+
+ }
+
+}