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

📄 policysigningdialog.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* Copyright (c) 2000-2005, University of Salford
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without 
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this 
* list of conditions and the following disclaimer.
* 
* Redistributions in binary form must reproduce the above copyright notice, 
* this list of conditions and the following disclaimer in the documentation 
* and/or other materials provided with the distribution. 
*
* Neither the name of the University of Salford nor the names of its 
* contributors may be used to endorse or promote products derived from this 
* software without specific prior written permission. 
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
* POSSIBILITY OF SUCH DAMAGE.
*/

package issrg.editor.gui;

import iaik.asn1.ASN1Object;
import iaik.asn1.BIT_STRING;
import iaik.asn1.structures.AlgorithmID;

import javax.swing.*;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Map;
import java.util.Date;
import java.util.Vector;
import java.util.Hashtable;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.security.MessageDigest;
import java.math.BigInteger;

import issrg.acm.extensions.SimpleSigningUtility;
import issrg.acm.extensions.LDAPSavingUtility;
import issrg.ac.attributes.PMIXMLPolicy;
import issrg.ac.AttributeCertificate;

/**
 * Created by IntelliJ IDEA.
 * User: Administrador
 * Date: Jul 12, 2004
 * Time: 1:00:07 PM
 * To change this template use Options | File Templates.
 */
public class PolicySigningDialog extends JDialog {
    private JRadioButton jRBfile = null;
    private JRadioButton jRBLDAP = null;
    private JTextField textBeforeDate = null;
    private JSpinner spinnerBeforeH = null;
    private JSpinner spinnerBeforeM = null;
    private JSpinner spinnerBeforeS = null;
    private JTextField textAfterDate = null;
    private JSpinner spinnerAfterH = null;
    private JSpinner spinnerAfterM = null;
    private JSpinner spinnerAfterS = null;
    private JCheckBox jCHBefore = null;
    private JCheckBox jCHAfter  = null;
    private Map env;
    private JButton bBeforeChooser = null;
    private JButton bAfterChooser = null;
    private JFrame jf;

    private String xmlPolicy = "NULL";

    public PolicySigningDialog(JFrame f) {

        super(f,"Signing and publishing of your policy");
        jf = f;
        env = new Hashtable();

        JPanel pData = new JPanel();
        pData.setLayout(new BorderLayout());
        JPanel pButtons = new JPanel();

        JPanel pPublication = new JPanel();
        pPublication.setBorder(new TitledBorder("My policy will be published"));
        pPublication.setLayout(new BorderLayout());
        jRBfile = new JRadioButton("as a file",true);
        jRBLDAP = new JRadioButton("in a LDAP server",false);
        ButtonGroup bg = new ButtonGroup();
        bg.add(jRBfile);
        bg.add(jRBLDAP);
        pPublication.add("West",jRBfile);
        pPublication.add("Center",jRBLDAP);


        JPanel pBefore = new JPanel();
        pBefore.setBorder(new TitledBorder("My policy will be valid from"));
        pBefore.setLayout(new GridLayout(2,1));

        JPanel pBeforeDate = new JPanel();
        JPanel pBeforeTime = new JPanel();

        pBeforeDate.add(new JLabel("Date"));
        if (textBeforeDate == null)
            textBeforeDate = new JTextField(10);
        textBeforeDate.setText(new SimpleDateFormat("yyyy.MM.dd").format(new Date()));
        pBeforeDate.add(textBeforeDate);
        bBeforeChooser = new JButton("Choose...");
        bBeforeChooser.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                /** DateChooser instance to use to change the date. */
                DateChooser DATE_CHOOSER = new DateChooser(jf,"Select Date");
                Date d = DATE_CHOOSER.select();
                textBeforeDate.setText(new SimpleDateFormat("yyyy.MM.dd").format(d));
            }
        });
        pBeforeDate.add(bBeforeChooser);
        pBefore.add(pBeforeDate);

        SpinnerNumberModel modelH = new SpinnerNumberModel(0,0,23,1);
        spinnerBeforeH = new JSpinner(modelH);
        JSpinner.NumberEditor editorBeforeH = new JSpinner.NumberEditor(spinnerBeforeH);
        spinnerBeforeH.setEditor(editorBeforeH);

        SpinnerNumberModel modelM = new SpinnerNumberModel(0,0,59,1);
        spinnerBeforeM = new JSpinner(modelM);
        JSpinner.NumberEditor editorBeforeM = new JSpinner.NumberEditor(spinnerBeforeM);
        spinnerBeforeM.setEditor(editorBeforeM);

        SpinnerNumberModel modelS = new SpinnerNumberModel(0,0,59,1);
        spinnerBeforeS = new JSpinner(modelS);
        JSpinner.NumberEditor editorBeforeS = new JSpinner.NumberEditor(spinnerBeforeS);
        spinnerBeforeS.setEditor(editorBeforeS);

        pBeforeTime.add(spinnerBeforeH);
        pBeforeTime.add(new JLabel("hours"));
        pBeforeTime.add(spinnerBeforeM);
        pBeforeTime.add(new JLabel("minutes"));
        pBeforeTime.add(spinnerBeforeS);
        pBeforeTime.add(new JLabel("seconds"));
        pBefore.add(pBeforeTime);
        if (jCHBefore == null)
            jCHBefore = new JCheckBox("From now");
