/** * 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 setMethod(String meth) { client.setMethod(meth); }
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); }
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(); } } }
@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); } }
@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"); } }
@Override public void addHeader(String tag, String value) { client.addHeader(tag, value); }
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(); } } }
public void setSecurity(DME2Client client) throws CadiException { if(isDenied()) { throw new CadiException(REPEAT_OFFENDER); } client.addHeader("Authorization", headValue); } }
public String call(final PrintStream out, final String meth, final String path) { try { DME2Client client = new DME2Client(new URI(aafurl),10000); client.setCredentials(aafid, symm.depass(aafpass)); client.setMethod(meth); client.setContext(path); if("GET".equalsIgnoreCase(meth) || "DELETE".equalsIgnoreCase(meth)) { client.setPayload(""); } else if("POST".equalsIgnoreCase(meth) || "PUT".equalsIgnoreCase(meth)) { int c; StringBuilder sb = new StringBuilder(); while((c=System.in.read()) >=0) { sb.append((char)c); } client.setPayload(sb.toString()); } return client.sendAndWait(10000); } catch (Exception e) { e.printStackTrace(out); return ""; } } }
@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); } }