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

📄 permistargetpolicy.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }
    }
    
    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("tar_pol_domain_id");
       return  s+ idString + idName + st;
    }
    
    /** 
     * 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 String getSelectedInclude()
    {
        DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
                      targetTree.getLastSelectedPathComponent();
        if (currentNode==null) return null;

        String s = currentNode.toString();
        s = s.substring(s.indexOf(":") +1);
        return s.trim();
    }
    private boolean validateExcludeNode( String excludeDN,
                                         String includeDN)
    {
        /* excludeDN is the node to the Excluded from the
         * Include node includeDN. 
         *
         */
        Entry exclude;
        Subtree include;
        try{
          if (excludeDN.startsWith("URL:")){
            exclude = URLHandler.getEntryByURL(excludeDN.substring("URL:".length()));
          }else{
            exclude = new UserEntry(new LDAPDNPrincipal(excludeDN));
          }

          if (includeDN.startsWith("URL:")){
            include = URLHandler.getSubtreeByURL(includeDN.substring("URL:".length()), 0, -1, null); // 0=min, -1=max, null=exclude subtrees
          }else{
            include = new DITSubtree(
                                new LDAPDNPrincipal(includeDN),
                                0,
                                -1,
                                null,
                                null
                                );
          }
        if(include.contains(exclude)){
            //add the Exclude to the include
            return true;
        }
        else{
            //
            JOptionPane.showMessageDialog(this.parent.getPermisParent(),
            ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
            getString("pol_exclude_dn_err1") + " " +
           getString(excludeDN) + " " + 
           ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
           getString("pol_exclude_dn_err2")+ " " +
           getString(includeDN)+ " "+
           ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
           getString("pol_exclude_dn_err3"),"Error",
     JOptionPane.ERROR_MESSAGE);
            return false;
        }
        
    }
     catch (Throwable th){}
    JOptionPane.showMessageDialog(this.parent.getPermisParent(),
            ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
            getString("pol_exclude_dn_err1") + " " +
           getString(excludeDN) + " " + 
           ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
           getString("pol_exclude_dn_err2")+ " " +
           getString(includeDN)+ " "+
           ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
           getString("pol_exclude_dn_err3"),"Error",
     JOptionPane.ERROR_MESSAGE);
       return false;
    }

   private void clearBoxes()
   {
       targetIdTextField.setText("");
       targetDnTextField.setText("");
       targetIdTextField.requestFocus();
       permisTargetPolicy.removeChild(targetTree);
       targetObjectClassListModel.clear();
       urlTextField.setText("");
   }
    
   private void disableLdapComponents()
   {
      targetDnTextField.setEnabled(false);
      //targetIncludeButton.setEnabled(false);
      ldap_dit.setEnabled(false);
      //ldap_dit.disableLdapDit();
       ldap_dit.setBackground(new Color(153, 153, 153));
       removeListener();
      ldapLabel1.setForeground(new Color(153, 153, 153));
      ldapDnLabel.setForeground(new Color(153, 153, 153));
      targetDnTextField.setBackground(new Color(153, 153, 153));
      urlTextField.setBackground(new Color(255, 255, 255));
      urlLabel.setForeground(new Color(51, 51, 51));
      urlPanel.setForeground(new Color(51, 51, 51));
      urlPanel.setForeground(new Color(51, 51, 51));
      //targetTree.setEnabled(false);
      targetDnTextField.setText("");
      
      
   }
   public void resetLdap()
   {
      ldap_dit.setEnabled(true);
     // ldap_dit.enableLdapDit();
      addListener();
   }
     private void enableLdapComponents()
   {
      targetDnTextField.setEnabled(true);
      //targetIncludeButton.setEnabled(true);
      ldap_dit.setEnabled(true);
      // ldap_dit.enableLdapDit();
      //targetTree.setEnabled(true);
      addListener();
      ldapDnLabel.setForeground(new Color(51, 51, 51));
      urlLabel.setForeground(new Color(153, 153, 153));
      urlPanel.setForeground(new Color(153, 153, 153));
      urlTextField.setBackground(new Color(153, 153, 153));
      ldapLabel1.setForeground(new Color(51, 51, 51));
      urlPanel.setForeground(new Color(153, 153, 153));
      targetDnTextField.setBackground(new Color(255, 255, 255));
      ldap_dit.setBackground(new Color(255, 255, 255));
      targetDnTextField.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("tar_pol_domain_id") + " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_id_err")); 
      
       return false;
             
        
    }


    private boolean validateURI(String text)
    {
      boolean found = false;
              
        Matcher mr = uriPattern.matcher(text);
        found = mr.matches();  
        
       
        if(found){
            return true;
        }
     
       javax.swing.JOptionPane.showMessageDialog(this, 
                    ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_url_validity_err") + " " +
                   ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                   getString("pol_url_err")); 
      
       return false;
             
        
    }
    private void addListener()
    { 
        ldap_dit.setSelectionListener(this);
    }
    private void removeListener()
    { 
        //removeTreeSelectionListener
    }

    public void doubleclick(LDAP_DIT dit){
      doLDAPDoubleClick(dit);
    }
    public void select(LDAP_DIT dit){doLDAPDoubleClick(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
    }

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

    public void focusLost(FocusEvent e){}

  public void actionPerformed(ActionEvent event){
    String command = event.getActionCommand().intern();
    if (command==VIEW_ACTION){
      targetViewComboBoxActionPerformed();
    }else if (command==EDIT_ACTION){
      targetViewEditButtonActionPerformed();
    }else if (command==DELETE_ACTION){
      targetViewDeleteButtonActionPerformed();
    }else if (command==CLOSE_ACTION){
      closeTargetButtonActionPerformed();
    }else if (command==INCLUDE_ACTION){
      targetIncludeButtonActionPerformed();
    }else if (command==EXCLUDE_ACTION){
      targetExcludeButtonActionPerformed();
    }else if (command==DELETE1_ACTION){
      targetDeleteButtonActionPerformed();
    }else if (command==OK_ACTION){
      targetOkButtonActionPerformed();
    }else if (command==CANCEL_ACTION){
      targetCancelButtonActionPerformed();
    }else if (command==CLOSE1_ACTION){
      targetCloseButtonActionPerformed();
    }else if (command==ADD_ACTION){
      targetObjectClassAddButtonActionPerformed();
    }else if (command==DELETE2_ACTION){
      targetObjectClassDeleteButtonActionPerformed();
    }else if (command==LDAP_ACTION){
      ldapRadioButtonActionPerformed();
    }else if (command==URL_ACTION){
      urlRadioButtonActionPerformed();
    }
  }
}

⌨️ 快捷键说明

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