+ "routeOffer=" + routeOffer; DME2Manager manager = new DME2Manager("testEndpointPublish", props); manager.setClientCredentials("sh301n", ""); DME2EndpointRegistry svcRegistry = manager.getEndpointRegistry();
@Override public void invalidate() throws CadiException { try { manager.refresh(); } catch (Exception e) { throw new CadiException(e); } }
/** * unpublishing endpoints */ public void unPublishEndPoints() { DME2Manager manager; try { System.setProperty("AFT_LATITUDE", latitude); System.setProperty("AFT_LONGITUDE", longitude); System.setProperty("AFT_ENVIRONMENT", "AFTUAT"); manager = DME2Manager.getDefaultInstance(); DME2EndpointRegistry svcRegistry = manager.getEndpointRegistry(); svcRegistry.unpublish(serviceURL, hostName, Integer.parseInt(port)); } catch (DME2Exception e) { LOG.error("Failed due to DME2Exception" + e); } }
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(); if(thisMachine==null) { // Can't get from dm... thisMachine = InetAddress.getLocalHost().getHostName(); thisPort = 0; } else { thisPort = dm.getPort(); } this.removeSelf = removeSelf; }
@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 DME2Manager newManager(PropAccess access) throws CadiException { Properties props = access.getDME2Properties(); // Critical that TLS Settings not ignored try { return new DME2Manager("AAFCon",props); } catch (DME2Exception e) { throw new CadiException(e); } }
dprops = System.getProperties(); dm = this.dm = new DME2Manager("DME2Locator created DME2Manager",dprops); } else { this.dm = dm; thisMachine = dm.getHostname(); if(thisMachine==null) { thisPort = 0; } else { thisPort = dm.getPort();
this.access = access; if(dm==null) { dm = this.dm = new DME2Manager("DME2Locator created DME2Manager",System.getProperties()); } else { this.dm = dm; DME2Server server = dm.getServer(); if(server == null) { thisMachine = InetAddress.getLocalHost().getHostName();
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; }
private static void dme2RawTest(DME2Manager dm, String aafurl, String user, String pass) { try { if(dm==null) { return; } URI uri = new URI(aafurl); print(true,"DME2 Direct Client Coding Methodology",uri.toString()); DME2Client client = dm.newClient( uri, 3000); client.setMethod("GET"); // FYI, DME2 defaults to "POST" client.setContext("/authz/perms/user/"+user); // DME2 direct requires separate setting of Context from URI if(pass!=null) { // rely on Cert if no pass client.setCredentials(user, pass); } client.setPayload(""); // DME2 will not send without something String resp = client.sendAndWait(7000); System.out.println(resp); } catch(Throwable e) { e.printStackTrace(); } } }
+ "/envContext=" + envContext + "/routeOffer=" + routeOffer; DME2EndpointRegistry svcRegistry = dme2Manager.getEndpointRegistry();
private DME2Manager newManager(PropAccess access) throws CadiException { Properties props = access.getDME2Properties(); // Critical that TLS Settings not ignored try { return new DME2Manager("AAFCon",props); } catch (DME2Exception e) { throw new CadiException(e); } }
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; }
private static void dme2RawTest(DME2Manager dm, String aafurl, String user, String pass) { try { if(dm==null) { return; } URI uri = new URI(aafurl); print(true,"DME2 Direct Client Coding Methodology",uri.toString()); DME2Client client = dm.newClient( uri, 3000); client.setMethod("GET"); // FYI, DME2 defaults to "POST" client.setContext("/authz/perms/user/"+user); // DME2 direct requires separate setting of Context from URI if(pass!=null) { // rely on Cert if no pass client.setCredentials(user, pass); } client.setPayload(""); // DME2 will not send without something String resp = client.sendAndWait(7000); System.out.println(resp); } catch(Throwable e) { e.printStackTrace(); } } }
DME2EndpointRegistry svcRegistry = dme2Manager.getEndpointRegistry(); String endpointUrlWithoutQueryParam = null; String serviceType = null;
public AAFClient(RosettaEnv env) throws Exception { this.env = env; Access access = new EnvAccess(env); String user = access.getProperty(Config.AAF_MECHID,null); String password = access.decrypt(access.getProperty(Config.AAF_MECHPASS,null), true); SecurityInfoC<HttpURLConnection> si = new SecurityInfoC<HttpURLConnection>(access); DME2Manager dm = new DME2Manager("APIclient DME2Manager", System.getProperties()); DME2Locator loc = new DME2Locator(access, dm, access.getProperty(Config.AAF_URL,null)); int TIMEOUT = Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, "30000")); hman = new HMangr(access, loc).readTimeout(TIMEOUT).apiVersion("2.0"); ss = new HBasicAuthSS(user, password, si); }
@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; }
connectTest(dl); dm = new DME2Manager("DME2Manager",pa.getProperties());
@Override public <RET> RET best(Retryable<RET> retryable) throws LocatorException, CadiException, APIException { // NOTE: DME2 had Retry Logic embedded lower. try { return (retryable.code(rclient(initURI,ss))); } catch (ConnectException e) { // DME2 should catch try { manager.refresh(); } catch (Exception e1) { throw new CadiException(e1); } throw new CadiException(e); } }
connectTest(dl); dm = new DME2Manager("DME2Manager",pa.getProperties());