//        pBefore.add(jCHBefore);
        jCHBefore.addChangeListener(new ChangeListener() {
           public void stateChanged(ChangeEvent e) {
               boolean status = !jCHBefore.isSelected();
               textBeforeDate.setEnabled(status);
               spinnerBeforeH.setEnabled(status);
               spinnerBeforeM.setEnabled(status);
               spinnerBeforeS.setEnabled(status);
               bBeforeChooser.setEnabled(status);
                 }
           });

        JPanel pAfter = new JPanel();
        pAfter.setBorder(new TitledBorder("My policy will be valid until"));
        pAfter.setLayout(new GridLayout(2,1));

        JPanel pAfterDate = new JPanel();
        JPanel pAfterTime = new JPanel();

        pAfterDate.add(new JLabel("Date"));
        textAfterDate = new JTextField(10);
        textAfterDate.setText(new SimpleDateFormat("yyyy.MM.dd").format(new Date()));
        pAfterDate.add(textAfterDate);
        bAfterChooser = new JButton("Choose...");
        bAfterChooser.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                /** DateChooser instance to use to change the date. */
                DateChooser DATE_CHOOSER = new DateChooser(jf,"Select Date");
                Date d = DATE_CHOOSER.select();
                textAfterDate.setText(new SimpleDateFormat("yyyy.MM.dd").format(d));
            }
        });


        pAfterDate.add(bAfterChooser);
        pAfter.add(pAfterDate);

        SpinnerNumberModel modelH2 = new SpinnerNumberModel(0,0,23,1);
        spinnerAfterH = new JSpinner(modelH2);
        JSpinner.NumberEditor editorAfterH = new JSpinner.NumberEditor(spinnerAfterH);
        spinnerAfterH.setEditor(editorAfterH);

        SpinnerNumberModel modelM2 = new SpinnerNumberModel(0,0,59,1);
        spinnerAfterM = new JSpinner(modelM2);
        JSpinner.NumberEditor editorAfterM = new JSpinner.NumberEditor(spinnerAfterM);
        spinnerAfterM.setEditor(editorAfterM);

        SpinnerNumberModel modelS2 = new SpinnerNumberModel();
        spinnerAfterS = new JSpinner(modelS2);
        JSpinner.NumberEditor editorAfterS = new JSpinner.NumberEditor(spinnerAfterS);
        spinnerAfterS.setEditor(editorAfterS);

        pAfterTime.add(spinnerAfterH);
        pAfterTime.add(new JLabel("hours"));
        pAfterTime.add(spinnerAfterM);
        pAfterTime.add(new JLabel("minutes"));
        pAfterTime.add(spinnerAfterS);
        pAfterTime.add(new JLabel("seconds"));
        pAfter.add(pAfterTime);
        jCHAfter = new JCheckBox("Forever");
//        pAfter.add(jCHAfter);

⌨️ 快捷键说明

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