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

📄 permistargetpolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    return;
                }
                 else if(!validateURI(urlTextField.getText().trim())){
                     urlTextField.requestFocus();
                     return;
                        
                    }
                 PermisPolicyEditorMenu.permisXmlDom.addDomAttr(
                                                   "TargetPolicy", 
                                                   TARGET_DOMAIN_SPEC, 
                                                   ID, 
                                                   targetIdTextField.getText());
                PermisPolicyEditorMenu.permisXmlDom.addUrl(
                                                  urlTextField.getText().trim(),
                                                  TARGET_DOMAIN_SPEC,
                                                   targetIdTextField.getText());
            }
            else{*/
                 //check that the Tree has children
            DefaultTreeModel treeModel = (DefaultTreeModel)targetTree.
                                                                     getModel();
            DefaultMutableTreeNode top = (DefaultMutableTreeNode)treeModel.
                                                                      getRoot();
            if (top.getChildCount() < 1) {
                PermisPolicyEditorMenu.dialog.showOkDialog(                                                 
                         ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("sub_pol_err_msg_c") + 
                         "\n" +
                         ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("sub_pol_msg_warn_b")); 
                return;
            }
             PermisPolicyEditorMenu.permisXmlDom.addDomAttr(
                                                   "TargetPolicy", 
                                                   TARGET_DOMAIN_SPEC, 
                                                   ID, 
                                                   targetIdTextField.getText());
             
            PermisPolicyEditorMenu.permisXmlDom.addDomFromTree(
                                                   targetTree, 
                                                   TARGET_DOMAIN_SPEC, 
                                                   targetIdTextField.getText());
            }
            PermisPolicyEditorMenu.permisXmlDom.addObjectClassFromList(
                                                    targetObjectClassListModel, 
                                                    targetIdTextField.getText(), 
                                                    TARGET_DOMAIN_SPEC, 
                                                    "ObjectClass");
            PermisPolicyEditorMenu.permisXmlDom.showMessage();
            String button = "targetAccessButton";
            parent.controlButton( button, true);
           //refresh the ReadablePolicy view
            if(parent.getPermisParent().getMenuItems().
                                                   getReadablePolicy() != null){
                    parent.getPermisParent().getMenuItems().getReadablePolicy().
                                                   comboBoxSetSelectedIndex(6);
            } 
        //}
       clearBoxes();
       parent.putIdHashtable(targetIdTextField.getText());
       highLighter(targetIdTextField);
       targetIdTextField.requestFocus();
        performRefresh();
        targetInternalFrame.setVisible(false);
    }
        
    
    /**
     * Deletes the selected node from the Target Policy JTree
     *
     * @param evt       Create/Modify delete button operated
     */
    
    private void targetDeleteButtonActionPerformed()
    {
        permisTargetPolicy.removeCurrentNode();
        boolean b = !permisTargetPolicy.isTreeEmpty(targetTree);
        targetDeleteButton.setEnabled(b);
        targetExcludeButton.setEnabled(b);
    }
        
    
    /**
     * Adds the entered data as an exclude node under the selected include node
     * of the Target Policy JTree/DefaultTreeModel.
     *
     * @param evt       Exclude button operated.
     */
    
    private void targetExcludeButtonActionPerformed()
    {
      boolean useDN = targetDnTextField.isEnabled();
      String uri = (useDN?targetDnTextField:urlTextField).getText().trim();

        if (uri.equals("")){
           PermisPolicyEditorMenu.dialog.showOkDialog(
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_err_msg_ldapdn") );
            return;
        }
      if (!useDN) uri="URL:"+uri;

             if(permisTargetPolicy.excludeNodeAlredayExist(targetTree,
                               uri)){
                   PermisPolicyEditorMenu.dialog.showOkDialog(
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_err_msg_c") +  "\n" +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_msg_dn_subtree") +" " +
                   getString(targetDnTextField.getText()) + " "+ 
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_msg_dn_exist")); 
            }else{
              String s = getSelectedInclude();
              if (s==null) return; // silently exit - perhaps, should complain

              s=s.trim();  
              if(validateExcludeNode(uri, s) && 
                permisTargetPolicy.excludeNode(uri)){
                  if (useDN) targetDnTextField.setText("");
                  else urlTextField.setText("");
               };
            
            }
    
       if (useDN) targetDnTextField.requestFocus();
       else urlTextField.requestFocus();
    }
        
    
    /**
     * Adds the entered data as an include node under the root node of the  
     * Target Policy JTree/DefaultTreeModel.
     *
     * @param evt       Include button operated.
     */
    
    private void targetIncludeButtonActionPerformed()
    {
      boolean useDN = targetDnTextField.isEnabled();
      String uri = (useDN?targetDnTextField:urlTextField).getText().trim();

         if (uri.equals("")){
             
             //System.out.println("empty field code called");
           PermisPolicyEditorMenu.dialog.showOkDialog(
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_err_msg_ldapdn") );
            return;
        }

        if (!useDN) uri="URL:"+uri;

         if(permisTargetPolicy.includeNodeAlreadyExist(targetTree,
                   uri)){
                      // System.out.println("already in tree code called");
                   PermisPolicyEditorMenu.dialog.showOkDialog(
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_err_msg_c") +  "\n" +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_msg_dn_subtree") +" " +
                   getString(uri) + " "+ 
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_msg_dn_exist")); 
        }else{
          if (!useDN && !validateURI(urlTextField.getText().trim())){
            urlTextField.requestFocus();
            return;
          }

          permisTargetPolicy.includeNode( targetTree, uri);

          targetDeleteButton.setEnabled(true);
          targetExcludeButton.setEnabled(true);
          if (useDN) targetDnTextField.setText("");
          else urlTextField.setText("");
       }

       if (useDN) targetDnTextField.requestFocus();
       else urlTextField.requestFocus();
    }
    
    
    /**
     * Closes the Target Policy window.
     *
     * @param evt   Close button operated.
     */
    
    private void closeTargetButtonActionPerformed()
    {
        targetInternalFrame.setVisible(false);
    }
        
    
    /**
     * Deletes the node selected in the JComboBox from the DOM.
     *
     * @param evt       View delete button operated.
     */
    
    private void targetViewDeleteButtonActionPerformed()
    {
        if (targetViewComboBox.getSelectedIndex() != -1){
            String targetDomainId = targetViewComboBox.getSelectedItem().
                                                                     toString();
            PermisPolicyEditorMenu.permisXmlDom.deleteNode( TARGET_DOMAIN_SPEC, 
                                                            targetDomainId);
            targetViewComboBox.removeItem(targetViewComboBox.getSelectedItem());
            performRefresh();
            targetViewListModel.clear();
            targetViewScrollPane.setViewportView(targetViewList);
        }
    }
        
    
    /**
     * To be added.
     *
     * @param evt       View edit button operated.
     */
    
    private void targetViewEditButtonActionPerformed()
    {
        
                                                    
        String targetDomainId = targetViewComboBox.
                                                   getSelectedItem().toString();
       targetIdTextField.setText(targetDomainId);
     
      
      loader.readTargetPolicy(targetTree,
              targetObjectClassListModel, targetDomainId, TARGET_DOMAIN_SPEC);
        
      targetTreeScrollPane.setViewportView(targetTree);
        //make the Tabbedpane visible
        targetDomainTabbedPane.setSelectedIndex(1);
        editPressed = true;

        boolean b = !permisTargetPolicy.isTreeEmpty(targetTree);
        targetDeleteButton.setEnabled(b);
        targetExcludeButton.setEnabled(b);
    }
        
    
    /**
     * Populates the view window with a sentence (String) describing the 
     * contents of the node whose ID has been selected in the JComboBox. 
     *
     * @param evt       Combo box selection made.
     */
    
    private void targetViewComboBoxActionPerformed() 
    {
        if (targetViewComboBox.getItemCount() != 0) {
            
            if (targetViewComboBox.getSelectedIndex() != -1){
                String targetId = targetViewComboBox.getSelectedItem().
                                                                     toString();
                
                String start =  ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("tar_pol_readable")+" " + getString(targetId) + " "; 
                String output =  PermisPolicyView.populateWindow( 
                                                            targetId,
                                                            start,
                                                            TARGET_DOMAIN_SPEC);
                targetViewListModel.clear();
                targetViewListModel.addElement(output);
                targetViewScrollPane.setViewportView(targetViewList);
                targetViewList.setCellRenderer(
                                        new PermisPolicyTextListCellRenderer());
            }
        }
    }
    
        
    
    /**
     * Refreshes the JComboBox every time data is added to or deleted from 
     * the DOM.
     */
    
    public void performRefresh()
    {  
        if (targetIdTextField.getText().equals("")){
            highLighter(targetIdTextField);
        }
        targetViewComboBox.removeAllItems();
        String[] targetDetailsA;
        targetDetailsA = PermisPolicyEditorMenu.permisXmlDom.
                                     getAttributeValues(TARGET_DOMAIN_SPEC, ID);
        
        for (int i = 0; i < targetDetailsA.length; i++) {
            targetViewComboBox.addItem(targetDetailsA[i]);

⌨️ 快捷键说明

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