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

📄 permispolicyloader.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        if(doc != null){
            
            Element parentElement = null;
            Element elem = null;
            String value = null;
            Element root = doc.getDocumentElement();
            NodeList list = root.getElementsByTagName("*");
            
            for (int i = 0; i < list.getLength(); i++) {
                if (list.item(i).getNodeName() == parent) {
                    if (list.item(i).getNodeType()!=Node.ELEMENT_NODE) continue;
                    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;
                    }
                }
            }
             if ((viewRoleListModel != null) ||( availableRoleListModel != null)){
             viewRoleListModel.clear();
             availableRoleListModel.clear();
             }
             if ( supRoleComboBox != null){
             supRoleComboBox.removeAllItems();
             }
             roleViewComboBox.removeAllItems();
            // 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);
               
                
                 String roleName = elem.getAttribute("Value");
                 if ((viewRoleListModel != null) ||( availableRoleListModel != null)){
                 viewRoleListModel.addElement(roleName);
                 availableRoleListModel.addElement(roleName);
                  if ( supRoleComboBox != null){
                 supRoleComboBox.addItem(roleName);
                  }
                 roleViewComboBox.addItem(roleName);
                 }
                 else{
                      if ( supRoleComboBox != null){
                     supRoleComboBox.addItem(roleName);
                      }
                     roleViewComboBox.addItem(roleName);
                 }
            
        }
        
    }
    }
     public void populateRolesPolicy( DefaultListModel subRoleListModel,
                                      String parent,
                                      String compare)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
        if(doc != null){
            
            Element parentElement = null;
            Element elem = null;
            String value = null;
            Element root = doc.getDocumentElement();
            NodeList list = root.getElementsByTagName("*");
            
            for (int i = 0; i < list.getLength(); i++) {
                if (list.item(i).getNodeName() == parent) {
                    if (list.item(i).getNodeType()!=Node.ELEMENT_NODE) continue;
                    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;
                    }
                }
            }
             
           subRoleListModel.clear();
            
            // 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);
                 
                     String elemName = elem.getAttribute("Value");
                     if(elemName.equals(compare)){
                       break;
                     }
            }
            NodeList elemList = elem.getChildNodes();
                   
            for (int j =0; j<elemList.getLength(); j++){
              if (elemList.item(j).getNodeType()!=Node.ELEMENT_NODE) continue;

              Element subElem = (Element)elemList.item(j);
              String roleName = subElem.getAttribute("Value");
              subRoleListModel.addElement(roleName);  
            }
        }
                  
                 
}
           
   public void readAssignmentPolicy( DefaultListModel roleListModel,
                                     JComboBox subjectComboBox,
                                     JComboBox soaComboBox,
                                     String compare,
                                     String parent,
                                     JCheckBox check,
                                     JCheckBox unlimited,
                                     JTextField depth)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
        if(doc != null){
            
            Element parentElement = null;
            Element elem = null;
            String value = null;
            Element root = doc.getDocumentElement();
            NodeList list = root.getElementsByTagName("*");
            
            for (int i = 0; i < list.getLength(); i++) {
                if (list.item(i).getNodeName() == parent) {
                    if (list.item(i).getNodeType()!=Node.ELEMENT_NODE) continue;
                    parentElement = (Element) list.item(i);
                    value = parentElement.getAttribute("ID");
                    
                    /* Compare the attribute value with idValue, this ensures
                     * that child nodes are under the correct parent
                     */
                    if(value.equals(compare)) {
                        break;
                    }
                }
            }
             roleListModel.clear();
             //soaComboBox.removeAllItems();
             //subjectComboBox.removeAllItems();
            // 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 name = elem.getNodeName();
                     if (name.equals("SOA")){
                      String roleName = elem.getAttribute("ID");
                      soaComboBox.setSelectedItem(roleName);  
                     }
                     else if (name.equals("SubjectDomain")) {
                        String roleName = elem.getAttribute("ID"); 
                        subjectComboBox.setSelectedItem(roleName);
                     } else if (name.equals("Delegate")) {
                         String Depth = elem.getAttribute("Depth");                         
                         if (Depth.equals("")) {                             
                             unlimited.setEnabled(true);
                             unlimited.setSelected(true);
                             unlimited.setBackground(Color.white);
                             check.setEnabled(true);
                             check.setSelected(true);
                             depth.setText("1");
                             depth.setEnabled(false);
                             depth.setEditable(false);
                             
                         } else if (!Depth.equals("0")){
                             unlimited.setEnabled(true);
                             unlimited.setSelected(false);
                             unlimited.setBackground(Color.white);
                             check.setEnabled(true);
                             check.setSelected(true);
                             depth.setEditable(true);
                             depth.setEnabled(true);
                             depth.setText(Depth);
                         } else {
                             unlimited.setEnabled(false);
                             unlimited.setSelected(false);                                     
                             check.setEnabled(true);
                             check.setSelected(false);
                             depth.setText("1");
                             depth.setEnabled(false);
                             depth.setEditable(false);
                             
                         }
                     }
                  
                  
                }
                 else{
                     NodeList elemList = elem.getChildNodes();
                     for ( int j =0; j < elemList.getLength(); j++){
                         if (elemList.item(j).getNodeType()!=Node.ELEMENT_NODE) continue;
                         Element elems = (Element)elemList.item(j);
                         String objectName = elems.getAttribute("Value");
                         roleListModel.addElement(objectName);
                     }
                 }
            }
        }
   }          
        
      
    public boolean isID( String nodeName,
                         String nodeValue)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
        if(doc == null){
            return false;
        }
        String NAME = "Name";
        String ID = "ID";
        // Get root of the Dom
        Element root = doc.getDocumentElement();
        // Create list of the required nodes
        NodeList elementList = root.getElementsByTagName(nodeName);
        String s = null;
        
        // check for the node and assign its attribute name
        if (nodeName.equals("Action")){
            s = NAME;
        }
        else{
            s = ID;
        }
        
        //Get the relevant attribute value for each element
        for (int i = 0; i < elementList.getLength(); i ++) {
            if (elementList.item(i).getNodeType()!=Node.ELEMENT_NODE) continue;
            Element elementA = (Element) elementList.item(i);
            // Find the required element
            if (nodeValue.equals(elementA.getAttribute(s))) {
               
                return true;
            }
        }   
        
        return false;
    }
    
    public void readPolicyNumber(JTextField textField)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
        if(doc != null){
        Element root = doc.getDocumentElement();
        String value = root.getAttribute("OID");
        textField.setText(value);
        }
    }
    
    public void readTargetAccessPolicy( DefaultListModel targetRoleListModel,
                                 DefaultListModel targetActionListModel, 
                                 JComboBox targetDomainComboBox,
                                 String parent,
                                 String compare)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
       
        if(doc != null){
            Element parentElement = null;
            Element elem = null;
            String value = null;
            Element root = doc.getDocumentElement();
            NodeList list = root.getElementsByTagName("*");
            
            for (int i = 0; i < list.getLength(); i++) {
                if (list.item(i).getNodeName() == parent) {
                    if (list.item(i).getNodeType()!=Node.ELEMENT_NODE) continue;
                    parentElement = (Element) list.item(i);
                    value = parentElement.getAttribute("ID");
                    
                    /* Compare the attribute value with idValue, this ensures

⌨️ 快捷键说明

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