package com.nailabs.abac.credential; import com.nailabs.abac.test.RtmlTest; import edu.stanford.rt.credential.CredentialDomain; import edu.stanford.rt.credential.CredentialStore; import edu.stanford.rt.credential.HashID; import edu.stanford.rt.credential.RTContext; import edu.stanford.rt.parser.*; import edu.stanford.peer.rbtm.credential.*; import edu.stanford.peer.rbtm.util.ResultEvidenceMap; import java.io.*; import java.net.*; import java.util.*; /** * A distributed discovery engine based on the RTML-aware GraphEngine. */ public class DDEngine extends RtmlEngine { protected RTParser parser; protected RTContext context; protected Properties lookupMap = new Properties(); static String PORT_PROPERTY = "com.nailabs.abac.discovery.port"; /** * The default constructor grabs parameters from the configuration * HashMap, including [Parser] and [PrepInfo] sections. */ public DDEngine(HashMap config) { super(); parser = (RTParser)config.get("DDEParser"); context = (RTContext)config.get("DDEContext"); lookupMap = (Properties)config.get("PrepInfo"); store = (CredentialStore)config.get("DDEStore"); try { if(context == null) { context = new RTContext(parser); } if(store == null) { store = (CredentialStore)config.get("CredentialStore"); } if(store == null) { store = new CredentialStore(parser); } } catch (Exception ex) { ex.printStackTrace(); } } protected URL createURL(String host, String operation, String expression) { StringBuffer buff = new StringBuffer("http://"); buff.append(host).append("?"); buff.append(operation).append("=").append(expression); try { System.out.println("Constructing url = " + buff); return new URL(buff.toString()); } catch(Exception ex) { ex.printStackTrace(); } return null; } protected Vector parseOutput(URL url) { Vector documents = new Vector(); StringWriter out = null; try { URLConnection connection = url.openConnection(); InputStream in = connection.getInputStream(); BufferedReader buffedReader = new BufferedReader(new InputStreamReader(in)); out = new StringWriter(); // grab the first line so we don't have an empty vector item out.write(buffedReader.readLine()); while(true) { String line = buffedReader.readLine(); if(line == null)break; if(line.startsWith("