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

📄 dialogauthenticator.java

📁 JXTA&#8482 is a set of open, generalized peer-to-peer (P2P) protocols that allow any networked devi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            cancelButton.addActionListener(this);            buttonPanel.add(cancelButton);                        c.gridx = 0;            c.gridy = 3;            c.gridwidth = 2;            c.anchor = GridBagConstraints.LAST_LINE_END;            c.fill = GridBagConstraints.VERTICAL;            cancelButton.addActionListener(this);            contentPane.add(buttonPanel, c);                        setContentPane(contentPane);                        if (initKeyStore) {                identityPassField.requestFocusInWindow();            } else {                storePassField.requestFocusInWindow();            }        }                /**         * Handler for key events.         **/        private class PasswordDialogKeyHandler extends KeyAdapter {            /**             *  {@inheritDoc}             **/            @Override            public void keyReleased(KeyEvent e) {                setOKState();            }        }                /**         **/        private void setOKState() {            boolean enableOK = false;                        if (initKeyStore) {                enableOK = (null                        != PSEUtils.pkcs5_Decrypt_pbePrivateKey(identityPassField.getPassword()                        ,                        seedCert.getPublicKey().getAlgorithm(), seedKey));                                storePassLabel.setEnabled(enableOK);                storePassField.setEnabled(enableOK);            } else {                boolean enableIdentityList = false;                                ID[] roots = getIdentities(storePassField.getPassword());                                if (null != roots) {                    Iterator eachRoot = Arrays.asList(roots).iterator();                                        while (eachRoot.hasNext()) {                        ID aPeer = (ID) eachRoot.next();                                                try {                            X509Certificate aCert = DialogAuthenticator.this.source.getPSEConfig().getTrustedCertificate(aPeer);                            JComboEntry anEntry = new JComboEntry(aPeer, aCert);                                                        if (!enableIdentityList) {                                enableIdentityList = true;                                identityList.removeAllItems();                                identityList.setSelectedIndex(-1);                            }                                                        identityList.addItem(anEntry);                            identityList.setSelectedIndex(0);                        } catch (Exception ignore) {                            continue;                        }                    }                }                                if (enableIdentityList) {                    identityList.setMaximumRowCount(identityList.getItemCount());                } else {                    identityList.removeAllItems();                    identityList.setSelectedIndex(-1);                    identityPassField.setText("");                }                                identityLabel.setEnabled(enableIdentityList);                identityList.setEnabled(enableIdentityList);                identityPassLabel.setEnabled(enableIdentityList);                identityPassField.setEnabled(enableIdentityList);            }                        if ((null != getIdentity()) && (null != getKeyStorePassword()) && (null != getIdentityPassword())) {                setAuth1_KeyStorePassword(getKeyStorePassword());                setAuth2Identity(getIdentity());                setAuth3_IdentityPassword(getIdentityPassword());                enableOK = isReadyForJoin();            }                        okButton.setEnabled(enableOK);        }                /**         *  {@inheritDoc}         **/        public void actionPerformed(ActionEvent e) {                        if (okButton == e.getSource()) {                canceled = false;                dispose();            } else if (cancelButton == e.getSource()) {                canceled = true;                dispose();            } else {}        }                public void showDialog() {            pack();            setLocationRelativeTo(null);                        setOKState();                        setVisible(true);        }                /**         *  Returns the KeyStore password.         *         *  @return the KeyStore password.         **/        public char[] getKeyStorePassword() {            if (!storePassField.isEnabled()) {                return null;            }                        char[] result = storePassField.getPassword();                        return result;        }                /**         *  Returns the selected Identity.         *         *  @return the selected Identity.         **/        public ID getIdentity() {            if (!identityList.isEnabled()) {                return null;            }                        JComboEntry selectedIdentity = (JComboEntry) identityList.getSelectedItem();                        if (null == selectedIdentity) {                return null;            }                        return selectedIdentity.itsID;        }                /**         *  Returns the Identity password.         *         *  @return the Identity password.         **/        public char[] getIdentityPassword() {            if (!identityPassField.isEnabled()) {                return null;            }                        char[] result = identityPassField.getPassword();                        return result;        }                /**         *  Returns the final state of the dialog. Until the "OK" button is         *  pressed the dialog is "cancelled".         *         *  @param returns the final state of the dialog.         **/        public boolean wasCanceled() {            return canceled;        }    }        /**     * Creates an authenticator for the PSE membership service. Anything entered     * into the identity info section of the Authentication credential is     * ignored.     *     *  @param source The instance of the PSE membership service which     *  created this authenticator.     *  @param application Anything entered into the identity info section of     *  the Authentication credential is ignored.     **/    DialogAuthenticator(PSEMembershipService source, AuthenticationCredential application) {        super(source, application);                // XXX 20010328 bondolo@jxta.org Could do something with the authentication credential here.    }        /**     * Creates an authenticator for the PSE membership service. Anything entered     * into the identity info section of the Authentication credential is     * ignored.     *     *  @param source The instance of the PSE membership service which     *  created this authenticator.     *  @param application Anything entered into the identity info section of     *  the Authentication credential is ignored.     **/    DialogAuthenticator(PSEMembershipService source, AuthenticationCredential application, X509Certificate seedCert, EncryptedPrivateKeyInfo seedKey) {        super(source, application, seedCert, seedKey);                // XXX 20010328 bondolo@jxta.org Could do something with the authentication credential here.    }        /**     * {@inheritDoc}     **/    @Override    public String getMethodName() {        return "DialogAuthentication";    }        /**     * {@inheritDoc}     **/    public boolean interact() {        PasswordDialog p = new PasswordDialog(source.group.getPeerID(), seedCert, seedKey);                p.showDialog();                if (p.wasCanceled()) {            setAuth1_KeyStorePassword((char[]) null);            setAuth2Identity((ID) null);            setAuth3_IdentityPassword((char[]) null);                    } else {            setAuth1_KeyStorePassword(p.getKeyStorePassword());            setAuth2Identity(p.getIdentity());            setAuth3_IdentityPassword(p.getIdentityPassword());        }                return !p.wasCanceled();    }}

⌨️ 快捷键说明

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