public String conflict_Analysis_English(Frame frame) { // TODO冲突分析,结果写入冲突报告 CndPolicy policy1 = null, policy2 = null; Result result = new Result(); int numberOfPolicy = policyDAO.getPolicyAmount(); StringBuffer strTotal = new StringBuffer(); int policyAmount = numberOfPolicy; int conflictAmount = 0; int unralation = 0; int syntaxConflict = 0; int inclusiveConflict = 0; int partialConflict = 0; for (int i = 1; i < numberOfPolicy; i++) { for (int j = i + 1; j <= numberOfPolicy; j++) { policy1 = policyDAO.getOnePolicy(i); policy2 = policyDAO.getOnePolicy(j); String str = null; String str_Policy1 = "policy" + policy1.getPolicyId(); String str_Policy2 = "policy" + policy2.getPolicyId(); if (policyDAO .getMeasureElementDenyList(policy1.getMeasure()) .contains(policy2.getMeasure())) { if (judge_Relation_Policy(policy1, policy2) == 0) { str = "No conflict"; unralation++; } if (judge_Relation_Policy(policy1, policy2) == 1) { str = "Grammar Conflict"; StringBuffer strSyntax = new StringBuffer(); strSyntax.append("\n"); strSyntax.append("Conflict policy:"); strSyntax.append("\n"); strSyntax.append(str_Policy1 + " " + str_Policy2); strSyntax.append("\n"); strSyntax.append("Conflict Position:"); strSyntax.append("\n"); strSyntax.append("all policy elements"); strSyntax.append("\n"); strSyntax.append("Conflict Reason:"); strSyntax.append("\n"); strSyntax.append("systax conflict"); str = str + strSyntax.toString(); syntaxConflict++; } if (judge_Relation_Policy(policy1, policy2) == 2) { str = "Inclusion Conflict"; StringBuffer strSyntax = new StringBuffer(); strSyntax.append("\n"); strSyntax.append("Conflict Policy:"); strSyntax.append("\n"); strSyntax.append(str_Policy1 + " " + str_Policy2); strSyntax.append("\n"); strSyntax.append("Conflict Position:"); strSyntax.append("\n"); strSyntax.append("all policy elements"); strSyntax.append("\n"); strSyntax.append("Conflict Reason:"); strSyntax.append("\n"); strSyntax.append("inclusive conflict"); str = str + strSyntax.toString(); inclusiveConflict++; } if (judge_Relation_Policy(policy1, policy2) == 3) { str = "Revelant Conflict"; partialConflict++; StringBuffer strTemp = new StringBuffer(); strTemp.append("\n"); strTemp.append("Conflict Policy:"); strTemp.append("\n"); strTemp.append(str_Policy1 + " " + str_Policy2); strTemp.append("\n"); strTemp.append("Conflict Position & Reason:"); if (elementRelation.judge_Relation_Context(policy1.getContext(), policy2.getContext()) == 1) { strTemp.append("Context have overlapped"); strTemp.append(","); // strTemp.append("\n"); } if (elementRelation.judge_Relation_Role(policy1.getRole(), policy2.getRole()) == 1) { strTemp.append("Role have overlapped"); strTemp.append(","); // strTemp.append("\n"); } if (elementRelation.judge_Relation_View(policy1.getView(), policy2.getView()) == 1) { strTemp.append("View have overlapped"); strTemp.append(","); // strTemp.append("\n"); } if (elementRelation.judge_Relation_Activity( policy1.getActivity(), policy2.getActivity()) == 1) { strTemp.append("Activity have overlapped"); strTemp.append(","); // strTemp.append("\n"); } str = str + strTemp.toString(); } } else { str = "No conflict"; unralation++; } StringBuffer strBuffer = new StringBuffer(); strBuffer.append(str_Policy1); strBuffer.append(" and "); strBuffer.append(str_Policy2); strBuffer.append(" exsit "); strBuffer.append(str); // frame.getJTextArea().setText(strBuffer.toString()); System.out.println(strBuffer.toString()); strTotal.append(strBuffer.toString()); strTotal.append("\n"); } } conflictAmount = syntaxConflict + inclusiveConflict + partialConflict; result.setPolicyAmount(policyAmount); result.setConflictAmount(conflictAmount); result.setUnrelation(unralation); result.setSyntaxconflict(syntaxConflict); result.setInclusivematch(inclusiveConflict); result.setPartialmatch(partialConflict); // 如果策略数量相同则不添加新数据 if (!policyDAO.getPolicyAmountList().contains(policyAmount)) { policyDAO.addResult(result); } frame.getMessageArea().setText(strTotal.toString()); return strTotal.toString(); }
public String conflict_Analysis_English(Frame frame, String dataBase) { CndPolicy policy1 = null, policy2 = null; Result result = new Result(); int numberOfPolicy = policyDAO.getPolicyAmount(); StringBuffer strTotal = new StringBuffer(); int policyAmount = numberOfPolicy; int conflictAmount = 0; int unralation = 0; int syntaxConflict = 0; int inclusiveConflict = 0; int partialConflict = 0; for (int i = 1; i < numberOfPolicy; i++) { for (int j = i + 1; j <= numberOfPolicy; j++) { policy1 = policyDAO.getOnePolicy(i); policy2 = policyDAO.getOnePolicy(j); String str = null; String str_Policy1 = "policy" + policy1.getPolicyId(); String str_Policy2 = "policy" + policy2.getPolicyId(); if (!(policy1.getMeasure().equals(policy2.getMeasure()))) { if (judge_Relation_Policy(policy1, policy2, dataBase) == 0) { str = "No conflict"; unralation++; } else { /* * if (judge_Relation_Policy(policy1, policy2, dataBase) * == 1) { str = "语法冲突"; StringBuffer strSyntax = new * StringBuffer(); strSyntax.append("\n"); * strSyntax.append("冲突对象:"); strSyntax.append("\n"); * strSyntax.append(str_Policy1 + " " + str_Policy2); * strSyntax.append("\n"); strSyntax.append("冲突位置:"); * strSyntax.append("\n"); * strSyntax.append("all policy elements"); * strSyntax.append("\n"); strSyntax.append("冲突原因:"); * strSyntax.append("\n"); * strSyntax.append("systax conflict"); str = str + * strSyntax.toString(); syntaxConflict++; } */ if (judge_Relation_Policy(policy1, policy2, dataBase) == 2) { str = "Inclusion Conflict"; StringBuffer strSyntax = new StringBuffer(); strSyntax.append("\n"); strSyntax.append("Conflict Policy:"); strSyntax.append("\n"); strSyntax.append(str_Policy1 + " " + str_Policy2); strSyntax.append("\n"); strSyntax.append("Conflict Position:"); strSyntax.append("\n"); strSyntax.append( str_Policy1 + "_" + policy1.getRole() + " have conflict with " + str_Policy2 + "_" + policy2.getRole() + " to folder " + policy1.getOrganization() + "\\" + policy1.getContext() + "\\" + policy1.getView() + " with action of " + this.fileActPos + ""); strSyntax.append("\n"); strSyntax.append("Conflict Reason:"); strSyntax.append("\n"); if (0 == this.getFileRoleInc()) { strSyntax.append( str_Policy2 + "'s role " + policy2.getRole() + " inherits " + str_Policy1 + "'s role " + policy1.getRole()); } else if (1 == this.getFileRoleInc()) { strSyntax.append( str_Policy1 + "'s role " + policy1.getRole() + " inherits " + str_Policy2 + "'s role" + policy2.getRole()); } else if (3 == this.getFileRoleInc()) { } else { strSyntax.append( str_Policy1 + "'s role " + policy1.getRole() + " is the same with " + str_Policy2 + "'s role " + policy2.getRole() + ""); } strSyntax.append("\n"); strSyntax.append( str_Policy1 + "'s activity " + policy1.getActivity() + " and " + str_Policy2 + " 's activity " + policy2.getActivity() + " have contain relation " + "(" + this.fileActPos + ")"); strSyntax.append("\n"); if (0 == this.getFileActInc()) { strSyntax.append( str_Policy1 + "'s activity " + policy1.getActivity() + " contains " + str_Policy2 + "'s activity"); } else if (1 == this.getFileActInc()) { strSyntax.append( str_Policy1 + "'s activity " + policy1.getActivity() + "is contained within " + str_Policy2 + "'s activity"); } else if (3 == this.getFileActInc()) { } else { strSyntax.append( str_Policy1 + "'s activity " + policy1.getActivity() + " is the same with " + str_Policy2 + "'s activity"); } strSyntax.append("\n"); str = str + strSyntax.toString(); inclusiveConflict++; } if (judge_Relation_Policy(policy1, policy2, dataBase) == 3) { str = "Relevant Conflict"; partialConflict++; StringBuffer strTemp = new StringBuffer(); strTemp.append("\n"); strTemp.append("Conflict Policy:"); strTemp.append("\n"); strTemp.append(str_Policy1 + " " + str_Policy2); strTemp.append("\n"); strTemp.append("Conflict Position:"); strTemp.append("\n"); strTemp.append( str_Policy1 + "_" + policy1.getRole() + " have conflict with " + str_Policy2 + "_" + policy2.getRole() + " to folder " + policy1.getOrganization() + "\\" + policy1.getContext() + "\\" + policy1.getView() + " with action of " + this.fileActPos + ""); strTemp.append("\n"); strTemp.append("Conflict Reason:"); strTemp.append("\n"); if (0 == this.getFileRoleInc()) { strTemp.append( str_Policy2 + "'s role " + policy2.getRole() + " inherits " + str_Policy1 + "'s role " + policy1.getRole()); } else if (1 == this.getFileRoleInc()) { strTemp.append( str_Policy1 + "'s role " + policy1.getRole() + " inherits " + str_Policy2 + "'s role " + policy2.getRole()); } else if (3 == this.getFileRoleInc()) { strTemp.append( str_Policy1 + "'s group " + policy1.getRole() + " and " + str_Policy2 + "'s group " + policy2.getRole() + " have the same user"); } else { strTemp.append( str_Policy1 + "'s role " + policy1.getRole() + " is the same with " + str_Policy2 + "'s role " + policy2.getRole() + ""); } strTemp.append("\n"); strTemp.append( str_Policy1 + "'s activity " + policy1.getActivity() + " and " + str_Policy2 + "'s activity " + policy2.getActivity() + " have contain relation " + "(" + this.fileActPos + ")"); strTemp.append("\n"); // strTemp.append("\n"); str = str + strTemp.toString(); } StringBuffer strBuffer = new StringBuffer(); strBuffer.append(str_Policy1); strBuffer.append(" and "); strBuffer.append(str_Policy2); strBuffer.append(" exsit "); strBuffer.append(str); // frame.getJTextArea().setText(strBuffer.toString()); System.out.println(strBuffer.toString()); strTotal.append(strBuffer.toString()); strTotal.append("\n"); } } } } conflictAmount = syntaxConflict + inclusiveConflict + partialConflict; result.setPolicyAmount(policyAmount); result.setConflictAmount(conflictAmount); result.setUnrelation(unralation); // result.setSyntaxconflict(syntaxConflict); result.setInclusivematch(inclusiveConflict); result.setPartialmatch(partialConflict); // 如果策略数量相同则不添加新数据 if (!policyDAO.getPolicyAmountList().contains(policyAmount)) { policyDAO.addResult(result); } frame.getMessageArea().setText(strTotal.toString()); return strTotal.toString(); }