/** * Generates handles response. This is were we would pass stuff to cli or gui, etc * * @param n the processed policy object * @return the policyObjected as accepted by user (potentially modified */ public PolicyObject userResponse(PolicyObject n) { if ((parseAct(genProps.getProperty("userResponse", null)) == null) && !Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) { return userInterface.userResponse(n); } else { if (Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) { return n.setAction(n.getAction().setOverride(true)); } else { return n.setAction(parseAct(genProps.getProperty("userResponse", null))); } } }
/** * returns the policy object from the policyObject option * * @return the policy object to be processed */ public void loadPO() { if (genProps.getProperty("newPolicyLoc", null) == null) System.err.println("newPolLoc == null in gio:loadPO"); File pLoc = new File(genProps.getProperty("newPolicyLoc", null)); if (!pLoc.exists()) { System.err.println("no file found at p3p policy location specified by the new policy option"); System.exit(1); } po = (new P3PParser()).parse(pLoc.getAbsolutePath()); // TODO make sure that the context is parsed if avaliable if (po.getContext().getDomain() == null) { po.setContext( new Context( new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()), genProps.getProperty("newPolicyLoc"))); } }
/** loads [additional] policies from commandline (either -p or -f) */ private void loadCLPolicies() { // we already checked to make sure we have one of the options avaliable File pLoc = null; PolicyObject p = null; if (genProps.getProperty("p3pLocation", null) != null) { pLoc = new File(genProps.getProperty("p3pLocation")); if (!pLoc.exists()) { System.err.println( "no file found at p3p policy location specified by the -p3p option: " + genProps.getProperty("p3pLocation")); System.err.println("current location is " + System.getProperty("user.dir")); System.exit(1); } try { p = (new P3PParser()).parse(pLoc.getAbsolutePath()); if (p.getContextDomain() == null) { p.setContext( new Context( new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()), genProps.getProperty("p3pLocation"))); } pdb.addPolicy(p); } catch (Exception e) { System.err.println("Error with parsing or database"); e.printStackTrace(); // System.exit(5); } } if (genProps.getProperty("p3pDirLocation", null) != null) { pLoc = new File(genProps.getProperty("p3pDirLocation")); File[] pfiles = pLoc.listFiles(); // System.err.println("pfiles for p3pDirLocation: "+pfiles); for (int i = 0; i < pfiles.length; i++) { pLoc = (pfiles[i]); if (!pLoc.exists()) { System.err.println( "no file found at p3p policy location specified by the -p3pDirLocation option, " + genProps.getProperty("p3pDirLocation")); System.exit(1); } try { p = (new P3PParser()).parse(pLoc.getAbsolutePath()); if (p.getContext().getDomain() == null) { p.setContext( new Context( new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis()), pfiles[i].getAbsolutePath())); } pdb.addPolicy(p); } catch (Exception e) { System.err.println("Einar needs to fix this parsing error."); e.printStackTrace(); } } } }