aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/main/java/org/onap/aaf/cadi/dme2
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/main/java/org/onap/aaf/cadi/dme2')
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java223
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java64
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DME2ClientSS.java65
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DME2Locator.java349
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DME2TransferSS.java56
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DME2x509SS.java68
-rw-r--r--client/src/main/java/org/onap/aaf/cadi/dme2/DRcli.java142
7 files changed, 0 insertions, 967 deletions
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java
deleted file mode 100644
index 7bbdc25..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java
+++ /dev/null
@@ -1,223 +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.dme2;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URI;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.client.EClient;
-import org.onap.aaf.cadi.client.Future;
-import org.onap.aaf.cadi.client.Rcli;
-
-import com.att.aft.dme2.api.DME2Client;
-import com.att.aft.dme2.api.DME2Exception;
-import com.att.aft.dme2.api.DME2Manager;
-import com.att.aft.dme2.handler.DME2RestfulHandler;
-import com.att.aft.dme2.handler.DME2RestfulHandler.ResponseInfo;
-import org.onap.aaf.inno.env.APIException;
-import org.onap.aaf.inno.env.Data;
-import org.onap.aaf.rosetta.env.RosettaDF;
-
-public class DEClient implements EClient<DME2Client> {
- private DME2Client client;
- private DME2RestfulHandler replyHandler;
- private EClient.Transfer payload;
- private boolean isProxy;
- private SecuritySetter<DME2Client> ss;
-
- public DEClient(DME2Manager manager, SecuritySetter<DME2Client> ss, URI uri, long timeout) throws DME2Exception, CadiException {
- client = new DME2Client(manager,uri,timeout);
- client.setAllowAllHttpReturnCodes(true);
- this.ss = ss;
- ss.setSecurity(client);
- replyHandler = new DME2RestfulHandler(Rcli.BLANK);
- client.setReplyHandler(replyHandler);
- }
-
- @Override
- public void setMethod(String meth) {
- client.setMethod(meth);
- }
-
- /**
- * DME2 can't handle having QueryParams on the URL line, but it is the most natural way, so...
- *
- * Also, DME2 can't handle "/proxy" as part of Context in the main URI line, so we add it when we see authz-gw to "isProxy"
- */
- public void setPathInfo(String pathinfo) {
- int qp = pathinfo.indexOf('?');
- if(qp<0) {
- client.setContext(isProxy?("/proxy"+pathinfo):pathinfo);
- } else {
- client.setContext(isProxy?("/proxy"+pathinfo.substring(0,qp)):pathinfo.substring(0,qp));
- client.setQueryParams(pathinfo.substring(qp+1));
- }
- }
-
- @Override
- public void setPayload(EClient.Transfer transfer) {
- payload = transfer;
- }
-
- @Override
- public void addHeader(String tag, String value) {
- client.addHeader(tag, value);
- }
-
-
- @Override
- public void setQueryParams(String q) {
- client.setQueryParams(q);
- }
-
- @Override
- public void setFragment(String f) {
- // DME2 does not implement this
- }
-
- @Override
- public void send() throws APIException {
- try {
- if(payload!=null) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- payload.transfer(baos);
- client.setPayload(new String(baos.toByteArray()));
- } else {
- client.setPayload("");
- }
- client.send();
- } catch (DME2Exception e) {
- throw new APIException(e);
- } catch (IOException e) {
- throw new APIException(e);
- }
- }
-
-
- public class DFuture<T> extends Future<T> {
- protected final DME2RestfulHandler reply;
- protected ResponseInfo info;
-
- public DFuture(DME2RestfulHandler reply) {
- this.reply = reply;
- }
-
- protected boolean evalInfo() throws APIException{
- //return info.getCode()==200;
- return true;
- };
-
- public final boolean get(int timeout) throws CadiException {
- try {
- info = reply.getResponse(timeout);
- ss.setLastResponse(info.getCode());
- return evalInfo();
- } catch (Exception e) {
- throw new CadiException(e);
- }
- }
-
- @Override
- public int code() {
- return info.getCode();
- }
-
- @Override
- public String body() {
- return info.getBody();
- }
-
- @Override
- public String header(String tag) {
- return info.header(tag);
- }
-
- }
-
- @Override
- public <T> Future<T> futureCreate(Class<T> t) {
- return new DFuture<T>(replyHandler) {
- public boolean evalInfo() throws APIException {
-
- return info.getCode()==201;
- }
- };
- }
-
-
- @Override
- public Future<String> futureReadString() {
- return new DFuture<String>(replyHandler) {
- public boolean evalInfo() throws APIException {
- if(info.getCode()==200) {
- value = info.getBody();
- return true;
- }
- return false;
- }
- };
- }
-
- @Override
- public<T> Future<T> futureRead(final RosettaDF<T> df, final Data.TYPE type) {
- return new DFuture<T>(replyHandler) {
- public boolean evalInfo() throws APIException {
- if(info.getCode()==200) {
- value = df.newData().in(type).load(info.getBody()).asObject();
- return true;
- }
- return false;
- }
- };
- }
-
- @Override
- public <T> Future<T> future(final T t) {
- return new DFuture<T>(replyHandler) {
- public boolean evalInfo() {
- if(info.getCode()==200) {
- value = t;
- return true;
- }
- return false;
- }
- };
- }
-
- @Override
- public Future<Void> future(HttpServletResponse resp,int expected) throws APIException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setProxy(boolean isProxy) {
- this.isProxy=isProxy;
- }
-
-
-}
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java
deleted file mode 100644
index b29074f..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java
+++ /dev/null
@@ -1,64 +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.dme2;
-
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-
-import org.onap.aaf.cadi.Access;
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.client.AbsBasicAuth;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.cadi.config.SecurityInfoC;
-import org.onap.aaf.cadi.principal.BasicPrincipal;
-
-import com.att.aft.dme2.api.DME2Client;
-
-public class DME2BasicAuth extends AbsBasicAuth<DME2Client> {
- public DME2BasicAuth(String user, String pass, SecurityInfoC<DME2Client> si) throws IOException {
- super(user,pass,si);
- }
-
- public DME2BasicAuth(Access access, SecurityInfoC<DME2Client> si) throws IOException {
- super(access.getProperty(Config.AAF_MECHID, null),
- access.decrypt(access.getProperty(Config.AAF_MECHPASS, null), false),
- si);
- }
-
- public DME2BasicAuth(BasicPrincipal bp,SecurityInfoC<DME2Client> si) throws IOException {
- super(bp.getName(),new String(bp.getCred()),si);
- }
-
- public DME2BasicAuth(Access access) throws IOException, GeneralSecurityException {
- super(access.getProperty(Config.AAF_MECHID, null),
- access.decrypt(access.getProperty(Config.AAF_MECHPASS, null), false),
- new SecurityInfoC<DME2Client>(access));
- }
-
- public void setSecurity(DME2Client client) throws CadiException {
- if(isDenied()) {
- throw new CadiException(REPEAT_OFFENDER);
- }
- client.addHeader("Authorization", headValue);
- }
-}
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2ClientSS.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2ClientSS.java
deleted file mode 100644
index 167fe3b..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2ClientSS.java
+++ /dev/null
@@ -1,65 +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.dme2;
-
-import java.io.IOException;
-
-import org.onap.aaf.cadi.Access;
-import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.Access.Level;
-
-import com.att.aft.dme2.api.DME2Client;
-
-public class DME2ClientSS implements SecuritySetter<DME2Client> {
- private Access access;
- private String user,crd;
-
- public DME2ClientSS(Access access, String user, String pass) throws IOException {
- this.access = access;
- this.user = user;
- this.crd = pass;
- }
-
- @Override
- public void setSecurity(DME2Client client) {
- try {
- client.setCredentials(user, access.decrypt(crd, false));
- } catch (IOException e) {
- access.log(Level.ERROR,e,"Error decrypting DME2 Password");
- }
- }
-
- /* (non-Javadoc)
- * @see com.att.cadi.SecuritySetter#getID()
- */
- @Override
- public String getID() {
- return user;
- }
-
- @Override
- public int setLastResponse(int respCode) {
- // TODO Auto-generated method stub
- return 0;
- }
-}
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2Locator.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2Locator.java
deleted file mode 100644
index 47af9ea..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2Locator.java
+++ /dev/null
@@ -1,349 +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.dme2;
-
-
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Random;
-
-import org.onap.aaf.cadi.Access;
-import org.onap.aaf.cadi.Locator;
-import org.onap.aaf.cadi.LocatorException;
-import org.onap.aaf.cadi.Access.Level;
-
-//
-import com.att.aft.dme2.api.DME2Exception;
-import com.att.aft.dme2.api.DME2Manager;
-import com.att.aft.dme2.api.DME2Server;
-import com.att.aft.dme2.manager.registry.DME2Endpoint;
-
-public class DME2Locator implements Locator {
- private DME2Manager dm;
- private DME2Endpoint[] endpoints;
- private Access access;
- private String service;
- private String version;
- private String routeOffer;
- private String envContext;
- private String thisMachine;
- private String pathInfo;
- private int thisPort;
- private boolean removeSelf;
- private final static Random random = new Random();
-
- // Default is to not bother trying to remove self
- public DME2Locator(Access access, DME2Manager dm, String service, String version, String envContext, String routeOffer) throws DME2Exception, UnknownHostException, LocatorException {
- this(access,dm,service,version,envContext,routeOffer,false);
- }
-
- public DME2Locator(Access access, DME2Manager dm, String service, String version, String envContext, String routeOffer, boolean removeSelf) throws DME2Exception, UnknownHostException, LocatorException {
- this.access = access;
- if(dm==null) {
- this.dm = new DME2Manager("DME2Locator created DME2Manager",System.getProperties());
- } else {
- this.dm = dm;
- }
- this.service = service;
- this.version = version;
- this.envContext = envContext;
- this.routeOffer = routeOffer;
- refresh();
- DME2Server server = dm.getServer();
- if(server == null) {
- thisMachine = InetAddress.getLocalHost().getHostName();
- thisPort = 0;
- } else {
- try {
- thisMachine = server.getServerProperties().getHostname();
- //thisPort = server.getPort();
- thisPort = server.getServerProperties().getPort();
- } catch(NullPointerException np) { // BAD BOY, DME2...
- access.log(Level.ERROR, "WARNING: DME2 threw a NullPointer Exception getting Server Machine and Port");
- thisMachine = InetAddress.getLocalHost().getHostName();
- thisPort = 0;
- }
- }
- this.removeSelf = removeSelf;
- }
-
- // Default is to not bother trying to remove self
- public DME2Locator(Access access, DME2Manager dm, String aafurl) throws DME2Exception, UnknownHostException, LocatorException {
- this(access,dm,aafurl,false);
- }
-
- public DME2Locator(Access access, DME2Manager dm, String aafurl, boolean removeSelf) throws DME2Exception, UnknownHostException, LocatorException {
- if(aafurl==null) throw new LocatorException("URL is null");
- this.access = access;
- if(dm==null) {
- dm = this.dm = new DME2Manager("DME2Locator created DME2Manager",System.getProperties());
- } else {
- this.dm = dm;
- }
- String[] split = aafurl.split("/");
- StringBuilder sb = new StringBuilder();
- boolean dme2Entered = false;
- for(String s : split) {
- if(s.startsWith( "service=")) this.service = s.substring(8);
- else if(s.startsWith("version=")) this.version = s.substring(8);
- else if(s.startsWith("envContext=")) this.envContext = s.substring(11);
- else if(s.startsWith("routeOffer=")) {
- this.routeOffer = s.substring(11);
- dme2Entered = true;
- }
- else if(dme2Entered) {
- sb.append('/');
- sb.append(s);
- }
- pathInfo = sb.toString();
- }
- DME2Server server = dm.getServer();
- if(server == null) {
- thisMachine = InetAddress.getLocalHost().getHostName();
- thisPort = 0;
- } else {
- thisMachine = server.getServerProperties().getHostname();
- if(thisMachine==null) { // even if server !=null, apparently, it can be uninitialized
- thisMachine = InetAddress.getLocalHost().getHostName();
- thisPort = 0;
- } else {
- try {
- thisPort = server.getServerProperties().getPort();
- } catch (Exception e) {
- thisPort = 0;
- }
- }
- }
- this.removeSelf=removeSelf;
- refresh();
- }
-
- @Override
- public boolean refresh() {
- try {
- dm.refresh();
- endpoints = dm.findEndpoints(service, version, envContext, routeOffer, true);
- if(removeSelf) {
- for(int i=0;i<endpoints.length;++i) {
- if(endpoints[i].getPort()==thisPort && endpoints[i].getHost().equals(thisMachine))
- endpoints[i]=null;
- }
- }
- return endpoints.length!=0;
- } catch (Exception e) {
- access.log(Level.ERROR, e.getMessage());
- }
- return false;
- }
-
- private String noEndpointsString() {
- StringBuilder sb = new StringBuilder("No DME2 Endpoints found for ");
- sb.append(service);
- sb.append('/');
- sb.append(version);
- sb.append('/');
- sb.append(envContext);
- sb.append('/');
- sb.append(routeOffer);
- return sb.toString();
- }
-
- @Override
- public URI get(Locator.Item item) throws LocatorException {
- if(!hasItems())
- throw new LocatorException(noEndpointsString());
- if(item == null)
- return null;
-
- Item li = ((Item)item);
- // if URI has been created, use it
- if(li.uri!=null)return li.uri;
-
- // URI not created, create it
- if(li.idx<endpoints.length) {
- DME2Endpoint de = endpoints[li.idx];
- if(de!=null) {
- try {
- return li.uri=new URI(de.getProtocol(),null,de.getHost(),de.getPort(),pathInfo,null,null);
- } catch (URISyntaxException e) {
- throw new LocatorException(e);
- }
- }
- }
- return null;
- }
-
- @Override
- public boolean hasItems() {
- return endpoints!=null && endpoints.length>0;
- }
-
- @Override
- public void invalidate(Locator.Item item) throws LocatorException {
- if(item instanceof Item) {
- int idx = ((Item)item).idx;
- if(idx<endpoints.length) {
- DME2Endpoint uhoh = endpoints[idx]; // Sometimes, DME2Endpoint, at least on File system, returns bogus entries.
- endpoints[idx]=null;
- boolean noneLeft=true;
- for(int i=0;i<endpoints.length && noneLeft;++i) {
- noneLeft = endpoints[i]==null;
- }
- if(noneLeft && refresh()) { // make sure DME2 isn't giving us the same invalidated entry...
- for(int i=0;i<endpoints.length && noneLeft;++i) {
- DME2Endpoint ep = endpoints[i];
- if(ep != null &&
- ep.getHost().equals(uhoh.getHost()) &&
- ep.getPort()==uhoh.getPort()) {
- endpoints[i]=null;
- }
- }
- }
-
- }
- }
- }
-
- public class Item implements Locator.Item {
- private final int idx;
- private URI uri;
- private Item(int i) {
- idx = i;
- uri = null;
- }
- }
-
- @Override
- public Item best() throws LocatorException {
- if(!hasItems()) // checks endpoints
- if(!refresh()) throw new LocatorException("No DME2 Endpoints Available");
-
- // Some endpoints in Array are null. Need sub array of usable endpoints
- int usable[] = new int[endpoints.length];
- int count=0;
- for(int i=0;i<endpoints.length;++i) {
- if(endpoints[i]!=null) {
- usable[count++] = i;
- }
- }
- switch(count) {
- case 0: refresh(); return null;
- case 1: return new Item(usable[0]);
- default:
- int samemach[] = new int[count];
- int samecount = 0,closecount=0;
- // has to be sortable
- Integer closemach[] = new Integer[count];
-
- // Analyze for Same Machine or Remote machines
- for(int i=0;i<count;++i) {
- DME2Endpoint ep = endpoints[usable[i]];
- String host = ep.getHost();
- if(thisMachine.equalsIgnoreCase(host)) {
- samemach[samecount++] = usable[i];
- } else {
- closemach[closecount++] = usable[i];
- }
- }
-
- switch(samecount) {
- case 0: break;
- case 1: return new Item(samemach[0]);
- default: // return randomized is multiple Endpoints on local machine.
- int i = random.nextInt();
- return new Item(usable[Math.abs(i%samecount)]);
- }
-
- // Analyze for closest remote
- switch(closecount) {
- case 0: return null;
- case 1: return new Item(closemach[0]);
- default: // return closest machine
- DoubIndex remote[] = new DoubIndex[closecount];
- int remotecount = 0;
- for(int i=0;i<closecount;++i) {
- DME2Endpoint de = endpoints[usable[i]];
- remote[remotecount++] = new DoubIndex(de.getDistance(),i);
- }
- Arrays.sort(remote,new Comparator<DoubIndex> () {
- @Override
- public int compare(DoubIndex a, DoubIndex b) {
- if(a.d<b.d) return -1;
- if(a.d>b.d) return 1;
- return (random.nextInt()%1)==0?1:0;// randomize if the same
- }
-
- });
- return new Item(remote[0].idx);
- }
- }
- }
-
- private class DoubIndex {
- public final double d;
- public final int idx;
-
- public DoubIndex(double doub, int i) {
- d = doub;
- idx = i;
- }
- }
- @Override
- public Item first() {
- if(endpoints==null)return null;
- for(int i=0;i<endpoints.length;++i) {
- if(endpoints[i]!=null)
- return new Item(i);
- }
- return null;
- }
-
- @Override
- public Item next(Locator.Item item) throws LocatorException {
- if(endpoints==null || endpoints.length==0 || !(item instanceof Item))return null;
- int idx = ((Item)item).idx +1;
- for(int i=idx;i<endpoints.length;++i) {
- if(endpoints[i]!=null)
- return new Item(i);
- }
-// This is a mistake.. will start infinite loops
-// // Did not have any at end... try beginning
-// for(int i=0;i<idx-1;++i) {
-// if(endpoints[i]!=null)
-// return new Item(i);
-// }
-// // If still nothing, refresh
-// refresh();
- return null;
- }
-
- @Override
- public void destroy() {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2TransferSS.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2TransferSS.java
deleted file mode 100644
index f71d19c..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2TransferSS.java
+++ /dev/null
@@ -1,56 +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.dme2;
-
-import java.io.IOException;
-import java.security.Principal;
-
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.client.AbsTransferSS;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.cadi.config.SecurityInfoC;
-
-import com.att.aft.dme2.api.DME2Client;
-
-public class DME2TransferSS extends AbsTransferSS<DME2Client> {
-
- public DME2TransferSS(Principal principal, String app, SecurityInfoC<DME2Client> si) throws IOException {
- super(principal, app, si);
- }
-
- @Override
- public void setSecurity(DME2Client client) throws CadiException {
- if(value!=null) {
- if(defSS==null) {
- throw new CadiException("Need App Credentials to send message");
- }
- defSS.setSecurity(client);
- client.addHeader(Config.CADI_USER_CHAIN, value);
- }
- }
-
- @Override
- public int setLastResponse(int respCode) {
- return 0;
- }
-}
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2x509SS.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2x509SS.java
deleted file mode 100644
index af803c1..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DME2x509SS.java
+++ /dev/null
@@ -1,68 +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.dme2;
-
-import java.io.IOException;
-import java.security.cert.CertificateEncodingException;
-
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.cadi.config.SecurityInfoC;
-
-import com.att.aft.dme2.api.DME2Client;
-import org.onap.aaf.inno.env.APIException;
-
-
-public class DME2x509SS implements SecuritySetter<DME2Client> {
- private String alias;
-
- public DME2x509SS(final String sendAlias, SecurityInfoC<DME2Client> si) throws APIException, IOException, CertificateEncodingException {
- if((alias=sendAlias) == null) {
- if(si.default_alias == null) {
- throw new APIException("JKS Alias is required to use X509SS Security. Use " + Config.CADI_ALIAS +" to set default alias");
- } else {
- alias = si.default_alias;
- }
- }
- }
-
- @Override
- public void setSecurity(DME2Client dme2) throws CadiException {
- // DME2Client has to have properties set before creation to work.
- }
-
- /* (non-Javadoc)
- * @see com.att.cadi.SecuritySetter#getID()
- */
- @Override
- public String getID() {
- return alias;
- }
-
- @Override
- public int setLastResponse(int respCode) {
- return 0;
- }
-
-}
diff --git a/client/src/main/java/org/onap/aaf/cadi/dme2/DRcli.java b/client/src/main/java/org/onap/aaf/cadi/dme2/DRcli.java
deleted file mode 100644
index cd95bcc..0000000
--- a/client/src/main/java/org/onap/aaf/cadi/dme2/DRcli.java
+++ /dev/null
@@ -1,142 +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.dme2;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.aaf.cadi.CadiException;
-import org.onap.aaf.cadi.SecuritySetter;
-import org.onap.aaf.cadi.client.EClient;
-import org.onap.aaf.cadi.client.Rcli;
-
-import com.att.aft.dme2.api.DME2Client;
-import com.att.aft.dme2.api.DME2Exception;
-import com.att.aft.dme2.api.DME2Manager;
-import com.att.aft.dme2.manager.registry.DME2Endpoint;
-import com.att.aft.dme2.request.DmeUniformResource;
-import org.onap.aaf.inno.env.APIException;
-import org.onap.aaf.inno.env.Data.TYPE;
-
-/**
- * DME2 Rosetta Client
- *
- * JAXB defined JSON or XML over DME2 middleware
- *
- *
- * @param <T>
- */
-public class DRcli extends Rcli<DME2Client> {
- // Can be more efficient if tied to manager, apparently. Can pass in null.
- DME2Manager manager=null;
- private SecuritySetter<DME2Client> ss;
- private boolean isProxy;
-
- public DRcli(URI uri, SecuritySetter<DME2Client> secSet) {
- this.uri = uri;
- type = TYPE.JSON;
- apiVersion = null;
- ss=secSet;
- }
-
- @Override
- protected DRcli clone(URI uri, SecuritySetter<DME2Client> ss) {
- return new DRcli(uri,ss);
- }
-
-
-
- /**
- * Note from Thaniga on 11/5. DME2Client is not expected to be reused... need a fresh one
- * on each transaction, which is expected to cover the Async aspects.
- *
- * @return
- * @throws APIException
- * @throws DME2Exception
- */
- protected EClient<DME2Client> client() throws CadiException {
- try {
- DEClient dc = new DEClient(manager,getSecuritySetter(),uri,readTimeout);
- dc.setProxy(isProxy);
- return dc;
- } catch (DME2Exception e) {
- throw new CadiException(e);
- }
- }
-
- public DRcli setManager(DME2Manager dme2Manager) {
- manager = dme2Manager;
- return this;
- }
-
- public List<DRcli> all() throws DME2Exception, APIException {
- ArrayList<DRcli> al = new ArrayList<DRcli>();
-
- if(manager == null) {
- manager = DME2Manager.getDefaultInstance();
- }
- try {
- DME2Endpoint[] endp = manager.getEndpoints(new DmeUniformResource(manager.getConfig(),uri));
- // Convert Searchable Endpoints to Direct Endpoints
- for(DME2Endpoint de : endp) {
- al.add(new DRcli(
- new URI(uri.getScheme(),null,de.getHost(),de.getPort(),null,null,null),ss)
-// new URI(uri.getScheme(),null,de.getHost(),de.getPort(),uri.getPath(),null,null),ss)
- .setManager(manager)
- );
- }
- } catch (MalformedURLException e) {
- throw new APIException("Invalid URL",e);
- } catch (URISyntaxException e) {
- throw new APIException("Invalid URI",e);
- }
- return al;
- }
-
- @Override
- public void invalidate() throws CadiException {
- try {
- manager.refresh();
- } catch (Exception e) {
- throw new CadiException(e);
- }
- }
-
- @Override
- public void setSecuritySetter(SecuritySetter<DME2Client> ss) {
- this.ss = ss;
- }
-
- @Override
- public SecuritySetter<DME2Client> getSecuritySetter() {
- return ss;
- }
-
- public void setProxy(boolean isProxy) {
- this.isProxy = isProxy;
- }
-
-}