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

📄 permisroleassignmentpolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * @param evt   View display edit button operated.
     */
        
    private void  roleAssignmentEditActionPerformed() 
    { 
        if(roleAssignViewComboBox.getItemCount() < 1){
            return;
        }
        else{
          roleSubjectComboBox.removeAllItems();
          roleAssignSoaComboBox.removeAllItems();
          refreshBoxes();
            String idValue = roleAssignViewComboBox.getSelectedItem().toString();
            roleAssignIDTextField.setText(idValue);
            loader.readAssignmentPolicy( roleAssignmentListModel, 
                                         roleSubjectComboBox,
                                         roleAssignSoaComboBox, 
                                         idValue,
                                         "RoleAssignment",
                                         check,
                                         unlimited,
                                         depth);
        if (!check.isSelected()) unlimited.setBackground(roleAssignmentSubjectPanel.getBackground());
        roleAssignmentListScrollPane.setViewportView(roleAssignmentList);
        roleAssignmentTabbedPane.setSelectedIndex(1);
       
    }
    editPressed = true;
    }
    public void refreshBoxes()
    {
         loader.readRolesPolicy(null,
                               null, 
                               null,
                               roleAssignmentComboBox,
                               "RoleSpec");
            String[] soaDetailsA;		
        soaDetailsA = PermisPolicyEditorMenu.permisXmlDom.
                                               getAttributeValues("SOASpec", ID);
        roleAssignSoaComboBox.removeAllItems();
        for ( int i = 0; i < soaDetailsA.length; i++){
             roleAssignSoaComboBox.addItem(soaDetailsA[i]);
        }
        roleSubjectComboBox.removeAllItems();
        String[] subjectDetailsA;
        subjectDetailsA = PermisPolicyEditorMenu.permisXmlDom.
                                         getAttributeValues("SubjectDomainSpec",
                                                            ID);
        for (int i=0; i <subjectDetailsA.length; i++){
            roleSubjectComboBox.addItem(subjectDetailsA[i]);
        }
    }
    
    /**
     * Populates the Roles, SOA and Subject Domain combo boxes in the 
     * Create/Modify display.
     */
        
    public void populateRoleAssignment()
    {
        this.doc = PermisPolicyEditorMenu.permisXmlDom.getDoc();
        if(doc != null){
        
        String[] soaDetails = PermisPolicyEditorMenu.permisXmlDom.
                                                             getAttributeValues(
                                                             "SOASpec", 
                                                             "ID");
        
        // Empty SOA combo box and then repopulate
        roleAssignSoaComboBox.removeAllItems();
        
        for (int i = 0; i < soaDetails.length; i++) {
            roleAssignSoaComboBox.addItem(soaDetails[i]);
        }
        String[] roleSubjectDetails = PermisPolicyEditorMenu.permisXmlDom.
                                                            getAttributeValues(
                                                            "SubjectDomainSpec", 
                                                            "ID");
        // Empty Subject combo box and then repopulate
        roleSubjectComboBox.removeAllItems();
        
        for (int i = 0; i < roleSubjectDetails.length; i++) {
            roleSubjectComboBox.addItem(roleSubjectDetails[i]);
        }
        String[] roleAssignmentDetails = PermisPolicyEditorMenu.permisXmlDom.
                                                             getAttributeValues(
                                                             "SupRole",
								                             "Value");
        //empty Role combo box and then repopulate
        roleAssignmentComboBox.removeAllItems();
        
        for (int i = 0; i < roleAssignmentDetails.length; i++) {
            roleAssignmentComboBox.addItem(roleAssignmentDetails[i]);
        }
        
        }
    }

    
    /**
     * Refreshes the view display combo box every time data is added to or 
     * deleted from the DOM.
     */
        
    public void performRefresh()
    {
         if (roleAssignIDTextField.getText().equals("")){
             highLighter(roleAssignIDTextField);
         }
              
        String[] roleAssignmentId = PermisPolicyEditorMenu.permisXmlDom.
                                                             getAttributeValues(
                                                             "RoleAssignment", 
	                                                         "ID");
       
        if(roleAssignmentId.length == 0){
            
           populateRoleAssignment(); 
        }
        else{
        roleAssignViewComboBox.removeAllItems();
        
        for (int i = 0; i < roleAssignmentId.length; i++) {
            roleAssignViewComboBox.addItem(roleAssignmentId[i]);
        }
        }
    }

    
    /**
     * 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 roleAssignViewComboBoxActionPerformed()
    {
        if (roleAssignViewComboBox.getItemCount() != 0 ) {
            
            if (roleAssignViewComboBox.getSelectedIndex() != -1){
                String roleId = roleAssignViewComboBox.getSelectedItem().
                                                                     toString();
                StringBuffer roleValue = new StringBuffer();
                roleValue.append(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                                           getString("role_ass_pol_readable") 
                                           + " " + getString(roleId) + " ");
                                
                                
                roleValue.append(PermisPolicyEditorMenu.permisXmlDom.
                                                         getRoleValues(roleId));
                roleAssignmentViewListModel.clear();
                roleAssignmentViewListModel.addElement(roleValue);
                roleAssignmentViewList.setCellRenderer(
                                        new PermisPolicyTextListCellRenderer());
                roleAssignViewScrollPane.setViewportView(roleAssignmentViewList);
            }
        }
    }
    
    /**
     *
     */      
    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 + "]";
   }
    
    /** 
     * 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("rol_ass_brd_role_assign");
       return  s+ idString + idName + st;
    }
    
    /** 
     * 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()
    {
        roleAssignmentListModel.clear();
        roleAssignIDTextField.setText("");
    }

    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("rol_ass_brd_role_assign") + " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_id_err")); 
      
       return false;
             
        
    }

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

    public void focusLost(FocusEvent e){}

  public void actionPerformed(ActionEvent event){
    String command = event.getActionCommand().intern();
    if (command==REMOVE_ACTION){
      roleAssignmentEditActionPerformed();
    }else if (command==DELETE_ACTION){
      roleAssignmentDeleteButtonActionPerformed();
    }else if (command==CLOSE_ACTION){
      roleAssignCloseButtonActionPerformed();
    }else if (command==VIEW_ACTION){
      roleAssignViewComboBoxActionPerformed();
    }else if (command==OK_ACTION){
      roleAssignmentOkButtonActionPerformed();
    }else if (command==CANCEL_ACTION){
      roleAssignmentCancelButtonActionPerformed();
    }else if (command==CLOSE1_ACTION){
      roleAssignmentCloseButtonActionPerformed();
    }else if (command==ADD_ACTION){
      roleAssignmentAddButtonActionPerformed();
    }else if (command==REMOVE_SUBJECT_ACTION){
      roleAssignmentRemoveSubjectButtonActionPerformed();
    }
  }
}

⌨️ 快捷键说明

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