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

📄 permissoapolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        }
       else if (permisPolicySoa.checkNode(treeSoa,soaIDTextField.getText())){
            
            PermisPolicyEditorMenu.dialog.showOkDialog(
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("sub_pol_err_msg_c") + " "+
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("Soa_ID")+ " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("soa_pol_err_msg_id"));
            soaIDTextField.requestFocus();
            soaIDTextField.selectAll();
            return ;
        }
        
        else {
            
            permisPolicySoa.addTreeNode( treeSoa, 
                                         soaIDTextField.getText(), 
                                         soaDnTextField.getText());
           parent.putIdHashtable(soaIDTextField.getText());
           highLighter(soaIDTextField);
           soaIDTextField.requestFocus();
           soaDnTextField.setText("");
        }
    }
    
    /**************************************************************************\
     *                           soaPolicyCloseButton1ActionPerformed         *
    \**************************************************************************/
    
    /** 
     * Closes the SOA Policy window.
     *
     * @param evt   Close button operated.
     */    
    private void soaPolicyCloseButton1ActionPerformed() 
    {
        soaInternalFrame.setVisible(false);
    }
    
    /**************************************************************************\
     *                           soaPolicyDeleteButtonActionPerformed         *
    \**************************************************************************/
    
    /** 
     * Deletes the node selected in the JComboBox from the DOM.
     *
     * @param evt   Delete button operated.
     */    
    private void soaPolicyDeleteButtonActionPerformed()
    {
        if (soaViewComboBox.getSelectedIndex() != -1){
            String soaId = soaViewComboBox.getSelectedItem().toString();
            PermisPolicyEditorMenu.permisXmlDom.deleteNode(SOA_SPEC, soaId);
            soaViewComboBox.removeItem(soaViewComboBox.getSelectedItem());
            performRefresh();
            soaViewListModel.clear();
            soaViewScrollPane.setViewportView(soaViewList);
        }
    }
    
    /**************************************************************************\
     *                           soaViewComboBoxActionPerformed               *
    \**************************************************************************/
    
    /** 
     * Populates the view window with a sentence (String) describing the
     * contents of the node whose ID has been selected in the JComboBox.
     *
     * @param evt   Selection made from JComboBox
     */    
    private void soaViewComboBoxActionPerformed() 
    {
        if (soaViewComboBox.getItemCount() != 0){
            
            if (soaViewComboBox.getSelectedIndex() != -1){
                String soaId = soaViewComboBox.getSelectedItem().toString();
                String output =ResourceBundle.getBundle(
               "issrg/editor/gui/Editor_GUI_i18n").getString("soa_pol_readable")
                 + " "  + getString(soaId) + " " +  ResourceBundle.getBundle(
               "issrg/editor/gui/Editor_GUI_i18n").getString("soa_pol_readable1")+
                                
                getString(PermisPolicyEditorMenu.permisXmlDom.getSoaValue(soaId));
                soaViewListModel.clear();
                soaViewListModel.addElement(output);
                soaViewScrollPane.setViewportView(soaViewList);
                soaViewList.setCellRenderer(new 
                                            PermisPolicyTextListCellRenderer());
            }
        }
    }

    /**************************************************************************\
     *                           soaPolicyEditButtonActionPerformed           *
    \**************************************************************************/
    
    /**
     * Changes the view to the Creatre/Modify screen with all the relveant areas
     * populated with data from the node whose Id is selecetd in the JComboBox.
     *
     * @param evt   Edit button operated
     */
    private void soaPolicyEditButtonActionPerformed() 
    {
       
        String soaId = soaViewComboBox.getSelectedItem().toString();
         permisPolicySoa.removeChild(treeSoa );
        soaIDTextField.setText(soaId);
        //policy.readSoaPolicy(treeSoa, soaId, SOA_SPEC);
        loader.readSoaPolicy(soaDnTextField, soaId, SOA_SPEC);
        
        loader.refreshSoaTree(treeSoa, "SOAPolicy");
       
        soaTreeScrollPane.setViewportView(treeSoa); 
        soaTabbedPane.setSelectedIndex(1);
        editPressed = true;
    }
    
    /**************************************************************************\
     *                           refreshComboBox                              *
    \**************************************************************************/
    
    /**
     *  Refreshes the JComboBox every data is added to or deleted from the DOM.
     */
    

    public void performRefresh()
    {
         if (soaIDTextField.getText().equals("")){
                 highLighter(soaIDTextField);
              }
        soaViewComboBox.removeAllItems();
        String[] soaDetailsA;		
        soaDetailsA = PermisPolicyEditorMenu.permisXmlDom.
                                               getAttributeValues(SOA_SPEC, ID);
        for (int i = 0; i < soaDetailsA.length; i++) {
            soaViewComboBox.addItem(soaDetailsA[i]);
        }
    }

    private ArrayList getSoaID()
    {
       String id = null;
       idArrayList = new ArrayList();
       DefaultTreeModel treeModel = (DefaultTreeModel)treeSoa.getModel();
        
        // Gets the root of the tree
       DefaultMutableTreeNode top =
                                    (DefaultMutableTreeNode)treeModel.getRoot();
       for (int j = 0; j< top.getChildCount(); j++) {
       DefaultMutableTreeNode child = 
                                      (DefaultMutableTreeNode)top.getChildAt(j);
       
       // Extract the attribute value of the Include node
       String attrValue = child.toString();
       String attributeValue = attrValue.substring(attrValue.indexOf(":") +
                                                         1, attrValue.length());
       id = attrValue.substring(0, attrValue.indexOf(":"));
       idArrayList.add(id);
          
          }
       return idArrayList;
    }

     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("Soa_ID");
       return  s+ idString + idName + st;
    }
    /**************************************************************************\
     *                          highLighter                                   *
    \**************************************************************************/
    
    /** 
     * Highlights the IDTextField
     * 
     */
    public void highLighter(JTextField tef)
    {
        DefaultHighlighter high = new DefaultHighlighter();
        DefaultHighlighter.DefaultHighlightPainter highlight_painter =
        new DefaultHighlighter.DefaultHighlightPainter(new Color(198,198,250));
        SimpleAttributeSet set = new  SimpleAttributeSet();

    
        //tef=new JTextField(12);
       
        tef.setText(getIDInitialization());
        tef.setEditable(true);
        tef.setHighlighter(high);
        int i = tef.getText().length();
        try{
            high.addHighlight(0,i,highlight_painter);
            //high.addHighlight(16,20,highlight_painter);
            //high.addHighlight(25,29,highlight_painter);
        }
        catch(Exception ignoreMe) {}

        

     }
    
    private void clearBoxes()
    {
         soaIDTextField.setText("");
         soaDnTextField.setText("");
         soaIDTextField.requestFocus();
         permisPolicySoa.removeChild(treeSoa );
    }
    
    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("Soa_ID") + " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_id_err")); 
      
       return false;
    }

  public void actionPerformed(ActionEvent evt){
    String command = evt.getActionCommand().intern();

    if (command == VIEW_ACTION){
      soaViewComboBoxActionPerformed();
    }else if(command == EDIT_ACTION){
      soaPolicyEditButtonActionPerformed();
    }else if(command == DELETE_ACTION){
      soaPolicyDeleteButtonActionPerformed();
    }else if(command == CLOSE_ACTION){
      soaPolicyCloseButton1ActionPerformed();
    }else if(command == ADD_ACTION){
      soaAddButtonActionPerformed();
    }else if(command == DELETE1_ACTION){
      soaDeleteButtonActionPerformed();
    }else if(command == OK_ACTION){
      soaPolicyOkButtonActionPerformed();
    }else if(command == CANCEL_ACTION){
      soaPolicyCancelButtonActionPerformed();
    }else if(command == CLOSE1_ACTION){
      soaPolicyCloseButtonActionPerformed();
    }
  }

  public void focusGained(FocusEvent e) {
    String s = getIDInitialization();
    if (soaIDTextField.getText().equals(s)){
      soaIDTextField.setText("");
    }
  }

  public void focusLost(FocusEvent e){}


  public void doubleclick(LDAP_DIT dit){
    try{
            
      String dn = dit.getSelectedNode().getNameInNamespace();
      soaDnTextField.setText(dn);
    }
    catch(javax.naming.NamingException ne)
    {
      parent.getLdapCon(). unsetLdap();
    }
  }
  public void select(LDAP_DIT dit){doubleclick(dit);}

  public void unselect(LDAP_DIT dit){/*do nothing*/}
  public void communicationError(Throwable th){
    //we don't want to do anything with the error
    parent.getLdapCon().unsetLdap(); // display 'not found' message in ldap browser
  }
}

⌨️ 快捷键说明

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