From 62c4eb45e157d502463d797c1353802ca8e1e307 Mon Sep 17 00:00:00 2001 From: sg481n Date: Fri, 25 Aug 2017 01:57:24 -0400 Subject: Update project structure for aaf/cadi Update project structure from com.att to org.onap and add distribution management and staging plugin. Issue-id: AAF-22 Change-Id: Idf2b591139e38921ad28782a51486714a05dee92 Signed-off-by: sg481n --- .../main/java/org/onap/aaf/cadi/dme2/DEClient.java | 223 +++++++++++++ .../java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java | 64 ++++ .../java/org/onap/aaf/cadi/dme2/DME2ClientSS.java | 65 ++++ .../java/org/onap/aaf/cadi/dme2/DME2Locator.java | 349 +++++++++++++++++++++ .../org/onap/aaf/cadi/dme2/DME2TransferSS.java | 56 ++++ .../java/org/onap/aaf/cadi/dme2/DME2x509SS.java | 68 ++++ .../main/java/org/onap/aaf/cadi/dme2/DRcli.java | 142 +++++++++ 7 files changed, 967 insertions(+) create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DME2ClientSS.java create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DME2Locator.java create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DME2TransferSS.java create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DME2x509SS.java create mode 100644 client/src/main/java/org/onap/aaf/cadi/dme2/DRcli.java (limited to 'client/src/main/java/org/onap/aaf/cadi/dme2') 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 new file mode 100644 index 0000000..7bbdc25 --- /dev/null +++ b/client/src/main/java/org/onap/aaf/cadi/dme2/DEClient.java @@ -0,0 +1,223 @@ +/******************************************************************************* + * ============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 { + private DME2Client client; + private DME2RestfulHandler replyHandler; + private EClient.Transfer payload; + private boolean isProxy; + private SecuritySetter ss; + + public DEClient(DME2Manager manager, SecuritySetter 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 extends Future { + 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 Future futureCreate(Class t) { + return new DFuture(replyHandler) { + public boolean evalInfo() throws APIException { + + return info.getCode()==201; + } + }; + } + + + @Override + public Future futureReadString() { + return new DFuture(replyHandler) { + public boolean evalInfo() throws APIException { + if(info.getCode()==200) { + value = info.getBody(); + return true; + } + return false; + } + }; + } + + @Override + public Future futureRead(final RosettaDF df, final Data.TYPE type) { + return new DFuture(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 Future future(final T t) { + return new DFuture(replyHandler) { + public boolean evalInfo() { + if(info.getCode()==200) { + value = t; + return true; + } + return false; + } + }; + } + + @Override + public Future 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 new file mode 100644 index 0000000..b29074f --- /dev/null +++ b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2BasicAuth.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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 { + public DME2BasicAuth(String user, String pass, SecurityInfoC si) throws IOException { + super(user,pass,si); + } + + public DME2BasicAuth(Access access, SecurityInfoC 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 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(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 new file mode 100644 index 0000000..167fe3b --- /dev/null +++ b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2ClientSS.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * ============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 { + 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 new file mode 100644 index 0000000..47af9ea --- /dev/null +++ b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2Locator.java @@ -0,0 +1,349 @@ +/******************************************************************************* + * ============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;i0; + } + + @Override + public void invalidate(Locator.Item item) throws LocatorException { + if(item instanceof Item) { + int idx = ((Item)item).idx; + if(idx () { + @Override + public int compare(DoubIndex a, DoubIndex b) { + if(a.db.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 { + + public DME2TransferSS(Principal principal, String app, SecurityInfoC 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 new file mode 100644 index 0000000..af803c1 --- /dev/null +++ b/client/src/main/java/org/onap/aaf/cadi/dme2/DME2x509SS.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * ============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 { + private String alias; + + public DME2x509SS(final String sendAlias, SecurityInfoC 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 new file mode 100644 index 0000000..cd95bcc --- /dev/null +++ b/client/src/main/java/org/onap/aaf/cadi/dme2/DRcli.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * ============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 + */ +public class DRcli extends Rcli { + // Can be more efficient if tied to manager, apparently. Can pass in null. + DME2Manager manager=null; + private SecuritySetter ss; + private boolean isProxy; + + public DRcli(URI uri, SecuritySetter secSet) { + this.uri = uri; + type = TYPE.JSON; + apiVersion = null; + ss=secSet; + } + + @Override + protected DRcli clone(URI uri, SecuritySetter 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 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 all() throws DME2Exception, APIException { + ArrayList al = new ArrayList(); + + 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 ss) { + this.ss = ss; + } + + @Override + public SecuritySetter getSecuritySetter() { + return ss; + } + + public void setProxy(boolean isProxy) { + this.isProxy = isProxy; + } + +} -- cgit 1.2.3-korg