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

📄 permissubjectpolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    {
        if(policySubjectTree.includeNodeAlreadyExist(treeSubject,
                   subjectPolicyLdapDnTextField.getText().trim())){
                   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(subjectPolicyLdapDnTextField.getText()) + " "+ 
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_msg_dn_exist")); 
         // subjectPolicyLdapDnTextField.setText("");
          subjectPolicyLdapDnTextField.requestFocus();
           return;
        }
        policySubjectTree.includeNode( treeSubject,
                                 subjectPolicyLdapDnTextField.getText().trim());
        
        subjectExcludeButton.setEnabled(true);
        subjectDeleteButton.setEnabled(true);
        subjectPolicyLdapDnTextField.setText("");
        subjectPolicyLdapDnTextField.requestFocus();
    }    
    /**************************************************************************\
     *                           subjectViewComboBoxActionPerformed           *
    \**************************************************************************/
    
    /**
     * 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 subjectViewComboBoxActionPerformed() 
    {
        if (subjectViewComboBox.getItemCount() != 0) {
            
            if (subjectViewComboBox.getSelectedIndex() != -1){
                String subjectId = subjectViewComboBox.
                                                   getSelectedItem().toString();
               String start = ResourceBundle.getBundle(
               "issrg/editor/gui/Editor_GUI_i18n").getString("pol_readable_sub") 
               + " " +  getString(subjectId) + " ";
                String output =  PermisPolicyView.populateWindow( 
                                                           subjectId,
                                                           start,
                                                           SUBJECT_DOMAIN_SPEC);
                subjectViewListModel.clear();
                subjectViewListModel.addElement(output);
                subjectPolicyViewScrollPane.setViewportView(subjectViewList);
                subjectViewList.setCellRenderer(
                                        new PermisPolicyTextListCellRenderer());
            }
        }
    
    }
            
    /**************************************************************************\
     *                           subjectEditButtonActionPerformed             *
    \**************************************************************************/
    
    /**
     * @param evt              Edit button operated
     */
    
    private void subjectEditButtonActionPerformed() 
    {
         if (subjectViewComboBox.getItemCount() != 0){
            
            if (subjectViewComboBox.getSelectedIndex() != -1){
        String subjectDomainId = subjectViewComboBox.
                                                   getSelectedItem().toString();
        subjectIdTextField.setText(subjectDomainId);
        //treeSubject = policySubjectTree.initNodes(SUBJECT_POLICY);
       
        treeSubject =   loader.readPolicy( treeSubject, 
                                           subjectDomainId, 
                                           SUBJECT_DOMAIN_SPEC);
        subjectPolicyTreeScrollPane.setViewportView(treeSubject);
        subjectExcludeButton.setEnabled(true);
        subjectDeleteButton.setEnabled(true);
        //make the Tabbedpane visible
        subjectPolicyTabbedPane.setSelectedIndex(1);
            }
         }
         editPressed = true;
    }
            
    /**************************************************************************\
     *                           subDeleteButtonActionPerformed               *
    \**************************************************************************/
    
    /**
     *
     * Deletes the node selected in the JComboBox from the DOM.
     *
     * @param evt       View delete button operated
     */
    
    private void viewDeleteButtonActionPerformed() 
    {
        if (subjectViewComboBox.getSelectedIndex() != -1){
            String subjectDomainId = subjectViewComboBox.
                                                   getSelectedItem().toString();
            PermisPolicyEditorMenu.permisXmlDom.deleteNode(SUBJECT_DOMAIN_SPEC, 
                                                            subjectDomainId);
            subjectViewComboBox.removeItem(
                                         subjectViewComboBox.getSelectedItem());
            performRefresh();
            subjectViewListModel.clear();
            subjectPolicyViewScrollPane.setViewportView(subjectViewList);
        }
    
    }
                
    /**************************************************************************\
     *                           closeSubjectButtonActionPerformed            *
    \**************************************************************************/
    
    /**
     * Closes the Subject Policy window.
     *
     * @param evt       View close button operated
     */
    
    private void closeSubjectButtonActionPerformed() 
    {
        subjectInternalFrame.setVisible(false);
    }
                
    /**************************************************************************\
     *                           refreshComboBox                              *
    \**************************************************************************/
    
    /** 
     * Refreshes the JComboBox every data is added to or deleted from the DOM 
     */
    
    public void performRefresh()
    {
         if (subjectIdTextField.getText().equals("")){
            
             highLighter(subjectIdTextField);
         }
        subjectViewComboBox.removeAllItems();
        String[] subjectDetailsA;
        subjectDetailsA = PermisPolicyEditorMenu.permisXmlDom.
                                         getAttributeValues(SUBJECT_DOMAIN_SPEC,
                                                            ID);
        
        for (int i = 0; i < subjectDetailsA.length; i++) {
            subjectViewComboBox.addItem(subjectDetailsA[i]);
        }
    }
    /**************************************************************************\
     *                           getString                                    *
    \**************************************************************************/
    
    /** 
     * adds square brackets to a string and return the new string
     *
     *
     */
     private String getString(String string)
   {
       return "[" + string + "]";
   }
    /**************************************************************************\
     *                          getIDInitialization                           *
    \**************************************************************************/
    
    /** 
     * Initializes ID TextField
     *
     */
    private String getIDInitialization()
    {
       String s = "<";
       String st = ">";
       String idString = ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("pol_please_type_in_a") + " " ;
       String idName = ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("sub_pol_err_msg_domain");
       return  s+ idString + idName + st;
    }
    /**************************************************************************\
     *                          highLighter                                   *
    \**************************************************************************/
    
    /** 
     * Highlights the IDTextField
     * 
     */
    public void highLighter(JTextField text)
    {
        DefaultHighlighter high = new DefaultHighlighter();
        DefaultHighlighter.DefaultHighlightPainter highlight_painter =
        new DefaultHighlighter.DefaultHighlightPainter(
             new Color(198,198,250));
    
        SimpleAttributeSet set=new  SimpleAttributeSet();
        text.setText(getIDInitialization());
        text.setEditable(true);
        text.setHighlighter(high);
        int i = text.getText().length();
        try{
            high.addHighlight(0,i,highlight_painter);
            
        }
        catch(Exception ignoreMe) {}

        }
    private void clearBoxes()
    {
       subjectIdTextField.setText("");
       subjectPolicyLdapDnTextField.setText("");
       subjectIdTextField.requestFocus();
       policySubjectTree.removeChild(treeSubject);
    }
    
    /**
     *
     *
     */
    private boolean validateID(String text)
    {
       boolean found = false;
              
        String IDRegex = "([\\w]++)*+";
        /* This expression  "([\\w]++)*+ allowa only a word character format
         * 
         *
         */
        Pattern pt = Pattern.compile(IDRegex);
        Matcher mr;
         mr = pt.matcher(text);
        found = mr.matches();  
        
       
        if(found){
            return true;
        }
       
       javax.swing.JOptionPane.showMessageDialog(this, 
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_err_msg_domain") + " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_id_err")); 
      
       return false;
             
        
    }

  public void actionPerformed(ActionEvent evt){
    String event=evt.getActionCommand().intern();
    if (event == VIEW_ACTION){
      subjectViewComboBoxActionPerformed();   
    }else if (event == EDIT_ACTION){
      subjectEditButtonActionPerformed();
    }else if (event == DELETE_ACTION){
      viewDeleteButtonActionPerformed();
    }else if (event == CLOSE_ACTION){
      closeSubjectButtonActionPerformed();
    }else if (event == INCLUDE_ACTION){
      subjectIncludeButtonActionPerformed();
    }else if (event == EXCLUDE_ACTION){
      subjectExcludeButtonActionPerformed();
    }else if (event == DELETE1_ACTION){
      subjectDeleteButtonActionPerformed();
    }else if (event == OK_ACTION){
      subjectOkButtonActionPerformed();
    }else if (event == CANCEL_ACTION){
      subjectCancelButtonActionPerformed();
    }else if (event == CLOSE1_ACTION){
      subjectCloseButtonActionPerformed();
    }
  }
    
}

⌨️ 快捷键说明

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