summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--auth/auth-batch/pom.xml2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java2
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/BatchPrincipal.java4
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Approval.java8
-rw-r--r--auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java4
-rw-r--r--auth/auth-cass/src/main/cql/init2_1.cql6
-rw-r--r--auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java140
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java15
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java24
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java9
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java12
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java34
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_1.java (renamed from auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_0.java)7
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java4
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_1.java (renamed from auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_0.java)5
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java5
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java43
-rw-r--r--auth/auth-locate/src/main/xsd/locate_1_1.xsd46
-rw-r--r--auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java4
-rw-r--r--auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java16
-rw-r--r--cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java2
21 files changed, 347 insertions, 45 deletions
diff --git a/auth/auth-batch/pom.xml b/auth/auth-batch/pom.xml
index 8892358d..a30ccaa7 100644
--- a/auth/auth-batch/pom.xml
+++ b/auth/auth-batch/pom.xml
@@ -29,7 +29,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>auth-batch</artifactId>
+ <artifactId>aaf-auth-batch</artifactId>
<name>AAF Auth Batch</name>
<description>Batch Processing for AAF Auth</description>
<packaging>jar</packaging>
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java
index 2a55af76..7826eb68 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java
@@ -145,7 +145,7 @@ public abstract class Batch {
}
}
- protected abstract void run(AuthzTrans trans);
+ protected abstract void run(AuthzTrans trans);
protected abstract void _close(AuthzTrans trans);
public String[] args() {
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/BatchPrincipal.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/BatchPrincipal.java
index 6ca79018..5403e3a5 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/BatchPrincipal.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/BatchPrincipal.java
@@ -26,7 +26,7 @@ public class BatchPrincipal extends TaggedPrincipal {
private final String name;
public BatchPrincipal(final String name) {
- this.name = name;
+ this.name = "batch:"+name;
}
@Override
@@ -36,6 +36,6 @@ public class BatchPrincipal extends TaggedPrincipal {
@Override
public String tag() {
- return "Batch";
+ return "Btch";
}
}
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Approval.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Approval.java
index 0bd9397c..7963b022 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Approval.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/helpers/Approval.java
@@ -45,10 +45,10 @@ public class Approval implements CacheChange.Data {
public static final String RE_VALIDATE_ADMIN = "Re-Validate as Administrator for AAF Namespace '";
public static final String RE_VALIDATE_OWNER = "Re-Validate Ownership for AAF Namespace '";
- public static TreeMap<String,List<Approval>> byApprover = new TreeMap<String,List<Approval>>();
- public static TreeMap<String,List<Approval>> byUser = new TreeMap<String,List<Approval>>();
- public static TreeMap<UUID,List<Approval>> byTicket = new TreeMap<UUID,List<Approval>>();
- private final static CacheChange<Approval> cache = new CacheChange<Approval>();
+ public static TreeMap<String,List<Approval>> byApprover = new TreeMap<>();
+ public static TreeMap<String,List<Approval>> byUser = new TreeMap<>();
+ public static TreeMap<UUID,List<Approval>> byTicket = new TreeMap<>();
+ private final static CacheChange<Approval> cache = new CacheChange<>();
public final ApprovalDAO.Data add;
private String role;
diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java
index cc30890c..e3cd359f 100644
--- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java
+++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/test/JU_BatchPrincipal.java
@@ -41,8 +41,8 @@ public class JU_BatchPrincipal {
@Test
public void testBatchPrincipal() {
bPrincipal = new BatchPrincipal("name");
- bPrincipal.getName();
- Assert.assertEquals("Batch", bPrincipal.tag());
+ Assert.assertEquals("batch:name", bPrincipal.getName());
+ Assert.assertEquals("Btch", bPrincipal.tag());
}
}
diff --git a/auth/auth-cass/src/main/cql/init2_1.cql b/auth/auth-cass/src/main/cql/init2_1.cql
new file mode 100644
index 00000000..4b9e7934
--- /dev/null
+++ b/auth/auth-cass/src/main/cql/init2_1.cql
@@ -0,0 +1,6 @@
+CREATE TABLE config (
+ name varchar,
+ tag varchar,
+ value varchar,
+ PRIMARY KEY (name,tag)
+);
diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java
new file mode 100644
index 00000000..df284044
--- /dev/null
+++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/ConfigDAO.java
@@ -0,0 +1,140 @@
+/**
+ * ============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.dao.cass;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import org.onap.aaf.auth.dao.AbsCassDAO;
+import org.onap.aaf.auth.dao.CassDAOImpl;
+import org.onap.aaf.auth.dao.Loader;
+import org.onap.aaf.auth.dao.Streamer;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.misc.env.APIException;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Row;
+
+/**
+ * CredDAO manages credentials.
+ * @author Jonathan
+ * Date: 6/25/18
+ */
+public class ConfigDAO extends CassDAOImpl<AuthzTrans,ConfigDAO.Data> {
+ public static final String TABLE = "config";
+ public static final int CACHE_SEG = 0x40; // yields segment 0x0-0x3F
+ private PSInfo psName;
+
+ public ConfigDAO(AuthzTrans trans, Cluster cluster, String keyspace) throws APIException, IOException {
+ super(trans, ConfigDAO.class.getSimpleName(),cluster, keyspace, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
+ init(trans);
+ }
+
+ public ConfigDAO(AuthzTrans trans, AbsCassDAO<AuthzTrans,?> aDao) throws APIException, IOException {
+ super(trans, ConfigDAO.class.getSimpleName(),aDao, Data.class,TABLE, readConsistency(trans,TABLE), writeConsistency(trans,TABLE));
+ init(trans);
+ }
+
+ public static final int KEYLIMIT = 2;
+ public static class Data {
+ public String name;
+ public String tag;
+ public String value;
+ }
+
+ private static class ConfigLoader extends Loader<Data> implements Streamer<Data>{
+ public static final int MAGIC=2673849;
+ public static final int VERSION=1;
+ public static final int BUFF_SIZE=48;
+
+ public static final ConfigLoader deflt = new ConfigLoader(KEYLIMIT);
+ public ConfigLoader(int keylimit) {
+ super(keylimit);
+ }
+
+ @Override
+ public Data load(Data data, Row row) {
+ data.name = row.getString(0);
+ data.tag = row.getString(1);
+ data.value = row.getString(2);
+ return data;
+ }
+
+ @Override
+ protected void key(Data data, int idx, Object[] obj) {
+ obj[idx] = data.name;
+ obj[++idx] = data.tag;
+ }
+
+ @Override
+ protected void body(Data data, int _idx, Object[] obj) {
+ obj[_idx] = data.value;
+ }
+
+ @Override
+ public void marshal(Data data, DataOutputStream os) throws IOException {
+ writeHeader(os,MAGIC,VERSION);
+ writeString(os, data.name);
+ writeString(os, data.tag);
+ writeString(os, data.value);
+ }
+
+ @Override
+ public void unmarshal(Data data, DataInputStream is) throws IOException {
+ /*int version = */readHeader(is,MAGIC,VERSION);
+ // If Version Changes between Production runs, you'll need to do a switch Statement, and adequately read in fields
+ byte[] buff = new byte[BUFF_SIZE];
+ data.name = readString(is,buff);
+ data.tag = readString(is,buff);
+ data.value = readString(is,buff);
+ }
+ }
+
+ private void init(AuthzTrans trans) throws APIException, IOException {
+ String[] helpers = setCRUD(trans, TABLE, Data.class, ConfigLoader.deflt);
+
+ psName = new PSInfo(trans, SELECT_SP + helpers[FIELD_COMMAS] + " FROM " + TABLE +
+ " WHERE name = ?", ConfigLoader.deflt,readConsistency);
+ }
+
+
+ /**
+ * Log Modification statements to History
+ *
+ * @param modified which CRUD action was done
+ * @param data entity data that needs a log entry
+ * @param overrideMessage if this is specified, we use it rather than crafting a history message based on data
+ */
+ @Override
+ protected void wasModified(AuthzTrans trans, CRUD modified, Data data, String ... override) {
+ // not an auditable table.
+ }
+
+ public Result<List<Data>> readName(AuthzTrans trans, String name) {
+ return psName.read(trans, R_TEXT, new Object[]{name});
+ }
+
+
+}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
index efda67f7..9986c60a 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
@@ -30,6 +30,7 @@ import javax.servlet.Filter;
import org.onap.aaf.auth.cache.Cache;
import org.onap.aaf.auth.cache.Cache.Dated;
import org.onap.aaf.auth.dao.CassAccess;
+import org.onap.aaf.auth.dao.cass.ConfigDAO;
import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.direct.DirectLocatorCreator;
import org.onap.aaf.auth.direct.DirectRegistrar;
@@ -41,7 +42,7 @@ import org.onap.aaf.auth.locate.api.API_Api;
import org.onap.aaf.auth.locate.api.API_Find;
import org.onap.aaf.auth.locate.api.API_Proxy;
import org.onap.aaf.auth.locate.facade.LocateFacadeFactory;
-import org.onap.aaf.auth.locate.facade.LocateFacade_1_0;
+import org.onap.aaf.auth.locate.facade.LocateFacade_1_1;
import org.onap.aaf.auth.locate.mapper.Mapper.API;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
@@ -68,8 +69,8 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
private static final String DOT_LOCATOR = ".locator";
private static final String USER_PERMS = "userPerms";
- private LocateFacade_1_0 facade; // this is the default Facade
- private LocateFacade_1_0 facade_1_0_XML;
+ private LocateFacade_1_1 facade; // this is the default Facade
+ private LocateFacade_1_1 facade_1_1_XML;
public Map<String, Dated> cacheUser;
public final AAFAuthn<?> aafAuthn;
public final AAFLurPerm aafLurPerm;
@@ -77,6 +78,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
public final long expireIn;
private final Cluster cluster;
public final LocateDAO locateDAO;
+ public final ConfigDAO configDAO;
private Locator<URI> dal;
private final String aaf_service_name;
private final String aaf_gui_name;
@@ -103,6 +105,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
cluster = org.onap.aaf.auth.dao.CassAccess.cluster(env,null);
locateDAO = new LocateDAO(trans,cluster,CassAccess.KEYSPACE);
+ configDAO = new ConfigDAO(trans,locateDAO); // same stuff
// Have AAFLocator object Create DirectLocators for Location needs
AbsAAFLocator.setCreator(new DirectLocatorCreator(env, locateDAO));
@@ -112,8 +115,8 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
aafAuthn = aafCon().newAuthn(aafLurPerm);
- facade = LocateFacadeFactory.v1_0(env,locateDAO,trans,Data.TYPE.JSON); // Default Facade
- facade_1_0_XML = LocateFacadeFactory.v1_0(env,locateDAO,trans,Data.TYPE.XML);
+ facade = LocateFacadeFactory.v1_1(env,this,trans,Data.TYPE.JSON); // Default Facade
+ facade_1_1_XML = LocateFacadeFactory.v1_1(env,this,trans,Data.TYPE.XML);
synchronized(env) {
if(cacheUser == null) {
@@ -166,7 +169,7 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
// setup Application API HTML ContentTypes for XML and Route
application = applicationXML(respCls, version);
- route(env,meth,path,code.clone(facade_1_0_XML,false),application,"text/xml;version="+version);
+ route(env,meth,path,code.clone(facade_1_1_XML,false),application,"text/xml;version="+version);
// Add other Supported APIs here as created
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java
index 9de92d14..af7611a3 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/api/API_AAFAccess.java
@@ -21,6 +21,8 @@
package org.onap.aaf.auth.locate.api;
+import static org.onap.aaf.auth.layer.Result.OK;
+
import java.io.IOException;
import java.net.ConnectException;
import java.net.URI;
@@ -222,6 +224,28 @@ public class API_AAFAccess {
}
}
});
+
+ /**
+ * Configuration
+ */
+ gwAPI.route(HttpMethods.GET,"/configure/:id/:type",API.CONFIG,new LocateCode(facade,"Deliver Configuration Properties to AAF", true) {
+ @Override
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ try {
+ Result<Void> r = facade.getConfig(trans, req, resp, pathParam(req, ":id"),pathParam(req,":type"));
+ switch(r.status) {
+ case OK:
+ resp.setStatus(HttpStatus.OK_200);
+ break;
+ default:
+ context.error(trans,resp,r);
+ }
+
+ } catch (Exception e) {
+ context.error(trans, resp, Result.ERR_General, e.getMessage());
+ }
+ }
+ });
}
private static void redirect(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, LocateFacade context, Locator<URI> loc, String path) throws IOException {
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java
index 817fcc58..8fb719fe 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade.java
@@ -103,4 +103,13 @@ public interface LocateFacade {
*/
public abstract Result<Void> removeMgmtEndpoints(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp);
+ /**
+ *
+ * @param trans
+ * @param req
+ * @param resp
+ * @return
+ */
+ public Result<Void> getConfig(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, String id, String type);
+
} \ No newline at end of file
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java
index ea20df5a..cff70f03 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeFactory.java
@@ -1,5 +1,5 @@
/**
- * ============LICENSE_START====================================================
+\\ * ============LICENSE_START====================================================
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
@@ -21,10 +21,10 @@
package org.onap.aaf.auth.locate.facade;
-import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.env.AuthzEnv;
import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.locate.mapper.Mapper_1_0;
+import org.onap.aaf.auth.locate.AAF_Locate;
+import org.onap.aaf.auth.locate.mapper.Mapper_1_1;
import org.onap.aaf.auth.locate.service.LocateServiceImpl;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data;
@@ -35,13 +35,13 @@ import locate_local.v1_0.Out;
public class LocateFacadeFactory {
- public static LocateFacade_1_0 v1_0(AuthzEnv env, LocateDAO locateDAO, AuthzTrans trans, Data.TYPE type) throws APIException {
- return new LocateFacade_1_0(
+ public static LocateFacade_1_1 v1_1(AuthzEnv env, AAF_Locate locate, AuthzTrans trans, Data.TYPE type) throws APIException {
+ return new LocateFacade_1_1(
env,
new LocateServiceImpl<
InRequest,
Out,
- Error>(trans,locateDAO,new Mapper_1_0()),
+ Error>(trans,locate,new Mapper_1_1()),
type);
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java
index fdb02c70..af6ad1c1 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacadeImpl.java
@@ -54,9 +54,9 @@ import org.onap.aaf.auth.rserv.doc.ApiDoc;
import org.onap.aaf.cadi.aaf.client.Examples;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data;
+import org.onap.aaf.misc.env.Data.TYPE;
import org.onap.aaf.misc.env.Env;
import org.onap.aaf.misc.env.TimeTaken;
-import org.onap.aaf.misc.env.Data.TYPE;
import org.onap.aaf.misc.rosetta.env.RosettaDF;
import org.onap.aaf.misc.rosetta.env.RosettaData;
@@ -82,28 +82,30 @@ import locate_local.v1_0.Api;
* @author Jonathan
*
*/
-public abstract class LocateFacadeImpl<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> extends FacadeImpl implements LocateFacade
+public abstract class LocateFacadeImpl<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> extends FacadeImpl implements LocateFacade
{
- private LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> service;
+ private LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> service;
private final RosettaDF<ERROR> errDF;
private final RosettaDF<Api> apiDF;
private final RosettaDF<ENDPOINTS> epDF;
private final RosettaDF<MGMT_ENDPOINTS> mepDF;
+ private final RosettaDF<CONFIGURATION> confDF;
private static long cacheClear = 0L, emptyCheck=0L;
private final static Map<String,String> epsCache = new HashMap<String, String>(); // protected manually, in getEndpoints
- public LocateFacadeImpl(AuthzEnv env, LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> service, Data.TYPE dataType) throws APIException {
+ public LocateFacadeImpl(AuthzEnv env, LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> service, Data.TYPE dataType) throws APIException {
this.service = service;
(errDF = env.newDataFactory(mapper().getClass(API.ERROR))).in(dataType).out(dataType);
(apiDF = env.newDataFactory(Api.class)).in(dataType).out(dataType);
(epDF = env.newDataFactory(mapper().getClass(API.ENDPOINTS))).in(dataType).out(dataType);
(mepDF = env.newDataFactory(mapper().getClass(API.MGMT_ENDPOINTS))).in(dataType).out(dataType);
+ (confDF = env.newDataFactory(mapper().getClass(API.CONFIG))).in(dataType).out(dataType);
}
- public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> mapper() {
+ public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIGURATION,ERROR> mapper() {
return service.mapper();
}
@@ -391,4 +393,26 @@ public abstract class LocateFacadeImpl<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> ex
}
}
+ private static final String GET_CONFIG = "Get Configuration";
+ @Override
+ public Result<Void> getConfig(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp, final String id, final String type) {
+ TimeTaken tt = trans.start(GET_CONFIG, Env.SUB|Env.ALWAYS);
+ try {
+ Result<CONFIGURATION> rp = service.getConfig(trans, id, type);
+ switch(rp.status) {
+ case OK:
+ setContentType(resp,mepDF.getOutType());
+ confDF.newData(trans).load(rp.value).to(resp.getOutputStream());
+ return Result.ok();
+ default:
+ return Result.err(rp);
+ }
+ } catch (Exception e) {
+ trans.error().log(e,IN,GET_CONFIG);
+ return Result.err(e);
+ } finally {
+ tt.done();
+ }
+ }
+
} \ No newline at end of file
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_0.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_1.java
index e2d2c9f6..d044b731 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_0.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/facade/LocateFacade_1_1.java
@@ -28,13 +28,14 @@ import org.onap.aaf.misc.env.Data;
import locate.v1_0.Endpoints;
import locate.v1_0.MgmtEndpoints;
+import locate_local.v1_0.Error;
import locate_local.v1_0.InRequest;
import locate_local.v1_0.Out;
-import locate_local.v1_0.Error;
+import locate_local.v1_1.Configuration;
-public class LocateFacade_1_0 extends LocateFacadeImpl<InRequest,Out,Endpoints,MgmtEndpoints,Error>
+public class LocateFacade_1_1 extends LocateFacadeImpl<InRequest,Out,Endpoints,MgmtEndpoints,Configuration,Error>
{
- public LocateFacade_1_0(AuthzEnv env, LocateService<InRequest,Out,Endpoints,MgmtEndpoints,Error> service, Data.TYPE type) throws APIException {
+ public LocateFacade_1_1(AuthzEnv env, LocateService<InRequest,Out,Endpoints,MgmtEndpoints,Configuration,Error> service, Data.TYPE type) throws APIException {
super(env, service, type);
}
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java
index 685d096f..7e012f2d 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper.java
@@ -28,9 +28,9 @@ import org.onap.aaf.auth.layer.Result;
import locate.v1_0.MgmtEndpoint;
-public interface Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR>
+public interface Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR>
{
- public enum API{IN_REQ,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR,VOID};
+ public enum API{IN_REQ,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR,VOID};
public Class<?> getClass(API api);
public<A> A newInstance(API api);
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_0.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_1.java
index 50839b73..61178951 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_0.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/mapper/Mapper_1_1.java
@@ -35,8 +35,9 @@ import locate.v1_0.MgmtEndpoints;
import locate_local.v1_0.Error;
import locate_local.v1_0.InRequest;
import locate_local.v1_0.Out;
+import locate_local.v1_1.Configuration;
-public class Mapper_1_0 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,Error> {
+public class Mapper_1_1 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,Configuration,Error> {
@Override
public Class<?> getClass(API api) {
@@ -47,6 +48,7 @@ public class Mapper_1_0 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,
case VOID: return Void.class;
case ENDPOINTS: return Endpoints.class;
case MGMT_ENDPOINTS: return MgmtEndpoints.class;
+ case CONFIG: return Configuration.class;
}
return null;
}
@@ -60,6 +62,7 @@ public class Mapper_1_0 implements Mapper<InRequest,Out,Endpoints,MgmtEndpoints,
case ERROR: return (A)new Error();
case ENDPOINTS: return (A) new Endpoints();
case MGMT_ENDPOINTS: return (A) new MgmtEndpoints();
+ case CONFIG: return (A) new Configuration();
case VOID: return null;
}
return null;
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java
index d2a37348..ac2e3c46 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateService.java
@@ -25,9 +25,10 @@ import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
import org.onap.aaf.auth.locate.mapper.Mapper;
-public interface LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> {
- public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,ERROR> mapper();
+public interface LocateService<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR> {
+ public Mapper<IN,OUT,ENDPOINTS,MGMT_ENDPOINTS,CONFIG,ERROR> mapper();
public Result<ENDPOINTS> getEndPoints(AuthzTrans trans, String service, String version, String other);
public Result<Void> putMgmtEndPoints(AuthzTrans trans, MGMT_ENDPOINTS meps);
public Result<Void> removeMgmtEndPoints(AuthzTrans trans, MGMT_ENDPOINTS meps);
+ public Result<CONFIG> getConfig(AuthzTrans trans, String id, String type);
}
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
index d1a03cdc..9789ad0e 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/service/LocateServiceImpl.java
@@ -21,11 +21,15 @@
package org.onap.aaf.auth.locate.service;
+import java.util.List;
import java.util.UUID;
+import org.onap.aaf.auth.dao.cass.ConfigDAO;
+import org.onap.aaf.auth.dao.cass.ConfigDAO.Data;
import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.auth.locate.AAF_Locate;
import org.onap.aaf.auth.locate.mapper.Mapper;
import org.onap.aaf.auth.locate.validation.LocateValidator;
import org.onap.aaf.cadi.aaf.AAFPermission;
@@ -34,20 +38,24 @@ import org.onap.aaf.misc.env.APIException;
import locate.v1_0.Endpoints;
import locate.v1_0.MgmtEndpoint;
import locate.v1_0.MgmtEndpoints;
+import locate_local.v1_1.Configuration;
+import locate_local.v1_1.Configuration.Props;
public class LocateServiceImpl<IN,OUT,ERROR>
- implements LocateService<IN,OUT,Endpoints,MgmtEndpoints,ERROR> {
- private Mapper<IN,OUT,Endpoints,MgmtEndpoints,ERROR> mapper;
- private LocateDAO locateDAO;
+ implements LocateService<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> {
+ private Mapper<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> mapper;
+ protected LocateDAO locateDAO;
+ private ConfigDAO configDAO;
private boolean permToRegister;
- public LocateServiceImpl(AuthzTrans trans, LocateDAO locateDAO, Mapper<IN,OUT,Endpoints,MgmtEndpoints,ERROR> mapper) throws APIException {
+ public LocateServiceImpl(AuthzTrans trans, AAF_Locate locate, Mapper<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> mapper) throws APIException {
this.mapper = mapper;
- this.locateDAO = locateDAO;
+ this.locateDAO = locate.locateDAO;
+ this.configDAO = locate.configDAO;
permToRegister = false; //TODO Setup a Configuration for this
}
- public Mapper<IN,OUT,Endpoints,MgmtEndpoints,ERROR> mapper() {return mapper;}
+ public Mapper<IN,OUT,Endpoints,MgmtEndpoints,Configuration,ERROR> mapper() {return mapper;}
@Override
public Result<Endpoints> getEndPoints(AuthzTrans trans, String service, String version, String other) {
@@ -117,6 +125,29 @@ public class LocateServiceImpl<IN,OUT,ERROR>
}
}
+ ///// ADDED v1_1
+ /* (non-Javadoc)
+ * @see org.onap.aaf.auth.locate.service.LocateService#getConfig(org.onap.aaf.auth.env.AuthzTrans, java.lang.String, java.lang.String)
+ */
+ @Override
+ public Result<Configuration> getConfig(AuthzTrans trans, String id, String type) {
+ Result<List<Data>> dr = configDAO.readName(trans, type);
+ Configuration c = new Configuration();
+ c.setName(type);
+ Props p;
+
+ if(dr.isOKhasData()) {
+ for(ConfigDAO.Data data : dr.value) {
+ p = new Props();
+ p.setTag(data.tag);
+ p.setValue(data.value);
+ c.getProps().add(p);
+ }
+ }
+ return Result.ok(c);
+ //return Result.err(Result.ERR_NotImplemented,"not done yet");
+ }
+
//////////////// APIs ///////////////////
};
diff --git a/auth/auth-locate/src/main/xsd/locate_1_1.xsd b/auth/auth-locate/src/main/xsd/locate_1_1.xsd
new file mode 100644
index 00000000..59409d45
--- /dev/null
+++ b/auth/auth-locate/src/main/xsd/locate_1_1.xsd
@@ -0,0 +1,46 @@
+<!--
+ * ============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====================================================
+ *
+-->
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:locate_local="urn:locate_local:v1_1"
+ targetNamespace="urn:locate_local:v1_1"
+ elementFormDefault="qualified">
+
+
+<!--
+ Configurations
+ -->
+ <xs:element name="Configuration">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="props" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="tag" type="xs:string"/>
+ <xs:element name="value" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</xs:schema> \ No newline at end of file
diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java
index 93b39b2d..26bea940 100644
--- a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java
+++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java
@@ -42,7 +42,7 @@ public class JU_Mapper_1_0Test {
@Test
public void testGetClasses() {
- Mapper_1_0 mapper = new Mapper_1_0();
+ Mapper_1_1 mapper = new Mapper_1_1();
assertEquals(InRequest.class, mapper.getClass(API.IN_REQ));
assertEquals(Out.class, mapper.getClass(API.OUT));
assertEquals(Error.class, mapper.getClass(API.ERROR));
@@ -53,7 +53,7 @@ public class JU_Mapper_1_0Test {
@Test
public void testNewInstance() {
- Mapper_1_0 mapper = new Mapper_1_0();
+ Mapper_1_1 mapper = new Mapper_1_1();
assertTrue(mapper.newInstance(API.IN_REQ) instanceof InRequest);
assertTrue(mapper.newInstance(API.OUT) instanceof Out);
assertTrue(mapper.newInstance(API.ERROR) instanceof Error);
diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java
index d9200d76..c79e9cbd 100644
--- a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java
+++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/service/JU_LocateServiceImplTest.java
@@ -35,6 +35,7 @@ import org.onap.aaf.auth.dao.cass.LocateDAO;
import org.onap.aaf.auth.dao.cass.LocateDAO.Data;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.layer.Result;
+import org.onap.aaf.auth.locate.AAF_Locate;
import org.onap.aaf.auth.locate.mapper.Mapper;
import org.onap.aaf.misc.env.APIException;
@@ -43,9 +44,21 @@ import locate.v1_0.MgmtEndpoints;
public class JU_LocateServiceImplTest {
+ // Extend, because I don't want a "setter" in the original. Compromised with a protected...
+ private final class LocateServiceImplExtension extends LocateServiceImpl {
+ private LocateServiceImplExtension(AuthzTrans trans, AAF_Locate locate, Mapper mapper) throws APIException {
+ super(trans, locate, mapper);
+ }
+ public void set(LocateDAO ld) {
+ locateDAO=ld;
+ }
+ }
+
@Mock
private AuthzTrans trans;
@Mock
+ private AAF_Locate aaf_locate;
+ @Mock
private LocateDAO locateDAO;
@Mock
private Mapper mapper;
@@ -65,7 +78,8 @@ public class JU_LocateServiceImplTest {
@Test
public void test() throws APIException {
- LocateServiceImpl locateServiceImpl = new LocateServiceImpl(trans, locateDAO, mapper);
+ LocateServiceImplExtension locateServiceImpl = new LocateServiceImplExtension(trans, aaf_locate, mapper);
+ locateServiceImpl.set(locateDAO);
assertEquals(mapper, locateServiceImpl.mapper());
diff --git a/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java b/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
index f61d1caf..722ac14f 100644
--- a/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
+++ b/cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java
@@ -47,7 +47,6 @@ import org.onap.aaf.cadi.lur.LocalPermission;
public class JU_LocalLur {
- private static final String password = "<pass>";
private PropAccess access;
private ByteArrayOutputStream outStream;
@@ -71,6 +70,7 @@ public class JU_LocalLur {
@Test
public void test() throws IOException {
+ final String password = "<pass>";
final String encrypted = rot13(password);
LocalLur lur;