import java.util.HashMap;
import java.util.Map;
import org.globus.myproxy.MyProxy;
import org.ietf.jgss.GSSCredential;
import edu.indiana.extreme.gfac.util.GfacUtils;
import xregistry.XregistryConstants;
import xregistry.XregistryException;
import xregistry.auth.Authorizer;
import xregistry.client.DocumentRegistryClient;
import xregistry.context.GlobalContext;
import xregistry.doc.DocData;
import xregistry.utils.ProxyRenewer;
import xregistry.utils.Utils;
public class Tester {
/**
* @param args
* @throws XregistryException
*/
public static void main(String[] args) throws Exception {
GlobalContext globalContext = new GlobalContext(true);
DocumentRegistryClient client = new DocumentRegistryClient(globalContext,"https://tyr15.cs.indiana.edu:6666/xregistry?wsdl");
client.registerConcreteWsdl(GfacUtils.readFile("/u/hperera/temp/cwsdls/AdderService.wsdl"), 99999999);
System.out.println(Utils.canonicalizeDN("O=LEAD Project,OU=portal.leadprojec t.org,OU=cs.indiana.edu,CN=hperera/Email=hperera@cs.indiana.edu,CN=proxy"));
// String actorsToAddStr = "#U/C=US/O=National Center for Supercomputing Applications/CN=Suresh Marru$Read";
//
// if(actorsToAddStr != null){
// Map<String,String> actorsToAdd = new HashMap<String,String>();
//
// String[] actorsToAddRaw = actorsToAddStr.split("#");
// for(String raw:actorsToAddRaw){
// if(raw != null && raw.trim().length() > 0){
// System.out.println("raw ="+raw);
// String[] data = raw.split("\\$");
// actorsToAdd.put(data[0], data[1]);
// boolean isUser = data[0].startsWith("U");
// String actor = data[0].substring(1);
// }
// }
// }
//
// String file = Utils.readFile("src/IXregistry.xml");
// String prettywsdl = Utils.prettyPrint2String(XmlConstants.BUILDER.parseFragmentFromReader(new StringReader(file)));
// System.out.println(prettywsdl);
//
// FileWriter out = new FileWriter("src/Xregistry.xml");
// out.write(prettywsdl);
// out.close();
// ProxyRenewer proxyRenewer = new ProxyRenewer("hperera", "hperera1234",
// MyProxy.DEFAULT_PORT, 1234, "portal.leadproject.org");
//
// GSSCredential credential = proxyRenewer.renewProxy();
// System.out.println(credential.getName());
// GlobalContext globalContext = new GlobalContext(true);
// globalContext.setTrustedCertsFile("/etc/lead/certificates/trusted_cas.pem");
// globalContext.setCredential(credential);
// //globalContext.setHostcertsKeyFile("/etc/lead/certificates/hostcertkey.pem.hperera");
// DocumentRegistryClient client = new DocumentRegistryClient(globalContext,"https://129.79.246.253:6666/xregistry?wsdl");
// //client.addCapability("urn:hostdesc:grid-hg.ncsa.teragrid.org", "extreme", false, XregistryConstants.Action.All.toString());
//
// DocData[] data = client.findHosts("");
// for(DocData doc:data){
// System.out.println(doc.name);
// }
// client.removeConcreteWsdl("{http://www.extreme.indiana.edu/namespaces/2004/01/gFac}SrinathLsService35_Thu_Jun_28_11_40_48_EDT_2007_941422");
// Scanner scanner = new Scanner(new File("src/xregistry/tables.sql"));
// scanner.useDelimiter(";");
// //Pattern pattern = Pattern.compile(".*\\;");
//
// while(scanner.hasNext()){
// String line = scanner.next();
// if(line.trim().length() > 0 && !line.startsWith("--")){
// System.out.println(line.trim()+"\n");
// //statement.executeUpdate(line.trim());
// }
// }
}
}