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

📄 permistargetaccesspolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * Populates the view window with a sentence (String) describing the 
     * contents of the node whose ID has been selected in the combo box. 
     *
     * @param evt       Selection made in the JComboBox.
     */
        
    private void targetAccessViewComboBoxActionPerformed()
    {
        if (targetAccessViewComboBox.getItemCount() != 0 ) {
            
            if (targetAccessViewComboBox.getSelectedIndex() != -1){
                String targetAccessId = targetAccessViewComboBox.
                                                   getSelectedItem().toString();
                StringBuffer targetValue = PermisPolicyEditorMenu.permisXmlDom.
                                          getTargetAccessValues(targetAccessId);
                targetAccessViewListModel.clear();
                String string = ResourceBundle.getBundle(
                                         "issrg/editor/gui/Editor_GUI_i18n").
                                          getString("tar_acc_pol_readable")+" ";
            
          
                targetValue.insert(0,
                 string + " " + getString(targetAccessId)+ " "
                 + ResourceBundle.getBundle(
                                 "issrg/editor/gui/Editor_GUI_i18n").
                                  getString("tar_acc_pol_readable_grant")+ " ");
                String output = targetValue.toString();
                output.trim();
                targetAccessViewListModel.addElement(output);
                targetAccessViewList.setCellRenderer(
                                        new PermisPolicyTextListCellRenderer());
                targetAccessViewScrollPane.setViewportView(
                                                          targetAccessViewList);
            }
        }
    }
    
    /**************************************************************************\
     *             populateTargetAccess                                       *
    \**************************************************************************/
    
    /**
     * Populates the Roles, Actions and Target Domain combo boxes in the 
     * Create/Modify display.
     */
        
    public void populateTargetAccess()
    {
        // Populates the targetAccess combo boxes from memory
        String[] roleAssignmentDetails = PermisPolicyEditorMenu.permisXmlDom.
                                                   getAttributeValues("SupRole",
                                                                      "Value");
        
        // Empty combo box and repopulate it
        targetRoleComboBox.removeAllItems();
        
        for (int i = 0; i < roleAssignmentDetails.length; i++) {
            targetRoleComboBox.addItem(roleAssignmentDetails[i]);
        }
        String[] actionDetails = PermisPolicyEditorMenu.permisXmlDom.
                                                    getAttributeValues("Action",
                                                                       "Name");
        // Empty combo box and repopulate it
        targetAccessActionComboBox.removeAllItems();	
        
        for (int i = 0; i < actionDetails.length; i++) {
            targetAccessActionComboBox.addItem(actionDetails[i]);
        }
        String[] roleSubjectDetails = PermisPolicyEditorMenu.permisXmlDom.
                                         getAttributeValues( "TargetDomainSpec",
									                         ID);
        // Empty combo box and repopulate it
        targetDomainComboBox.removeAllItems();	
        
        for (int i = 0; i < roleSubjectDetails.length; i++) {
            targetDomainComboBox.addItem(roleSubjectDetails[i]);
        }
        
        // Empty combo box and repopulate it
        targetAccessViewComboBox.removeAllItems();
        String[] subjectDetailsA = PermisPolicyEditorMenu.permisXmlDom.
                                             getAttributeValues( "TargetAccess",
                                                                 ID);
        for (int i = 0; i < subjectDetailsA.length; i++) {
            targetAccessViewComboBox.addItem(subjectDetailsA[i]);
        }
    }
    
    /**************************************************************************\
     *             refreshComboBox                                            *
    \**************************************************************************/
    
    /**
     * Refreshes the view display combo box every time data is added to or 
     * deleted from the DOM.
     */
        
    public void performRefresh()
    {
        if(targetAccessIDTextField.getText().equals("")){
             highLighter(targetAccessIDTextField);
        }
        String[] targetAccessId = PermisPolicyEditorMenu.permisXmlDom.
                                             getAttributeValues( "TargetAccess", 
                                                                 ID);
        if( targetAccessId != null){
        if(targetAccessId.length == 0){
            populateTargetAccess();
        }
        else{
        targetAccessViewComboBox.removeAllItems();
        
        for (int i = 0; i < targetAccessId.length; i++) {
            targetAccessViewComboBox.addItem(targetAccessId[i]);
        }
    }
        }
    }
    private boolean checkDuplication( String compare,
                                      DefaultListModel compareList)
                                         
    {
        if(!compareList.isEmpty()){
            for (int i = 0; i < compareList.size(); i++){
                if (compareList.elementAt(i).equals(compare)){
                    return true;
                }
            }
            
       
        }
        return false;
    }
    private String getString(String string)
    {
        return "[" + string + "]";
    }
    public void refreshBoxes()
    {
        
    }
    
    /**************************************************************************\
     *                          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("tar_acc_pol_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.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()
   {
       targetAccessRoleListModel.clear();
       //targetAccessDomainListModel.clear();
       targetAccessActionListModel.clear();
       targetAccessIDTextField.setText("");
   }
     /**************************************************************************\
     *                             validateOID                                *
    \**************************************************************************/
    /**
     *
     *
     */
    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("tar_acc_pol_id") + " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_id_err")); 
      
       return false;
             
        
    }

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

    public void focusLost(FocusEvent e){}

  public void actionPerformed(ActionEvent event){
    String command = event.getActionCommand().intern();
    if (command==EDIT_ACTION){
      targetAccessEditButtonActionPerformed();
    }else if (command==DELETE_ACTION){
      targetAccessDeleteButtonActionPerformed();
    }else if (command==CLOSE_ACTION){
      targetAccessCloseButton1ActionPerformed();
    }else if (command==VIEW_ACTION){
      targetAccessViewComboBoxActionPerformed();
    }else if (command==ADD_ACTION){
      targetRoleAddButtonActionPerformed();
    }else if (command==REMOVE_ACTION){
      targetRoleRemoveButtonActionPerformed();
    }else if (command==ADD1_ACTION){
      targetActionAddButtonActionPerformed();
    }else if (command==REMOVE1_ACTION){
      targetActionRemoveButtonActionPerformed();
    }else if (command==OK_ACTION){
      targetAccessOkButtonActionPerformed();
    }else if (command==CANCEL_ACTION){
      targetAccessCancelButtonActionPerformed();
    }else if (command==CLOSE1_ACTION){
      targetAccessCloseButtonActionPerformed();
    }
  }
}

⌨️ 快捷键说明

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