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

📄 permispolicyloader.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                     * that child nodes are under the correct parent
                     */
                    if(value.equals(compare)) {
                        
                        break;
                    }
                }
            }
            targetRoleListModel.clear();
            targetActionListModel.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 name = elem.getNodeName();
                    
                    if (name.equals("RoleList")){
                        NodeList elemList = elem.getChildNodes();
                        
                        for ( int j = 0; j< elemList.getLength(); j++){
                            if (elemList.item(j).getNodeType()!=Node.ELEMENT_NODE) continue;
                            Element child = (Element)elemList.item(j);
                            String roleName = child.getAttribute("Value");
                            
                           targetRoleListModel.addElement(roleName);
                        }
                    }
                    
                    else if (name.equals("TargetList")){
                      NodeList nodeList = elem.getChildNodes();
                      for (int t = 0; t < nodeList.getLength(); t++){
                        if (nodeList.item(t).getNodeType()!=Node.ELEMENT_NODE) continue;
                        Element nextNode = (Element)nodeList.item(t);
                            if (nextNode.hasAttributes()){
                              String roleName = nextNode.getAttribute("Actions"); 
                       
                              String [] roleString = roleName.split(",");
                            
                              for (int i = 0; i < roleString.length; i++){
                               
                                targetActionListModel.addElement(roleString[i]);
                              }
                            }
                            
                        // this loop did not exist; instead Uche always retrieved the first child node. Why? what is this mysterious node?
                        Element nodeName = null;
                        NodeList nl = nextNode.getChildNodes();
                        for (int ii=0; ii<nl.getLength(); ii++){
                          if (nl.item(ii).getNodeType()!=Node.ELEMENT_NODE) continue;
                          nodeName = (Element)nl.item(ii);
                          break;
                        }
                        String idValue = nodeName.getAttribute("ID");   
                        targetDomainComboBox.setSelectedItem(idValue);
                      }
                    }
            }
        }
    }

   public void populateTargetAcessActionComboBox(JComboBox targetActionComboBox)
   {
       String actionListArray[] = PermisPolicyEditorMenu.permisXmlDom.
                                                               getActionNames();
       targetActionComboBox.removeAllItems();
        
        for (int i = 0; i < actionListArray.length; i++) {
           targetActionComboBox.addItem(actionListArray[i]);
        }
       
   }
   
   public void refreshSoaTree(JTree tree, String parent)
   {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
         Include= null;
        //check that the doc exists
        if(doc != null){
            Element parentElement = null;
            Element elem = null;
            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);
                   
                    
                    /* Compare the attribute value with idValue, this ensures
                     * that child nodes are under the correct parent
                     */
                    //if(value.equals(compare)) {
                        break;
                    //}
                }
            }
            // Gets the model of the tree
            // treeModel = null;
            treeModel = (DefaultTreeModel)tree.getModel();
            top =  (DefaultMutableTreeNode)treeModel.getRoot();
            
            // If there are children remove and reload
            top.removeAllChildren();
            treeModel.reload();
             //listModel.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);
               
                NodeList includeChildren = elem.getChildNodes();
                String value = elem.getAttribute("ID");
                String ldapName = elem.getAttribute("LDAPDN");
               
                String nodeName =  value + ":" + ldapName;
                Include =  new DefaultMutableTreeNode(nodeName, true);
                treeModel.insertNodeInto(Include,top,  top.getChildCount()); 
                tree.scrollPathToVisible(new TreePath(Include.getPath()));
              
                }
            }
       
   }
   public boolean isRole( String parent,
                          String roleString)
        {
        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) {
                    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);
                String roleName = elem.getAttribute("Value");
                 
                if(roleName.equals(roleString)){
                     return true;
                }
            }
        }
        return false;
   }

   
   public String getString(String string)
   {
       return "[" + string + "]";
   }
   
     
    public String populateRolePolicy(String roleString)
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
         String stringValue="";
         String parent = "RoleSpec";
         boolean haschildren = false;
        if(doc != null){
            Element parentElement = null;
            Element elem = null;
            String value = null;
            String roleName = "";
            String roles = "";
           
          
            String subRoleStatement = ResourceBundle.getBundle(
                                            "issrg/editor/gui/Editor_GUI_i18n").
                                             getString("role_hie_readable_sub");
            String supRoleStatement = ResourceBundle.getBundle(
                                            "issrg/editor/gui/Editor_GUI_i18n").
                                             getString("role_hie_sup_role");
          
           
           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();
           String elemName = "";
           String s ="";
           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()){
                   elemName = elem.getAttribute("Value");
                   if(roleString.equals(elemName)){
                  
                  haschildren = true;
                       break;
                   }
               }
               else {
                  
                  s = elemName = elem.getAttribute("Value");
                   if(roleString.equals(s)){
                        
                       break;
                      
                   }
                   
               }
           }
           String roleNames ="";
           if (haschildren){
           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);
                       roleNames = subElem.getAttribute("Value");
                       
                       if (j == elemList.getLength()-1) {
                           roleName += roleNames  ;
                       }
                       else {
                           roleName += roleNames + ",";
                       }
                      
                   } 
                //return collection of children
           return  supRoleStatement +" " +getString(roleString) +" "+ 
                                     subRoleStatement + " "+getString(roleName);
           }
           else{
               //role value has no children
                s = elemName = elem.getAttribute("Value");
                return  supRoleStatement + " " + getString(s)+ " " + 
                subRoleStatement + " " + getString("none");
               
           }
                  
           }
       return getString("none"); 
    }
}

⌨️ 快捷键说明

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