Example usage for com.itextpdf.text Chapter add

List of usage examples for com.itextpdf.text Chapter add

Introduction

In this page you can find the example usage for com.itextpdf.text Chapter add.

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

Adds a Paragraph, List, Table or another Section to this Section.

Usage

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildIntorductionChapter(Chapter chapter) {

    chapter.setTitle(getChapterTitleParagraph("Introduction"));
    chapter.setTriggerNewPage(true);//from w  ww .  j a  v a  2 s . co  m

    StringBuilder sb = new StringBuilder();
    sb.append("This document describes the security requirements for the " + getProjectName()
            + " project. It provides a detailed description of the socio-technical security requirements models ");

    if (generateSecurityRequirementsChapter() && (!generateSocialViewChapter()
            && !generateInformationViewChapter() && !generateAuthorisationViewChapter())) {
        sb.append("presenting the list of security requirements derived in terms of social commitments.");
    } else {
        List<String> views = new ArrayList<String>();
        if (generateSocialViewChapter()) {
            views.add("%iSocial%");
        }
        if (generateInformationViewChapter()) {
            views.add("%iInformation%");
        }
        if (generateAuthorisationViewChapter()) {
            views.add("%iAuthorisation%");
        }

        if (views.size() == 1) {
            sb.append("from a view ");
        } else {
            sb.append("from different views ");
        }
        sb.append("(" + separateListOfString(views, ", ", ", ") + ")");

        if (generateSecurityRequirementsChapter()) {
            sb.append(" and then presents the list of %isecurity requirements% derived from them");
        }
        sb.append(".");

    }

    chapter.add(createParagraph(sb.toString()));

    sb = new StringBuilder();

    if (generateSocialViewChapter()) {
        sb.append(
                "The %iSocial view% represents stakeholders as intentional and social entities, representing their goals and important information in terms of documents, together with their interactions with other actors to achieve these goals and to exchange information. Stakeholders express constraints over their interactions in terms of %i security needs. % ");
    }
    if (generateInformationViewChapter()) {
        if (sb.length() > 0)
            sb.append(" ");
        sb.append(
                "The %iInformation view% represents the informational content of stakeholders documents, showing how information and documents are interconnected, as well as how they are composed respectively.");
    }
    if (generateAuthorisationViewChapter()) {
        if (sb.length() > 0)
            sb.append(" ");
        sb.append(
                "The %iAuthorisation view% represents which stakeholders own what information, and captures the flow of permissions from one stakeholder to another. The modelling of authorisations expresses other %i security needs % related to the way information is to be manipulated. ");
    }
    if (sb.length() > 0)
        chapter.add(createParagraph(sb.toString()));

    if (generateSecurityRequirementsChapter()) {
        String s = "The document ends with the list of %isecurity requirements% for the system to be expressed in terms of %i social commitments%, namely promises with contractual validity stakeholders make to one another. The security requirements are derived automatically once the modelling is done and the designer has expressed the security needs. Whenever a security need is expressed over an interaction from one stakeholder to the other, a commitment on the opposite direction is expected from the second stakeholder to satisfy the security need.";
        chapter.add(createParagraph(s));
    }

    chapter.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

/******************************************************************************************/

private void buildSocialViewChapter(Chapter chapter, Document document) {

    chapter.setTitle(getChapterTitleParagraph("Social View"));
    String chapterIntro = "The social view shows the involved stakeholders, which are represented as %iroles% and %iagents%. Agents refer to actual participants (stakeholders) known when modelling the "
            + getProjectName()/*w  w w.java 2s . com*/
            + " project, whereas roles are a generalisation (abstraction) of agents. To capture the connection between roles and agents, the %i play % relation is used to express the fact that certain agents play certain roles.";
    chapter.add(createParagraph(chapterIntro));
    chapterIntro = "Stakeholders have goals to achieve and they make use of different information to achieve these goals. They interact with one another mainly by %i delegating goals% and %i exchanging information%. Information is represented by means of documents, which actors manipulate to achieve their goals.";
    chapter.add(createParagraph(chapterIntro));

    if (generateSocialViewDiagramSection()) {
        buildSectionSocialDiagram(chapter.addSection(getSectionTitleParagraph("Social View Diagram")),
                document);
        chapter.add(Chunk.NEXTPAGE);
    }
    if (generateStakeholdersSection()) {
        buildSectionStakeholders(chapter.addSection(getSectionTitleParagraph("Stakeholders")));
    }
    if (generateStakeholdersDocumentSection()) {
        buildSectionStakeholdersDocument(
                chapter.addSection(getSectionTitleParagraph("Stakeholders' documents")));
    }
    if (generateStakeholdersDocumentAndGoalsSection()) {
        buildSectionStakeholdersDocumentAndGoals(
                chapter.addSection(getSectionTitleParagraph("Stakeholders' documents and goals")));
    }
    if (generateGoalAnalysisSection()) {
        buildSectionGoalAnalysis(chapter.addSection(getSectionTitleParagraph("Goal Analysis")));
    }
    if (generateGoalContributionSection()) {
        buildSectionGoalContribution(chapter.addSection(getSectionTitleParagraph("Contributions")));
    }
    if (generateStakeholdersInteractionsSection()) {
        buildSectionStakeholdersInteractions(
                chapter.addSection(getSectionTitleParagraph("Stakeholders Interactions")));
    }
    if (generateOrganisationalConstraintsSection()) {
        buildSectionOrganisationalConstraints(
                chapter.addSection(getSectionTitleParagraph("Organisational Constraints")));
    }

    if (generateEventSection()) {
        buildEventsSection(chapter.addSection(getSectionTitleParagraph("Events")));
    }

    chapter.setTriggerNewPage(true);
    chapter.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

/******************************************************************************************/

private void buildInformationViewChapter(Chapter chapter, Document document) {

    chapter.setTitle(getChapterTitleParagraph("Information View"));
    chapter.setTriggerNewPage(true);//from w w w .j a v  a 2  s.c om
    String chapterIntro = "The information view gives a structured representation of the information and documents in the "
            + getProjectName()
            + " project. It shows what is the informational content of the documents represented in the social view. Information is represented by one or more documents (%itangible by%), and the same document can make tangible multiple information. Moreover, the information view considers composite documents (information) capturing these by means of %ipart of% relations.";
    chapter.add(createParagraph(chapterIntro));

    if (generateInformationViewDiagramSection()) {
        buildSectionInformationViewDiagram(
                chapter.addSection(getSectionTitleParagraph("Information View Diagram")), document);
        chapter.add(Chunk.NEXTPAGE);
    }
    if (generateModellingOwnershipSection()) {
        buildSectionModellingOwnership(chapter.addSection(getSectionTitleParagraph("Modelling Ownership")));
    }
    if (generateRepresentationInformationSection()) {
        buildSectionRepresentationInformation(
                chapter.addSection(getSectionTitleParagraph("Representation of Information")));
    }
    if (generateCompositionSection()) {
        buildSectionComposition(chapter.addSection(getSectionTitleParagraph("Compositions")));
    }
    chapter.setTriggerNewPage(true);
    chapter.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

/******************************************************************************************/

private void buildAuthorisationViewChapter(Chapter chapter, Document document) {

    chapter.setTitle(getChapterTitleParagraph("Authorisation View"));

    String chapterIntro = "The authorisation view shows the permission flow from a stakeholder to another, that is, the authorisations stakeholders grant to others about information, specifying the operations the others can perform over the information. Apart from granting authority on performing operations, a higher authority can be granted, that of further authorising other actors.";
    chapter.add(createParagraph(chapterIntro));
    chapterIntro = "Authorisations start from the information owner. Therefore, in the authorisation view, ownership is preserved and inherited from the information view.";
    chapter.add(createParagraph(chapterIntro));

    if (generateAuthorisationViewDiagramSection()) {
        buildSectionAuthorisationDiagram(
                chapter.addSection(getSectionTitleParagraph("Authorisation View Diagram")), document);
        chapter.add(Chunk.NEXTPAGE);/*from w  w w. java  2 s  .co  m*/
    }
    if (generateAuthorisationFlowSection()) {
        buildSectionAuthorisationFlow(chapter.addSection(getSectionTitleParagraph("Authorisation Flow")));
    }
    chapter.setTriggerNewPage(true);
    chapter.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

/******************************************************************************************/

private void buildSecurityRequirementsChapter(Chapter chapter, Document document) {

    chapter.setTitle(getChapterTitleParagraph("Security Requirements"));

    String chapterIntro = "This section provides the list of security requirements derived for the "
            + getProjectName() + " project.";
    chapter.add(createParagraph(chapterIntro));

    chapterIntro = "The list of security requirements shows the roles/agents that are %iresponsible% to satisfy them, so that stakeholders know what they have to bring about in order to satisfy the corresponding security needs. Security requirements also include the authorisations granted by stakeholders to other stakeholders.";
    chapter.add(createParagraph(chapterIntro));

    chapterIntro = "%iSecurity needs% are expressed mainly over goal delegations, document provisions and authorisations. Therefore, the list of security requirements is derived from every type of security need. Moreover, the organisational constraints specify further %ineeds% over roles and goal, leading to the generation of other security requirements.";
    chapter.add(createParagraph(chapterIntro));

    chapterIntro = "Finally, the %irequester% actors are represented to capture the actors requiring certain security needs to be brought about.";
    chapter.add(createParagraph(chapterIntro));

    buildSecurityRequirementsChapterContent(chapter);

    chapter.setTriggerNewPage(true);//from   w  w w . j  av a 2 s  . c o  m
    chapter.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSecurityRequirementsChapterContent(Chapter chapter) {

    List<Actor> selActors = getSecurityRequirementsActors();
    List<Paragraph> phrases = new ArrayList<Paragraph>();

    for (Actor act : selActors) {

        StringBuilder sbDel = new StringBuilder();
        for (Delegation d : act.getOutgoingDelegations()) {

            if (selActors.contains(d.getTarget())) {

                if ((d.getTimesTransferable() >= 0
                        || (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION
                                || d.getRepudiationType() == RepudiationType.DELEGATEEE_REPUDIATION)
                        || d.getRedundancyType() != RedundancyType.NO_REDUNDANCY)) {
                    if (sbDel.length() > 0)
                        sbDel.append("; while it ");
                    sbDel.append("requires %i" + d.getTarget().getName() + "% ");

                    List<String> req = new ArrayList<String>();

                    if (d.getRedundancyType() != RedundancyType.NO_REDUNDANCY) {
                        switch (d.getRedundancyType()) {
                        case TRUE_SINGLE:
                            req.add("%isingle-actor-true-redundancy% (true_rs)");
                            break;
                        case TRUE_MULTI:
                            req.add("%imulti-actor-true-redundancy% (true_rm)");
                            break;
                        case FALLBACK_SINGLE:
                            req.add("%isingle-actor-fallback-redundancy% (multi_rs)");
                            break;
                        case FALLBACK_MULTI:
                            req.add("%imulti-actor-fallback-redundancy% (multi_rm)");
                            break;
                        }/*from  w w  w.  j  a v a2s. co m*/
                    }
                    if (d.getTimesTransferable() >= 0) {
                        req.add("%ino-delegation% on goal %i" + d.getSourceGoal().getName() + "%");
                    }

                    if (d.getRepudiationType() == RepudiationType.DELEGATEEE_REPUDIATION
                            || d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION) {
                        req.add("%inon-repudiation-of-acceptance% " + "of the delegation of goal %i"
                                + d.getSourceGoal().getName() + "%");
                    }

                    if (d.isAvailability()) {
                        req.add("an %iAvailability% level of " + d.getAvailabilityValue() + "%");
                    }
                    if (d.isTrustworthiness()) {
                        req.add("a %iTrustworthiness% level of " + d.getTrustworthinessValue() + "");
                    }

                    if (req.size() > 0) {
                        StringBuilder sb = new StringBuilder();
                        sb.append(separateListOfString(req));
                        sb.append(", when delegating %i" + d.getSourceGoal().getName() + "% to %i"
                                + d.getTarget().getName() + "%");
                        sbDel.append(sb.toString());
                    }
                }

                if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION
                        || d.getRepudiationType() == RepudiationType.DELEGATOR_REPUDIATION) {
                    if (sbDel.length() > 0)
                        sbDel.append("; while it ");
                    sbDel.append("is required by %i" + d.getTarget().getName() + "% ");
                    sbDel.append("%inon-repudiation-of-delegation% " + "of the delegation of goal %i"
                            + d.getSourceGoal().getName() + "%, ");
                    sbDel.append("when delegating %i" + d.getSourceGoal().getName() + "% to %i"
                            + d.getTarget().getName() + "%");
                }
            }
        }

        if (sbDel.length() > 0) {
            phrases.add(createParagraph("%b" + act.getName() + "% " + sbDel.toString() + "."));
        }

        StringBuilder sbProv = new StringBuilder();
        for (Provision p : act.getOutgoingProvisions()) {
            if (selActors.contains(p.getTarget())) {
                if (p.isAvailability()) {
                    sbProv.append("requires %i" + p.getTarget().getName() + "% an availability level of "
                            + p.getAvailabilityValue() + "% for document ");
                    sbProv.append("%i" + p.getSourceResource().getName() + "%, when providing %i"
                            + p.getTarget().getName() + "% this document");
                }
                if (p.isIntegrity()) {
                    if (sbProv.length() > 0)
                        sbProv.append("; while it ");
                    sbProv.append("is required by %i" + p.getTarget().getName()
                            + "% to ensure integrity of transmission over the provision of document "
                            + p.getSourceResource().getName());
                    // sbProv.append("%i" + p.getSourceResource().getName()
                    // + "%, when providing document %i" +
                    // p.getTarget().getName() + "% ");
                }
                if (p.isConfidentiality()) {
                    if (sbProv.length() > 0)
                        sbProv.append("; while it ");
                    sbProv.append("is required by %i" + p.getTarget().getName()
                            + "% to ensure confidentiality of transmission over the provision of document "
                            + p.getSourceResource().getName());
                }
            }
        }
        if (sbProv.length() > 0) {
            phrases.add(createParagraph("%b" + act.getName() + "% " + sbProv.toString() + "."));
        }

        StringBuilder sbAut = new StringBuilder();
        for (Authorisation a : act.getOutgoingAuthorisations()) {
            if (selActors.contains(a.getTarget())) {
                if (a.getResources().size() > 0
                        && (a.isDistribution() || a.isModification() || a.isUsage() || a.isProduce())
                        && !(a.isDistribution() && a.isModification() && a.isUsage() && a.isProduce())) {
                    List<String> comm = new ArrayList<String>();
                    List<String> opera = new ArrayList<String>();
                    List<String> goals = new ArrayList<String>();
                    List<String> res = new ArrayList<String>();
                    for (IResource r : a.getResources()) {
                        res.add("%i" + r.getName() + "%");
                    }
                    for (Goal g : a.getGoals()) {
                        goals.add("%i" + g.getName() + "%");
                    }

                    if (!a.isUsage()) {
                        comm.add("%i" + "non-usage" + "%");
                    } else {
                        opera.add("%i" + "use" + "%");
                    }
                    if (!a.isModification()) {
                        comm.add("%i" + "non-modification" + "%");
                    } else {
                        opera.add("%i" + "modify" + "%");
                    }
                    if (!a.isProduce()) {
                        comm.add("%i" + "non-production" + "%");
                    } else {
                        opera.add("%i" + "produce" + "%");
                    }
                    if (!a.isDistribution()) {
                        comm.add("%i" + "non-disclosure" + "%");
                    } else {
                        opera.add("%i" + "distribute" + "%");
                    }

                    if (sbAut.length() > 0)
                        sbAut.append("; while it ");
                    sbAut.append("requires %i" + a.getTarget().getName() + "% the ");
                    sbAut.append(separateListOfString(comm) + " of information");
                    if (res.size() > 1)
                        sbAut.append("s");
                    sbAut.append(" " + separateListOfString(res) + ", ");

                    if (a.getGoals().size() > 0) {
                        sbAut.append("and %ineed-to-know% of these pieces of information");
                        if (res.size() > 1)
                            sbAut.append("s");
                        sbAut.append(" in the scope of goal");
                        if (goals.size() > 1)
                            sbAut.append("s");
                        sbAut.append(" " + separateListOfString(goals) + ", ");
                    }
                    sbAut.append("when autorising %i" + a.getTarget().getName() + "% to "
                            + separateListOfString(opera) + " ");
                    sbAut.append(separateListOfString(res));
                    if (a.getGoals().size() > 0) {
                        sbAut.append(" in the scope of goal");
                        if (goals.size() > 1)
                            sbAut.append("s");
                        sbAut.append(" " + separateListOfString(goals));
                    }
                }
            }
        }
        if (sbAut.length() > 0) {
            phrases.add(createParagraph("%b" + act.getName() + "% " + sbAut.toString() + "."));
        }
    }

    List<Paragraph> sodRole = new ArrayList<Paragraph>();
    List<Paragraph> sodGoal = new ArrayList<Paragraph>();
    List<Paragraph> bodGoal = new ArrayList<Paragraph>();

    for (Actor a : selActors) {
        if (a instanceof Role) {
            Role r = (Role) a;
            for (IncompatibleDuties id : r.getIncompatibleDutiesOut()) {
                if (id.getTarget() != null && id.getTarget() instanceof Role) {
                    String r1 = "%i" + r.getName() + "%";
                    String r2 = "%i" + ((Role) id.getTarget()).getName() + "%";
                    String s = "%iAny agent% playing " + r1 + "  is required not to play " + r2
                            + ", and any agent playing " + r2 + " is required not to play " + r1
                            + ", given that an SoD constraint is specified between " + r1 + " and " + r2 + ".";
                    sodRole.add(createParagraph(s));
                }
            }
        }
        for (Goal g : a.getGoals()) {
            for (IncompatibleDuties id : g.getIncompatibleDutiesOut()) {
                if (id.getTarget() != null && id.getTarget() instanceof Goal) {
                    String g1 = "%i" + g.getName() + "%";
                    String g2 = "%i" + ((Goal) id.getTarget()).getName() + "%";
                    String s = "%iAny agent% achieving " + g1 + " is required not to achieve " + g2
                            + ", and any agent achieving " + g2 + " is required not to achieve " + g1
                            + ", when specifying a SoD constraint between these goals.";
                    sodGoal.add(createParagraph(s));
                }
            }
            for (CompatibleDuties bd : g.getCompatibleDutiesOut()) {
                if (bd.getTarget() != null && bd.getTarget() instanceof Goal) {
                    String g1 = "%i" + g.getName() + "%";
                    String g2 = "%i" + ((Goal) bd.getTarget()).getName() + "%";
                    String s = "%iAny agent% achieving " + g1 + " is required to achieve " + g2
                            + ", and any agent achieving " + g2 + " is required not to achieve " + g1
                            + ", when specifying a CoD constraint between these goals.";
                    bodGoal.add(createParagraph(s));
                }
            }
        }
    }

    phrases.addAll(sodRole);
    phrases.addAll(sodGoal);
    phrases.addAll(bodGoal);

    if (phrases.size() > 0) {
        String s = "The security requirements for the " + getProjectName() + " project ("
                + ftc.getTable(FigureConstant.COMM_TABLE) + ") are:";
        chapter.add(createParagraph(s));
        chapter.add(listParagraphs(phrases));

        buildSecurityRequirementsChapterContentTable(chapter);
    } else {

    }

}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSecurityRequirementsChapterContentTable(Chapter chapter) {

    List<Actor> selActors = getSecurityRequirementsActors();

    List<String[]> headers = new ArrayList<String[]>();//
    headers.add(new String[] { "Responsible" });
    headers.add(new String[] { "Security Requirement" });
    headers.add(new String[] { "Requester" });
    headers.add(new String[] { "Description" });
    PdfPTable table = createTable(headers);

    for (Actor act : selActors) {

        List<PdfPCell> cells = new ArrayList<PdfPCell>();

        for (Delegation d : act.getIncomingDelegations()) {
            if (selActors.contains(d.getSource()) && (d.getTimesTransferable() >= 0
                    || d.getRepudiationType() != RepudiationType.NO_REPUDIATION
                    || d.getRedundancyType() != RedundancyType.NO_REDUNDANCY || d.isAvailability())) {
                if (d.getRedundancyType() != RedundancyType.NO_REDUNDANCY) {
                    String red = "";
                    switch (d.getRedundancyType()) {
                    case TRUE_SINGLE:
                        red = "single-actor-true-redundancy";
                        break;
                    case TRUE_MULTI:
                        red = "multi-actor-true-redundancy";
                        break;
                    case FALLBACK_SINGLE:
                        red = "single-actor-fallback-redundancy";
                        break;
                    case FALLBACK_MULTI:
                        red = "single-actor-fallback-redundancy";
                        break;
                    }/*from   w  w w .java 2  s .co m*/

                    cells.add(getContentCell(new String[] { red, "(" + d.getSourceGoal().getName() + ")" }));
                    cells.add(getContentCell(d.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getTarget().getName() + " requires " + red + " for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegating " + d.getSourceGoal().getName() + " to "
                            + d.getTarget().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.getTimesTransferable() >= 0) {
                    String s = "no-delegation";
                    cells.add(getContentCell(new String[] { s, "(" + d.getSourceGoal().getName() + ")" }));
                    cells.add(getContentCell(d.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getTarget().getName() + " requires " + s + " for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegating " + d.getSourceGoal().getName() + " to "
                            + d.getTarget().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION
                        || d.getRepudiationType() == RepudiationType.DELEGATEEE_REPUDIATION) {
                    cells.add(getContentCell(new String[] { "non-repudiation-of-acceptance",
                            "(delegated(" + d.getSource().getName() + "," + d.getTarget().getName() + ","
                                    + d.getSourceGoal().getName() + "))" }));
                    cells.add(getContentCell(d.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getSource().getName() + " require non-repudiation-of-acceptance for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegating " + d.getSourceGoal().getName() + " to "
                            + d.getTarget().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.isAvailability()) {
                    cells.add(getContentCell(new String[] { "availability",
                            "(" + d.getSourceGoal().getName() + "," + d.getAvailabilityValue() + "%)" }));

                    cells.add(getContentCell(d.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getSource().getName() + " require " + d.getTarget().getName()
                            + " to assure an availability level of " + d.getAvailabilityValue() + "% for goal "
                            + d.getSourceGoal().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Delegation d : act.getOutgoingDelegations()) {
            if (selActors.contains(d.getTarget())
                    && (d.getRepudiationType() != RepudiationType.NO_REPUDIATION || d.isTrustworthiness())) {

                if (d.getRepudiationType() == RepudiationType.DUAL_REPUDIATION
                        || d.getRepudiationType() == RepudiationType.DELEGATOR_REPUDIATION) {
                    cells.add(getContentCell(new String[] { "non-repudiation-of-delegation",
                            "(delegated(" + d.getSource().getName() + "," + d.getTarget().getName() + ","
                                    + d.getSourceGoal().getName() + "))" }));
                    cells.add(getContentCell(d.getTarget().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getTarget().getName() + " require non-repudiation-of-delegation for goal "
                            + d.getSourceGoal().getName() + ",");
                    sb.append("when delegated " + d.getSourceGoal().getName() + " by " + d.getSource().getName()
                            + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (d.isTrustworthiness()) {
                    cells.add(getContentCell(
                            new String[] { "trustworthiness", "(delegatedTo(" + d.getTarget().getName()
                                    + ", trustworthiness level: " + d.getTrustworthinessValue() + "))" }));

                    cells.add(getContentCell(d.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    sb.append(d.getSource().getName() + " will delegate to " + d.getTarget().getName()
                            + " that have trustwhorthiness level only grater than "
                            + d.getTrustworthinessValue());
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Provision p : act.getIncomingProvisions()) {
            if (selActors.contains(p.getTarget()) && (p.isAvailability())) {

                if (p.isAvailability()) {
                    cells.add(getContentCell(new String[] { "availability",
                            "(" + p.getSourceResource().getName() + "," + p.getAvailabilityValue() + "%)" }));

                    cells.add(getContentCell(p.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    sb.append(p.getSource().getName() + " require " + p.getTarget().getName()
                            + " to assure an availability level of " + p.getAvailabilityValue()
                            + "% for document " + p.getSourceResource().getName() + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Provision p : act.getOutgoingProvisions()) {
            if (selActors.contains(p.getTarget()) && (p.isIntegrity() || p.isConfidentiality())) {

                if (p.isIntegrity()) {
                    cells.add(
                            getContentCell(new String[] {
                                    "integrity", "(provided(" + p.getSource().getName() + ","
                                            + p.getTarget().getName() + "," + p.getSourceResource().getName(),
                                    "))" }));

                    cells.add(getContentCell(p.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    String a = p.getTarget().getName();
                    String b = p.getSource().getName();
                    String d = p.getSourceResource().getName();
                    sb.append(a + " requires " + b
                            + " to ensure integrity of transmission over the provision of document " + d
                            + ", when " + b + " provides " + d + " to " + a + ".");
                    cells.add(getContentCell(sb.toString()));
                }

                if (p.isConfidentiality()) {
                    cells.add(
                            getContentCell(new String[] {
                                    "confidentiality", "(provided(" + p.getSource().getName() + ","
                                            + p.getTarget().getName() + "," + p.getSourceResource().getName(),
                                    "))" }));

                    cells.add(getContentCell(p.getSource().getName()));
                    StringBuilder sb = new StringBuilder();
                    String a = p.getTarget().getName();
                    String b = p.getSource().getName();
                    String d = p.getSourceResource().getName();
                    sb.append(a + " requires " + b
                            + " to ensure confidentiality of transmission over the provision of document " + d
                            + ", when " + b + " provides " + d + " to " + a + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        for (Authorisation a : act.getIncomingAuthorisations()) {
            if (selActors.contains(a.getSource()) && a.getResources().size() > 0
                    && (a.isDistribution() || a.isModification() || a.isUsage() || a.isProduce())) {

                List<String> res = new ArrayList<String>();
                List<String> goal = new ArrayList<String>();
                for (IResource r : a.getResources()) {
                    res.add(r.getName());
                }
                for (Goal g : a.getGoals()) {
                    goal.add(g.getName());
                }

                if (!a.isUsage()) {
                    String s = "non-usage";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (!a.isModification()) {
                    String s = "non-modification";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (!a.isProduce()) {
                    String s = "non-production";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (!a.isDistribution()) {
                    String s = "non-disclosure";
                    cells.add(getContentCell(
                            new String[] { s, "(" + separateListOfString(res, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ".");
                    cells.add(getContentCell(sb.toString()));
                }
                if (a.getGoals().size() > 0) {
                    String s = "need-to-know";
                    cells.add(getContentCell(new String[] { s, "(" + separateListOfString(res, ",", ",") + ")",
                            "(" + separateListOfString(goal, ",", ",") + ")" }));
                    cells.add(getContentCell(a.getSource().getName()));

                    StringBuilder sb = new StringBuilder();
                    sb.append(a.getSource().getName() + " requires " + a.getTarget().getName() + " " + s
                            + " of Information ");
                    sb.append(separateListOfString(res) + ", in the scope of goal " + separateListOfString(goal)
                            + ".");
                    cells.add(getContentCell(sb.toString()));
                }
            }
        }

        PdfPCell respCell = getContentCell(act.getName());
        if (cells.size() > 0) {
            if (cells.size() >= 3) {
                respCell.setRowspan(cells.size() / 3);
            }
            table.addCell(respCell);
            for (PdfPCell c : cells) {
                table.addCell(c);
            }
        }
    }

    List<PdfPCell> cells = new ArrayList<PdfPCell>();
    for (Actor act : selActors) {

        if (act instanceof Role) {
            Role r = (Role) act;

            for (IncompatibleDuties id : r.getIncompatibleDutiesIn()) {
                cells.add(getContentCell(new String[] { "not-play-both", "(" + ((Role) id.getSource()).getName()
                        + "," + ((Role) id.getTarget()).getName() + ")" }));
                cells.add(getContentCell(
                        "Any agent that play " + r.getName() + " or " + ((Role) id.getSource()).getName()
                                + ", is required not to play (adopt) the other role too."));

            }
        }

        for (Goal g : act.getGoals()) {
            for (IncompatibleDuties id : g.getIncompatibleDutiesIn()) {
                cells.add(getContentCell(new String[] { "not-achieve-both",
                        "(" + g.getName() + "," + ((Goal) id.getSource()).getName() + ")" }));
                cells.add(getContentCell(
                        "Any agent that achieves " + g.getName() + " or " + ((Goal) id.getSource()).getName()
                                + ", is required not to achieve the other goal too."));

            }
            for (CompatibleDuties cd : g.getCompatibleDutiesIn()) {
                cells.add(getContentCell(new String[] { "achieve-in-combination",
                        "(" + g.getName() + "," + ((Goal) cd.getSource()).getName() + ")" }));
                cells.add(getContentCell("Any agent that achieves one of " + g.getName() + " or "
                        + ((Goal) cd.getSource()).getName() + ", is required to achieve the other goal too."));

            }
        }
        /*
         * for(Goal g:act.getGoals()){ for (IncompatibleDuties id :
         * g.getIncompatibleDutiesIn()) { cells.add(getContentCell(new
         * String[] {"achieves(a,"+g.getName()+")",
         * "then not achieve(a,"+((Goal)id.getSource()).getName()+")"}));
         * cells
         * .add(getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" not to achieve "+((Goal)id.getSource()).getName())); } for
         * (IncompatibleDuties id : g.getIncompatibleDutiesOut()) {
         * cells.add(getContentCell(new String[]
         * {"achieves(a,"+g.getName()+")",
         * "then not achieve(a,"+((Goal)id.getTarget()).getName()+")"}));
         * cells
         * .add(getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" not to achieve "+((Goal)id.getTarget()).getName())); }
         * 
         * for (CompatibleDuties cd : g.getCompatibleDutiesIn()) {
         * cells.add(getContentCell(new String[]
         * {"achieves(a,"+g.getName()+")",
         * "then achieve(a,"+((Goal)cd.getSource()).getName()+")"}));
         * cells.add
         * (getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" to achieve "+((Goal)cd.getSource()).getName()+" as well"));
         * } for (CompatibleDuties cd : g.getCompatibleDutiesOut()) {
         * cells.add(getContentCell(new String[]
         * {"achieves(a,"+g.getName()+")",
         * "then achieve(a,"+((Goal)cd.getTarget()).getName()+")"}));
         * cells.add
         * (getContentCell("Org requires any agent a that achieves "
         * +g.getName
         * ()+" to achieve "+((Goal)cd.getTarget()).getName()+" as well"));
         * } }
         */
    }
    PdfPCell respCell = getContentCell("\"Any agents\"");
    if (cells.size() > 0) {
        if (cells.size() >= 2) {
            respCell.setRowspan(cells.size() / 2);
        }
        table.addCell(respCell);
        for (int i = 0; i < cells.size(); i++) {
            table.addCell(cells.get(i));
            table.addCell(getContentCell("-"));
            table.addCell(cells.get(++i));
        }
    }

    addTableCaption(table, ftc.getTable(FigureConstant.COMM_TABLE) + " - Security Requirements for the "
            + getProjectName() + " Project");
    chapter.add(table);
    table.setComplete(true);

    boolean addAuthTable = false;

    // Chapter section = chapter;
    List<String[]> headers2 = new ArrayList<String[]>();
    headers2.add(new String[] { "Authorisor" });
    headers2.add(new String[] { "Information" });
    headers2.add(new String[] { "Goal" });
    headers2.add(new String[] { "Operation" });
    headers2.add(new String[] { "Authorisee" });
    headers2.add(new String[] { "Description" });
    PdfPTable table2 = createTable(headers2);

    for (Actor a : selActors) {

        List<Authorisation> validAuth = new ArrayList<Authorisation>();
        for (Authorisation au : a.getOutgoingAuthorisations()) {
            if (isValidAuth(au))
                validAuth.add(au);
        }

        if (validAuth.size() > 0) {
            addAuthTable = true;
            PdfPCell actorCell = getContentCell(a.getName());
            actorCell.setRowspan(validAuth.size());
            table2.addCell(actorCell);
            for (Authorisation au : validAuth) {

                Phrase p = null;
                for (int i = 0; i < au.getResources().size(); i++) {
                    if (i == 0)
                        p = new Phrase(au.getResources().get(i).getName(), TABLE_CONTENT_SMALL);
                    else {
                        p.add(Chunk.NEWLINE);
                        p.add(new Phrase(au.getResources().get(i).getName(), TABLE_CONTENT_SMALL));
                    }
                }

                /*
                 * com.itextpdf.text.List resList = new
                 * com.itextpdf.text.List(com.itextpdf.text.List.ORDERED,
                 * com.itextpdf.text.List.NUMERICAL); for (IResource r :
                 * au.getResources()) { ListItem listItem = new ListItem(new
                 * Phrase(r.getName(), TABLE_CONTENT));
                 * resList.add(listItem); }
                 */
                PdfPCell c = getContentCell();
                c.addElement(p);
                table2.addCell(c);
                // -------------------------------------//
                if (au.getGoals().size() > 0) {

                    Phrase p1 = null;
                    for (int i = 0; i < au.getGoals().size(); i++) {
                        if (i == 0)
                            p1 = new Phrase(au.getGoals().get(i).getName(), TABLE_CONTENT_SMALL);
                        else {
                            p1.add(Chunk.NEWLINE);
                            p1.add(new Phrase(au.getGoals().get(i).getName(), TABLE_CONTENT_SMALL));
                        }
                    }

                    /*
                     * com.itextpdf.text.List goalList = new
                     * com.itextpdf.text
                     * .List(com.itextpdf.text.List.ORDERED,
                     * com.itextpdf.text.List.NUMERICAL); for (Goal g :
                     * au.getGoals()) { ListItem listItem = new ListItem(new
                     * Phrase(g.getName(), TABLE_CONTENT));
                     * goalList.add(listItem); }
                     */
                    PdfPCell c1 = getContentCell();
                    c1.addElement(p1);
                    table2.addCell(c1);
                } else {
                    table2.addCell(getContentCell(""));
                }
                // -------------------------------------//
                table2.addCell(getContentCell(getOperationsTable(au)));

                // -------------------------------------//
                table2.addCell(getContentCell(au.getTarget().getName()));
                if (au.getTimesTransferable() == 0) {
                    table2.addCell(getContentCell("Non-transferable authority"));
                } else {
                    table2.addCell(getContentCell("Transferable authority"));
                }
            }
        }
    }
    if (addAuthTable) {
        chapter.add(createParagraph(""));
        chapter.add(createParagraph(
                ftc.getTable(FigureConstant.AUTH_TABLE) + " summarises the authorisations actors in the "
                        + getProjectName() + " project grant to one another."));
        chapter.add(table2);
        addTableCaption(table2, ftc.getTable(FigureConstant.AUTH_TABLE) + " - Authorisations in the "
                + getProjectName() + " project");
        table2.setComplete(true);
    }

}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

/******************************************************************************************/
private void buildAnalysisChapter(Chapter chapter, Document document) {

    chapter.setTitle(getChapterTitleParagraph("Analysis"));

    String chapterIntro = "";
    chapter.add(createParagraph(chapterIntro));

    if (generateConsistencyAnalysisSection()) {
        buildSectionConsistencyAnalysis(chapter.addSection(getSectionTitleParagraph("Consistency Analysis")),
                document);//  ww w .  j av  a 2  s .  c  om
    }
    if (generateSecurityAnalysisSection()) {
        buildSectionSecurityAnalysis(chapter.addSection(getSectionTitleParagraph("Security Analysis")));
    }
    if (generateRiskAnalysisSection()) {
        buildSectionRiskAnalysis(chapter.addSection(getSectionTitleParagraph("Threat Analysis")));
    }
    chapter.setTriggerNewPage(true);
    chapter.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

/******************************************************************************************/

private void buildAppendixAChapter(Chapter c, Document d) {

    c.setTitle(getChapterTitleParagraph("Appendix A"));
    c.setNumberDepth(0);//from   ww  w  .j a v a2s. c  o m
    c.setTriggerNewPage(true);

    float width = d.getPageSize().getWidth() - d.leftMargin() - d.rightMargin();
    float height = d.getPageSize().getHeight() - d.topMargin() - d.bottomMargin() - 70;

    if (needSocialDiagramInAppendixA()) {
        Image socialImage = rsp.generateScrenshot(ViewsManager.SOCIAL_VIEW);
        socialImage.setAlignment(Element.ALIGN_CENTER);
        if (socialImage.getPlainWidth() > socialImage.getPlainHeight()) {
            fitImageInArea(socialImage, height, width, true);
            socialImage.setRotationDegrees(90);
        } else {
            fitImageInArea(socialImage, width, height, true);
        }

        c.add(decorateImage(socialImage, ftc.getFigure(FigureConstant.SOCIAL_DIAGRAM)
                + " - Social View for the " + getProjectName() + " project"));
    }
    if (needInformationDiagramInAppendixA()) {
        Image informationImage = rsp.generateScrenshot(ViewsManager.RESOURCE_VIEW);
        informationImage.setAlignment(Element.ALIGN_CENTER);
        if (informationImage.getPlainWidth() > informationImage.getPlainHeight()) {
            fitImageInArea(informationImage, height, width, true);
            informationImage.setRotationDegrees(90);
        } else {
            fitImageInArea(informationImage, width, height, true);
        }
        // c.add(informationImage);
        c.add(decorateImage(informationImage, ftc.getFigure(FigureConstant.INFORMATION_DIAGRAM)
                + " - Information View for the " + getProjectName() + " project"));

    }
    if (needInformationDiagramInAppendixA()) {
        Image authorisationImage = rsp.generateScrenshot(ViewsManager.AUTHORIZATION_VIEW);
        authorisationImage.setAlignment(Element.ALIGN_CENTER);
        if (authorisationImage.getPlainWidth() > authorisationImage.getPlainHeight()) {
            fitImageInArea(authorisationImage, height, width, true);
            authorisationImage.setRotationDegrees(90);
        } else {
            fitImageInArea(authorisationImage, width, height, true);
        }
        // c.add(authorisationImage);
        c.add(decorateImage(authorisationImage, ftc.getFigure(FigureConstant.AUTH_DIAGRAM)
                + " - Authorisation View for the " + getProjectName() + " project"));

    }

    c.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildAppendixBChapter(Chapter c, Document d) {

    c.setTitle(getChapterTitleParagraph("Appendix B"));
    c.setNumberDepth(0);/*from  ww  w. j  a v a  2s.c o  m*/
    c.setTriggerNewPage(true);

    String sectionIntro = "Details of consistency analysis:";
    c.add(createParagraph(sectionIntro));

    List<Paragraph> plist = new ArrayList<Paragraph>();

    for (String aName : ConsistencyAnalysisTasksNames.ALL_TASKS_NAMES) {
        plist.add(getConsistencyAnalysisDescription(aName));
    }
    c.add(listParagraphs(plist));

    c.setComplete(true);
}