⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permisreadablepolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        if(doc != null){
            Element root = doc.getDocumentElement();
            String value = root.getAttribute("OID");
            String values = ResourceBundle.getBundle(
               "issrg/editor/gui/Editor_GUI_i18n").getString("pol_num_readable")
               + " [" + value+ "]\n";
            previewTextArea.append(values);
        }
    }
    

    private void subjectPolicy()
    {
        String[] subjectDetailsA;
        subjectDetailsA = 
        PermisPolicyEditorMenu.permisXmlDom.getAttributeValues(
                                        PermisSubjectPolicy.SUBJECT_DOMAIN_SPEC,
                                        PermisSubjectPolicy.ID);
        
        for (int i = 0; i < subjectDetailsA.length; i++) {
            String start = ResourceBundle.getBundle(
            "issrg/editor/gui/Editor_GUI_i18n").getString("pol_readable_sub")
            + " "+ getString(subjectDetailsA[i]) + " ";
                                
            String output =  PermisPolicyView.populateWindow( 
                                       subjectDetailsA[i],
                                       start,
                                       PermisSubjectPolicy.SUBJECT_DOMAIN_SPEC);
            output += "\n\n";
            previewTextArea.append(output);
        }
    
    }
    

    private void soaPolicy()
    {
        String[] soaDetailsA;		
        soaDetailsA = PermisPolicyEditorMenu.permisXmlDom.getAttributeValues(
                                                       PermisSoaPolicy.SOA_SPEC, 
                                                       PermisSoaPolicy.ID);
        
        for (int i = 0; i < soaDetailsA.length; i++) {
            String output =  ResourceBundle.getBundle(
            "issrg/editor/gui/Editor_GUI_i18n").getString("soa_pol_readable")
            + " " + getString(soaDetailsA[i])+ " " + 
            ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
            getString("soa_pol_readable1") + getString(PermisPolicyEditorMenu.
            permisXmlDom.getSoaValue(soaDetailsA[i]));
            output += "\n\n";
            previewTextArea.append(output);
        }
    }
    

    private void roleHiearchyPolicy()
    {
        readRolesPolicy("RoleSpec");
    }
    

    private void roleAssignmentPolicy()
    {
        String[] roleAssignmentId = PermisPolicyEditorMenu.permisXmlDom.
                                                             getAttributeValues(
                                                             "RoleAssignment", 
	                                                         "ID");
         for (int i = 0; i < roleAssignmentId.length; i++) {
             String output = ResourceBundle.getBundle(
                                        "issrg/editor/gui/Editor_GUI_i18n").
                                        getString("role_ass_pol_readable") + 
                                        getString(roleAssignmentId[i])+ " "+
                                        PermisPolicyEditorMenu.permisXmlDom.
                                        getRoleValues(roleAssignmentId[i])+ " ";
             output += "\n\n";
             previewTextArea.append(output);
         }
    }
    

    private void targetPolicy()
    {
        String[] targetDetailsA;
        targetDetailsA = 
                         PermisPolicyEditorMenu.permisXmlDom.getAttributeValues(
                         PermisTargetPolicy.TARGET_DOMAIN_SPEC,
                         PermisTargetPolicy.ID);
        
        for (int i = 0; i < targetDetailsA.length; i++) {
            String start =  ResourceBundle.getBundle(
                                           "issrg/editor/gui/Editor_GUI_i18n").
                                           getString("tar_pol_readable")+" "
                                          + getString( targetDetailsA[i]) + " ";  
                            
            String output =  PermisPolicyView.populateWindow( 
                                         targetDetailsA[i],
                                         start,
                                         PermisTargetPolicy.TARGET_DOMAIN_SPEC);
               output += "\n\n";
               previewTextArea.append(output);
                                                            
        }
    }


    private void actionPolicy()
    {
        String output ="";
        String start;
        String actionListArray[] = PermisPolicyEditorMenu.permisXmlDom.
                                                               getActionNames();
       
        
         previewTextArea.append( ResourceBundle.getBundle(
                                           "issrg/editor/gui/Editor_GUI_i18n").
                                           getString("act_pol_readable")+" ");
        for (int i = 0; i < actionListArray.length; i++) {
           output =  actionListArray[i];
            if (i == actionListArray.length -1){
                previewTextArea.append( ResourceBundle.getBundle(
                                     "issrg/editor/gui/Editor_GUI_i18n").
                                      getString("act_pol_readable_action")+" ");
                previewTextArea.append(getString(output));
            }
            else{
                previewTextArea.append( ResourceBundle.getBundle(
                                     "issrg/editor/gui/Editor_GUI_i18n").
                                      getString("act_pol_readable_action")+" ");
                   previewTextArea.append(getString(output)+ " " +
                  ResourceBundle.getBundle(
                                           "issrg/editor/gui/Editor_GUI_i18n").
                                           getString("and")+ " ");
            }
        }
         
         previewTextArea.append("\n");
    }
    

    private void targetAccessPolicy()
    {
        String[] targetAccessId = PermisPolicyEditorMenu.permisXmlDom.
                                             getAttributeValues( "TargetAccess", 
                                             PermisTargetAccessPolicy.ID);
       
        
        for (int i = 0; i < targetAccessId.length; i++) {
           String string = ResourceBundle.getBundle(
                                          "issrg/editor/gui/Editor_GUI_i18n").
                                          getString("tar_acc_pol_readable")+" ";
            
            StringBuffer targetValue = PermisPolicyEditorMenu.permisXmlDom.
                                       getTargetAccessValues(targetAccessId[i]);
            string = string + getString(targetAccessId[i])+" " 
            + ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                                  getString("tar_acc_pol_readable_grant") + " ";
            previewTextArea.append(string);
            String output = targetValue.toString();
            output += "\n\n";
            previewTextArea.append(output);
        }
    }
    

    private void addSeparationLine()
    {
        
        for (int i = 0; i < 119; i++){
        previewTextArea.append("-");
        }
        previewTextArea.append("\n\n");
    }
    

    
    private void readRolesPolicy(String parent)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
        
        if(doc != null){
            Element parentElement = null;
            Element elem = null;
            String value = null;
            String roleValue = "";
            String roleName = "";
            String roles = "";
            String otherRoles ="";
            String tempValue = "";
            String supRoles ="";
            String subRole = ResourceBundle.getBundle(
                                            "issrg/editor/gui/Editor_GUI_i18n").
                                             getString("role_hie_readable_sub");
            String supString = ResourceBundle.getBundle(
                                            "issrg/editor/gui/Editor_GUI_i18n").
                                             getString("role_hie_readable_sup");
          
           
           String roleStatment = ResourceBundle.getBundle(
                                          "issrg/editor/gui/Editor_GUI_i18n").
                                          getString("role_hie_readable") + "\n";
           Element root = doc.getDocumentElement();
           NodeList list = root.getElementsByTagName("*");
           
           for (int i = 0; i < list.getLength(); i++) {
               
               if (list.item(i).getNodeName() == parent) {
                   parentElement = (Element) list.item(i);
                   value = parentElement.getAttribute("OID");
                   /* Compare the attribute value with idValue, this ensures
                    * that child nodes are under the correct parent
                    */
                   if(value.equals("1.2.826.0.1.3344810.1.1.14")) {
                       break;
                   }
               }
           }
           
           // Get the childnodes of the parent Node
           NodeList childList = parentElement.getChildNodes();
           
           for (int k = 0; k < childList.getLength(); k++){
             if (childList.item(k).getNodeType()!=Node.ELEMENT_NODE) continue;
               elem = (Element)childList.item(k);
               
               if(elem.hasChildNodes()){
                   String elemName = elem.getAttribute("Value");
                   roleValue = elemName;
                   NodeList elemList = elem.getChildNodes();
                   String roleNames ="";
                   roleName="";
                   
                   for (int j =0; j<elemList.getLength(); j++){
                     if (elemList.item(j).getNodeType()!=Node.ELEMENT_NODE) continue;
                       Element subElem = (Element)elemList.item(j);
                       roleNames = subElem.getAttribute("Value");
                       
                       if (j == elemList.getLength()-1) {
                           roleName += roleNames  ;
                       }
                       else {
                           roleName += roleNames + ",";
                       }
                   } 
                   
                   if (k == childList.getLength()-1){
                       supRoles +=  elemName;
                       roles += " " + supString + " " + getString(roleValue)+" "
                       +subRole+" " +getString(roleName);
                   }
                   else{
                       supRoles +=  elemName + ",";
                       roles += " " + supString +" " +getString(roleValue)+" "
                       +subRole+" " +getString(roleName);
                   }
               }
               else{
                   otherRoles = elem.getAttribute("Value");
                   tempValue += "," + otherRoles;
               }
           }
           tempValue =  getString(supRoles +tempValue);
           String subString = roleStatment + tempValue +roles;
           
           subString = subString.replaceAll(",,", ",");
           previewTextArea.append(subString + "\n\n"); 
        }
    }
    private String getString(String string)
    {
        if(string.indexOf(",", 0) == 0){
            string = string.substring(1, string.length());
            return "[" + string + "]";
        }
        return "[" + string + "]";
    }
    public void comboBoxSetSelectedIndex(int i)
    {
        textViewComboBox.setSelectedIndex(i);
       
    }
    public void refreshReadablePoliyTextArea()
    {
        previewTextArea.setText("");
        if (textViewComboBox.getItemCount() != 0) {
            
            if ( textViewComboBox.getSelectedIndex() != -1){
                int item = textViewComboBox.getSelectedIndex();
                switch (item) {
                    case 0 :
                        completePolicy();
                        break;
                    case 1:
                        policyNumber();
                        break;
                    case 2:
                        subjectPolicy();
                        break;
                    case 3:
                        soaPolicy();
                        break;
                    case 4:
                        roleHiearchyPolicy();
                        break;
                    case 5:
                        roleAssignmentPolicy();
                        break;
                    case 6:
                        targetPolicy();
                        break;
                    case 7:
                         targetAccessPolicy();
                        break;
                    case 8:
                        actionPolicy();
                        break;
                    default:
                }
            }
         }
    }

  public void actionPerformed(ActionEvent event){
    String command = event.getActionCommand().intern();
    if (command==PRINT_ACTION){
      textPreviewPrintButtonActionPerformed();
    }else if (command==EDIT_ACTION){
      textPreviewEditButtonActionPerformed();
    }else if (command==CLOSE_ACTION){
      textPreviewCloseButtonActionPerformed();
    }else if (command==VIEW_ACTION){
      textViewComboBoxActionPerformed();   
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -