List of usage examples for com.itextpdf.text List setSymbolIndent
public void setSymbolIndent(final float symbolIndent)
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionAuthorisationFlow(Section section) { String sectionIntro = "In this section are described for each role/agent, the authorisations it passes to others and what authorisations it receives from other roles/agents."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getAuthorisationFlowActors(); List<com.itextpdf.text.List> lists = new ArrayList<com.itextpdf.text.List>(); for (Actor a : selActor) { StringBuilder sbOut = new StringBuilder(); for (Authorisation au : a.getOutgoingAuthorisations()) { if (isValidAuth(au)) { if (sbOut.length() > 0) sbOut.append(", and "); sbOut.append("authorises %i" + au.getTarget().getName() + "% to " + getOperations(au) + " information "); List<String> resList = new ArrayList<String>(); for (IResource r : au.getResources()) resList.add("%i" + r.getName() + "%"); sbOut.append(separateListOfString(resList) + ", "); List<String> goalList = new ArrayList<String>(); if (au.getGoals().size() > 0) { sbOut.append("in the scope of goal"); if (au.getGoals().size() > 1) sbOut.append("s"); // sbOut.append(" "); for (Goal g : au.getGoals()) { goalList.add("%i" + g.getName() + "%"); }/*from w w w . java 2 s . com*/ sbOut.append(" " + separateListOfString(goalList) + ", "); } if (au.getTimesTransferable() == 0) { sbOut.append("%iwithout% passing"); } else { sbOut.append("%ipassing%"); } sbOut.append(" the right to further authorising other actors"); String[] res = new String[resList.size()]; for (int i = 0; i < resList.size(); i++) res[i] = resList.get(i); String[] goals = new String[goalList.size()]; for (int i = 0; i < goalList.size(); i++) goals[i] = goalList.get(i); } } StringBuilder sbInc = new StringBuilder(); for (Authorisation au : a.getIncomingAuthorisations()) { if (isValidAuth(au)) { if (sbInc.length() > 0) sbInc.append(", and "); sbInc.append("is authorised by %i" + au.getSource().getName() + "% to " + getOperations(au) + " information "); List<String> resList = new ArrayList<String>(); for (IResource r : au.getResources()) resList.add("%i" + r.getName() + "%"); sbInc.append(separateListOfString(resList) + ", "); List<String> goalList = new ArrayList<String>(); if (au.getGoals().size() > 0) { sbInc.append("in the scope of goal"); if (au.getGoals().size() > 1) sbOut.append("s"); // sbInc.append(" "); for (Goal g : au.getGoals()) { goalList.add("%i" + g.getName() + "%"); } sbInc.append(" " + separateListOfString(goalList) + ", "); } if (au.getTimesTransferable() == 0) { sbInc.append("%iwithout% having"); } else { sbInc.append("%ihaving%"); } sbInc.append(" the right to further authorising other actors"); String[] res = new String[resList.size()]; for (int i = 0; i < resList.size(); i++) res[i] = resList.get(i); String[] goals = new String[goalList.size()]; for (int i = 0; i < goalList.size(); i++) goals[i] = goalList.get(i); } } if (sbOut.length() > 0 || sbInc.length() > 0) { String type = "%iAgent% "; if (a instanceof Role) type = "%iRole% "; Paragraph actorName = createParagraph(type + "%b" + a.getName() + "%:"); actorName.setSpacingAfter(5); com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(10f); list.add(new ListItem(actorName)); if (sbOut.length() > 0) { com.itextpdf.text.List sublist = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); sublist.setListSymbol("- "); sublist.setSymbolIndent(30f); // Paragraph p=createParagraph("%b" + a.getName() + "% " + // sbOut.toString() + "."); Paragraph p = createParagraph(sbOut.toString() + "."); if (sbInc.length() > 0) { p.setSpacingAfter(10); } sublist.add(new ListItem(p)); list.add(sublist); } if (sbInc.length() > 0) { com.itextpdf.text.List sublist = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); sublist.setListSymbol("- "); sublist.setSymbolIndent(30f); // Paragraph p=createParagraph("%b" + a.getName() + "% " + // sbInc.toString() + "."); Paragraph p = createParagraph(sbInc.toString() + "."); sublist.add(new ListItem(p)); list.add(sublist); } lists.add(list); } } if (lists.size() > 0) { String s = "In the " + getProjectName() + " project" + autDiagRef() + " the authorisations for each role/agent are:"; section.add(createParagraph(s)); for (com.itextpdf.text.List list : lists) { section.add(list); } } else { section.add(createParagraph("In the " + getProjectName() + " project there are no authorisation taking place for the given agents/roles.")); } section.setComplete(true); }
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildAppendixCChapter(Chapter c, Document d) { c.setTitle(getChapterTitleParagraph("Appendix C")); c.setNumberDepth(0);/*from ww w. j a v a 2 s.c o m*/ c.setTriggerNewPage(true); String sectionIntro = "STS-ml allows for the specification of security needs over actors interactions. It currently supports a non-exhaustive set of security needs and organisational constraints, namely non-repudiation, redundancy, no-delegation, non-usage, non-modification, non-production, non-disclosure and need-to-know. The purpose of security analysis is to verify whether there are any violations of security needs. As such, it includes defining the rules necessary to detect violations. In the following are provided the details for all the checks performed during security analysis."; c.add(createParagraph(sectionIntro)); List<Paragraph> plist = new ArrayList<Paragraph>(); int kk = 0; for (kk = kk; kk < 4; kk++) { plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } c.add(listParagraphs(plist)); plist.clear(); Paragraph parList = getDefaultParagraph(); com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f); parList.add(list); parList.setSpacingBefore(0f); parList.setSpacingAfter(0f); list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++]))); com.itextpdf.text.List subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); subList.setListSymbol("\u2022" + " "); subList.setSymbolIndent(15f); for (kk = kk; kk < 10; kk++) { subList.add( new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]))); // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } list.add(subList); c.add(parList); /* * Paragraph actorName = createParagraph(type + "%b" + a.getName() + * "%:"); actorName.setSpacingAfter(5); * * com.itextpdf.text.List list = new * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); * list.setListSymbol("\u2022" + " "); list.setSymbolIndent(10f); * list.add(new ListItem(actorName)); * * if (sbOut.length() > 0) { com.itextpdf.text.List sublist = new * com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); * sublist.setListSymbol("- "); sublist.setSymbolIndent(30f); * //Paragraph p=createParagraph("%b" + a.getName() + "% " + * sbOut.toString() + "."); Paragraph p = * createParagraph(sbOut.toString() + "."); * * if (sbInc.length() > 0) { p.setSpacingAfter(10); } * * sublist.add(new ListItem(p)); list.add(sublist); */ String text = "Apart from the verification of violations of security needs, security analysis performs checks to verify that actors comply with their authorities. For this, it searches for eventual unauthorised passages of rights. For the time being, the following violations are detected:"; c.add(createParagraph(text)); parList = getDefaultParagraph(); list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); list.setListSymbol("\u2022" + " "); list.setSymbolIndent(30f); parList.add(list); parList.setSpacingBefore(0f); parList.setSpacingAfter(0f); list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++]))); subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); subList.setListSymbol("\u2022" + " "); subList.setSymbolIndent(15f); for (kk = kk; kk < 16; kk++) { subList.add( new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]))); // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } list.add(subList); c.add(parList); text = "As far as organisational constraints are concerned, security analysis verifies that the specification of SoD and BoD constraints can be satisfied in the given model. The satisfaction of role-based SoD and BoD are already covered by the consistency analysis, security analysis deals with goal-based SoD and BoD instead."; c.add(createParagraph(text)); for (kk = kk; kk < SecurityAnalysisTasksNames.ALL_TASKS_NAMES.length; kk++) { plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])); } c.add(listParagraphs(plist)); c.setComplete(true); }
From source file:org.smap.sdal.managers.PDFSurveyManager.java
License:Open Source License
private void processSelect(Parser parser, String remoteUser, PdfPCell cell, DisplayItem di, boolean generateBlank, GlobalVariables gv, int oId) throws Exception { Font f = null;/*from w w w . j a v a 2 s . c o m*/ boolean isRtl = false; // If generating blank template List list = new List(); list.setAutoindent(false); list.setSymbolIndent(24); String lang; boolean isSelectMultiple = di.type.equals("select") ? true : false; // Questions that append their values to this question ArrayList<String> deps = gv.addToList.get(di.fIdx + "_" + di.rec_number + "_" + di.name); /* * Add the value of this question unless * The form is not blank and the value is "other" and their are 1 or more dependent questions * In this case we assume that its only the values of the dependent questions that are needed */ if (generateBlank) { // TODO get real choices using choice manager Form form = survey.forms.get(di.fIdx); Question question = form.questions.get(di.qIdx); OptionList ol = survey.optionLists.get(question.list_name); for (Option o : ol.options) { String text = null; if (o.display_name != null && o.display_name.trim().length() > 0) { text = o.display_name; } else { text = o.labels.get(languageIdx).text; } lang = GeneralUtilityMethods.getLanguage(text); f = getFont(lang); isRtl = isRtl(lang); ListItem item = new ListItem(GeneralUtilityMethods.unesc(text), f); if (isSelectMultiple) { item.setListSymbol(new Chunk("\uf096", Symbols)); list.add(item); } else { item.setListSymbol(new Chunk("\uf10c", Symbols)); list.add(item); } } if (isRtl) { cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); } cell.addElement(list); } else { if (deps == null || (di.value != null && !di.value.trim().toLowerCase().equals("other"))) { String value = di.value; if (di.type.equals("select1")) { Form form = survey.forms.get(di.fIdx); Question question = form.questions.get(di.qIdx); ArrayList<String> matches = new ArrayList<String>(); matches.add(di.value); value = choiceManager.getLabel(sd, cResults, user, oId, survey.id, question.id, question.l_id, question.external_choices, question.external_table, survey.languages.get(languageIdx).name, languageIdx, matches, survey.ident); } else if (di.type.equals("select")) { String nameValue = value; if (nameValue != null) { String vArray[] = nameValue.split(" "); ArrayList<String> matches = new ArrayList<String>(); if (vArray != null) { for (String v : vArray) { matches.add(v); } } Form form = survey.forms.get(di.fIdx); Question question = form.questions.get(di.qIdx); value = choiceManager.getLabel(sd, cResults, user, oId, survey.id, question.id, question.l_id, question.external_choices, question.external_table, survey.languages.get(languageIdx).name, languageIdx, matches, survey.ident); } } if (GeneralUtilityMethods.isRtlLanguage(di.value)) { cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); } parser.elements.clear(); String html = getHtml(value, di, gv, deps); try { parser.xmlParser.parse(new StringReader(html)); } catch (Exception e) { log.info("Error parsing: " + html.toString() + " : " + e.getMessage()); lm.writeLog(sd, survey.getId(), remoteUser, LogManager.ERROR, e.getMessage() + " for: " + html.toString()); cell.addElement(getPara(html.toString(), di, gv, null, null)); } for (Element element : parser.elements) { cell.addElement(element); } //cell.addElement(getPara(value, di, gv, deps, null)); } } }