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

📄 swingui.java

📁 JXTA&#8482 is a set of open, generalized peer-to-peer (P2P) protocols that allow any networked devi
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            @Override            public void keyReleased(java.awt.event.KeyEvent evt) {                invitationPasswordFieldKeyReleased(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 1;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;        gridBagConstraints.insets = new java.awt.Insets(4, 2, 2, 4);        invitationTab.add(invitationPasswordField, gridBagConstraints);        invitationConfirmButton.setEnabled(!invitationTab.isEnabled());        invitationConfirmButton.setText("Confirm");        invitationConfirmButton.setToolTipText("Click to confirm the peer group invitation.");        invitationConfirmButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                invitationConfirmButtonActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 2;        gridBagConstraints.gridy = 1;        gridBagConstraints.ipady = 3;        gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);        invitationTab.add(invitationConfirmButton, gridBagConstraints);        getContentPane().setLayout(new java.awt.GridBagLayout());        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        setTitle("PSE Peer Group Sample");        addWindowListener(new java.awt.event.WindowAdapter() {            @Override            public void windowClosed(java.awt.event.WindowEvent evt) {                swingUIClosed(evt);            }        });        keyStorePasswordLabel.setLabelFor(keyStorePasswordField);        keyStorePasswordLabel.setText("Key Store Password");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.ipadx = 3;        gridBagConstraints.ipady = 3;        gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;        gridBagConstraints.insets = new java.awt.Insets(5, 3, 1, 0);        getContentPane().add(keyStorePasswordLabel, gridBagConstraints);        keyStorePasswordField.setColumns(16);        keyStorePasswordField.setNextFocusableComponent(invitationTab);        keyStorePasswordField.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                keyStorePasswordFieldActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_END;        gridBagConstraints.insets = new java.awt.Insets(4, 0, 1, 2);        getContentPane().add(keyStorePasswordField, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 1;        gridBagConstraints.gridwidth = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;        gridBagConstraints.ipadx = 3;        gridBagConstraints.ipady = 3;        gridBagConstraints.insets = new java.awt.Insets(1, 0, 1, 0);        getContentPane().add(tabs, gridBagConstraints);        authenticationStatus.setColumns(32);        authenticationStatus.setEditable(false);        authenticationStatus.setFont(new java.awt.Font("Dialog", 0, 10));        authenticationStatus.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED));        authenticationStatus.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                authenticationStatusActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 2;        gridBagConstraints.gridwidth = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.ipady = 3;        gridBagConstraints.anchor = java.awt.GridBagConstraints.LAST_LINE_END;        gridBagConstraints.insets = new java.awt.Insets(1, 0, 4, 0);        getContentPane().add(authenticationStatus, gridBagConstraints);        pack();    }    // </editor-fold>//GEN-END:initComponents    private void memberPasswordFieldKeyReleasedHandler(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_memberPasswordFieldKeyReleasedHandler        if (null == memberAuthenticator) {            try {                AuthenticationCredential application = new AuthenticationCredential(group, "StringAuthentication", null);                memberAuthenticator = (StringAuthenticator) membership.apply(application);            } catch (ProtocolNotSupportedException noAuthenticator) {                authenticationStatus.setText("Could not create authenticator: " + noAuthenticator.getMessage());                return;            }            memberAuthenticator.setAuth1_KeyStorePassword(keyStorePasswordField.getPassword());            memberAuthenticator.setAuth2Identity(group.getPeerID());        }        memberAuthenticator.setAuth3_IdentityPassword(memberPasswordField.getPassword());        memberAuthenticateButton.setEnabled(memberAuthenticator.isReadyForJoin());    }// GEN-LAST:event_memberPasswordFieldKeyReleasedHandler    private void memberPasswordFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_memberPasswordFieldActionPerformed        // TODO add your handling code here:    }// GEN-LAST:event_memberPasswordFieldActionPerformed    private void ownerPasswordFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_ownerPasswordFieldActionPerformed        // TODO add your handling code here:    }// GEN-LAST:event_ownerPasswordFieldActionPerformed    private void ownerPasswordFieldKeyReleasedHandler(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_ownerPasswordFieldKeyReleasedHandler        if (null == ownerAuthenticator) {            try {                AuthenticationCredential application = new AuthenticationCredential(group, "StringAuthentication", null);                ownerAuthenticator = (StringAuthenticator) membership.apply(application);            } catch (ProtocolNotSupportedException noAuthenticator) {                authenticationStatus.setText("Could not create authenticator: " + noAuthenticator.getMessage());                return;            }            ownerAuthenticator.setAuth1_KeyStorePassword(keyStorePasswordField.getPassword());            ownerAuthenticator.setAuth2Identity(group.getPeerGroupID());        }        ownerAuthenticator.setAuth3_IdentityPassword(ownerPasswordField.getPassword());        ownerAuthenticateButton.setEnabled(ownerAuthenticator.isReadyForJoin());    }// GEN-LAST:event_ownerPasswordFieldKeyReleasedHandler    private void adminInviteButtonActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_adminInviteButtonActionPerformed        if (null == memberCredential) {            authenticationStatus.setText("Not authenticated -- cannot create invitation.");            return;        }        X509Certificate[] issuerChain = memberCredential.getCertificateChain();        PrivateKey issuerKey = null;        try {            issuerKey = memberCredential.getPrivateKey();        } catch (IllegalStateException notLocal) {            ;        }        if (null == issuerKey) {            authenticationStatus.setText("Member credential is not a local login credential.");            return;        }        if (issuerChain.length < 2) {            authenticationStatus.setText("Member credential is not certified as a Peer Group Administrator.");            return;        }        if (!issuerChain[1].getPublicKey().equals(Main.PSE_SAMPLE_GROUP_ROOT_CERT.getPublicKey())) {            authenticationStatus.setText("Member credential is not certified as a Peer Group Administrator.");            return;        }        // Build the Module Impl Advertisemet we will use for our group.        ModuleImplAdvertisement pseImpl = Main.build_psegroup_impl_adv(parentgroup);        // Publish the Module Impl Advertisement to the group where the        // peergroup will be advertised. This should be done in every peer        // group in which the Peer Group is also advertised.        // We use the same expiration and lifetime that the Peer Group Adv        // will use (the default).        try {            parentgroup.getDiscoveryService().publish(pseImpl, PeerGroup.DEFAULT_LIFETIME, PeerGroup.DEFAULT_EXPIRATION);        } catch (IOException failed) {            ;        }        PeerGroupAdvertisement pse_pga = null;        PSEUtils.IssuerInfo issuer = new PSEUtils.IssuerInfo();        issuer.cert = issuerChain[0];        issuer.subjectPkey = issuerKey;        PSEUtils.IssuerInfo newcert = PSEUtils.genCert("Invitation", issuer);        List<X509Certificate> chain = new ArrayList<X509Certificate>();        chain.add(newcert.cert);        chain.addAll(Arrays.asList(issuerChain));        EncryptedPrivateKeyInfo encryptedInvitationKey = PSEUtils.pkcs5_Encrypt_pbePrivateKey(                adminInvitationPasswordField.getPassword(), newcert.subjectPkey, 10000);        // Create the invitation.        pse_pga = Main.build_psegroup_adv(pseImpl, (X509Certificate[]) chain.toArray(new X509Certificate[chain.size()])                ,                encryptedInvitationKey);        XMLDocument asXML = (XMLDocument) pse_pga.getDocument(MimeMediaType.XMLUTF8);        try {            JFileChooser fc = new JFileChooser();            // In response to a button click:            int returnVal = fc.showSaveDialog(this);            if (returnVal == JFileChooser.APPROVE_OPTION) {                FileWriter invitation_file = new FileWriter(fc.getSelectedFile());                asXML.sendToWriter(invitation_file);                invitation_file.close();                authenticationStatus.setText("Invitation created as file : " + fc.getSelectedFile().getAbsolutePath());            } else {                authenticationStatus.setText("Invitation creation cancelled.");            }        } catch (IOException failed) {            authenticationStatus.setText("Failed invitation creation : " + failed);        }    }// GEN-LAST:event_adminInviteButtonActionPerformed    private void ownerSignCSRButtonActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_ownerSignCSRButtonActionPerformed        if (null == ownerCredential) {            authenticationStatus.setText("Not authenticated -- cannot sign certificates.");            return;        }        PSEUtils.IssuerInfo issuer = null;        X509Certificate[] issuerChain = null;        issuerChain = ownerCredential.getCertificateChain();        PrivateKey issuerKey = null;        try {            issuerKey = ownerCredential.getPrivateKey();        } catch (IllegalStateException notLocal) {            ;        }        if (null == issuerKey) {            authenticationStatus.setText("Owner credential is not a local login credential.");            return;        }        issuer = new PSEUtils.IssuerInfo();        issuer.cert = issuerChain[0];        issuer.subjectPkey = issuerKey;        org.bouncycastle.jce.PKCS10CertificationRequest csr;        try {            JFileChooser fc = new JFileChooser();            // In response to a button click:            int returnVal = fc.showOpenDialog(this);            XMLDocument csr_doc = null;            if (returnVal == JFileChooser.APPROVE_OPTION) {                FileReader csr_file = new FileReader(fc.getSelectedFile());                csr_doc = (XMLDocument) StructuredDocumentFactory.newStructuredDocument(MimeMediaType.XMLUTF8, csr_file);                csr_file.close();            } else {                authenticationStatus.setText("Certificate signing cancelled.");

⌨️ 快捷键说明

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