import java.io.*; import java.util.*; import net.deterlab.abac.*; /** * Simple test of the swig generated JNI for libabac. Loads credentials * from keystore and runs a query against them. */ public class prover_test { static { System.loadLibrary("jABAC"); } public static void main(String[] args) throws IOException { if (args.length != 4) { System.out.println("Usage: prover_test "); System.out.println(" runs the query issuer.role <-?- principal and prints the result" ); System.exit(1); } Context ctxt = new Context(); String keystore=args[0]; String iname=args[1]; String roletype=args[2]; String pname=args[3]; /* role="[keyid:${pID}].role:delicious" principal="[keyid:${cID}]" */ String ifname=iname+"_ID.pem"; String pfname=pname+"_ID.pem"; ID iID=new ID(ifname); ID pID=new ID(pfname); String ikeyid=iID.id_keyid(); String pkeyid=pID.id_keyid(); String role="[keyid:"+ikeyid+"].role:"+roletype; String principal="[keyid:"+pkeyid+"]"; ctxt.load_directory(keystore); /* what is in prolog db ctxt.dump_yap_db(); */ AttributeVector credentials = ctxt.query(role, principal); long sz=credentials.size(); if(sz > 0) System.out.println("prover success!!"); else System.out.println("prover failed!!"); for(int i=0; i