Source Code Cross Referenced for PassphraseDialog.java in  » Net » j2ssh » com » sshtools » common » authentication » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » j2ssh » com.sshtools.common.authentication 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  SSHTools - Java SSH2 API
003:         *
004:         *  Copyright (C) 2002-2003 Lee David Painter and Contributors.
005:         *
006:         *  Contributions made by:
007:         *
008:         *  Brett Smith
009:         *  Richard Pernavas
010:         *  Erwin Bolwidt
011:         *
012:         *  This program is free software; you can redistribute it and/or
013:         *  modify it under the terms of the GNU General Public License
014:         *  as published by the Free Software Foundation; either version 2
015:         *  of the License, or (at your option) any later version.
016:         *
017:         *  This program is distributed in the hope that it will be useful,
018:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020:         *  GNU General Public License for more details.
021:         *
022:         *  You should have received a copy of the GNU General Public License
023:         *  along with this program; if not, write to the Free Software
024:         *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
025:         */
026:        package com.sshtools.common.authentication;
027:
028:        import com.sshtools.common.ui.IconWrapperPanel;
029:        import com.sshtools.common.ui.ResourceIcon;
030:        import com.sshtools.common.ui.UIUtil;
031:
032:        import java.awt.BorderLayout;
033:        import java.awt.Color;
034:        import java.awt.Dialog;
035:        import java.awt.FlowLayout;
036:        import java.awt.Frame;
037:        import java.awt.GridBagConstraints;
038:        import java.awt.GridBagLayout;
039:        import java.awt.GridLayout;
040:        import java.awt.Insets;
041:        import java.awt.Window;
042:        import java.awt.event.ActionEvent;
043:        import java.awt.event.WindowAdapter;
044:        import java.awt.event.WindowEvent;
045:
046:        import javax.swing.BorderFactory;
047:        import javax.swing.JButton;
048:        import javax.swing.JDialog;
049:        import javax.swing.JLabel;
050:        import javax.swing.JPanel;
051:        import javax.swing.JPasswordField;
052:
053:        /**
054:         *
055:         *
056:         * @author $author$
057:         * @version $Revision: 1.15 $
058:         */
059:        public class PassphraseDialog extends JDialog {
060:            //  Statics
061:            final static String PASSPHRASE_ICON = "/com/sshtools/common/authentication/largepassphrase.png";
062:            JButton jButtonCancel = new JButton();
063:            JButton jButtonOK = new JButton();
064:            JLabel message = new JLabel("Enter passphrase");
065:            JPasswordField jPasswordField = new JPasswordField(20);
066:            boolean userCancelled = false;
067:
068:            /**
069:             * Creates a new PassphraseDialog object.
070:             */
071:            public PassphraseDialog() {
072:                super ((Frame) null, "Passphrase", true);
073:                init(null);
074:            }
075:
076:            /**
077:             * Creates a new PassphraseDialog object.
078:             *
079:             * @param parent
080:             */
081:            public PassphraseDialog(Frame parent) {
082:                super (parent, "Passphrase", true);
083:                init(parent);
084:            }
085:
086:            /**
087:             * Creates a new PassphraseDialog object.
088:             *
089:             * @param parent
090:             * @param identity
091:             */
092:            public PassphraseDialog(Frame parent, String identity) {
093:                super (parent, "Passphrase", true);
094:                init(parent);
095:                setTitle(identity + " - Identity");
096:            }
097:
098:            /**
099:             * Creates a new PassphraseDialog object.
100:             *
101:             * @param parent
102:             */
103:            public PassphraseDialog(Dialog parent) {
104:                super (parent, "Passphrase", true);
105:                init(parent);
106:            }
107:
108:            /*public void setVisible(boolean visible) {
109:            if (visible) {
110:            UIUtil.positionComponent(UIUtil.CENTER, PassphraseDialog.this);
111:            }
112:            }*/
113:
114:            /**
115:             *
116:             *
117:             * @return
118:             */
119:            public boolean isCancelled() {
120:                return userCancelled;
121:            }
122:
123:            /**
124:             *
125:             *
126:             * @param message
127:             */
128:            public void setMessage(String message) {
129:                this .message.setText(message);
130:            }
131:
132:            /**
133:             *
134:             *
135:             * @param color
136:             */
137:            public void setMessageForeground(Color color) {
138:                message.setForeground(color);
139:            }
140:
141:            /**
142:             *
143:             *
144:             * @return
145:             */
146:            public char[] getPassphrase() {
147:                return jPasswordField.getPassword();
148:            }
149:
150:            void init(Window parent) {
151:                getContentPane().setLayout(new GridLayout(1, 1));
152:
153:                if (parent != null) {
154:                    this .setLocationRelativeTo(parent);
155:                }
156:
157:                try {
158:                    jbInit();
159:                    pack();
160:                    UIUtil.positionComponent(UIUtil.CENTER,
161:                            PassphraseDialog.this );
162:                } catch (Exception ex) {
163:                    ex.printStackTrace();
164:                }
165:            }
166:
167:            void jButtonCancel_actionPerformed(ActionEvent e) {
168:                userCancelled = true;
169:                setVisible(false);
170:            }
171:
172:            void jButtonOK_actionPerformed(ActionEvent e) {
173:                userCancelled = false;
174:                setVisible(false);
175:            }
176:
177:            void jbInit() throws Exception {
178:                // Add a window listener to see when the window closes without
179:                // selecting OK
180:                addWindowListener(new WindowAdapter() {
181:                    public void windowClosing(WindowEvent evt) {
182:                        userCancelled = true;
183:                    }
184:                });
185:
186:                //  Ok button
187:                jButtonOK
188:                        .addActionListener(new java.awt.event.ActionListener() {
189:                            public void actionPerformed(ActionEvent e) {
190:                                jButtonOK_actionPerformed(e);
191:                            }
192:                        });
193:                jButtonOK.setText("OK");
194:                jButtonOK.setMnemonic('o');
195:                getRootPane().setDefaultButton(jButtonOK);
196:
197:                //  Cancel button
198:                jButtonCancel.setText("Cancel");
199:                jButtonCancel.setMnemonic('c');
200:                jButtonCancel
201:                        .addActionListener(new java.awt.event.ActionListener() {
202:                            public void actionPerformed(ActionEvent e) {
203:                                jButtonCancel_actionPerformed(e);
204:                            }
205:                        });
206:
207:                //  Passphrase panel
208:                JPanel passphrasePanel = new JPanel(new GridBagLayout());
209:                GridBagConstraints gbc = new GridBagConstraints();
210:                gbc.fill = GridBagConstraints.HORIZONTAL;
211:                gbc.anchor = GridBagConstraints.WEST;
212:                gbc.insets = new Insets(0, 2, 2, 2);
213:                gbc.weightx = 1.0;
214:                UIUtil.jGridBagAdd(passphrasePanel, message, gbc,
215:                        GridBagConstraints.REMAINDER);
216:                UIUtil.jGridBagAdd(passphrasePanel, jPasswordField, gbc,
217:                        GridBagConstraints.REMAINDER);
218:
219:                //  Create the center banner panel
220:                IconWrapperPanel centerPanel = new IconWrapperPanel(
221:                        new ResourceIcon(PASSPHRASE_ICON), passphrasePanel);
222:                centerPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4,
223:                        4));
224:
225:                //
226:                JPanel buttonPanel = new JPanel(new GridBagLayout());
227:                gbc = new GridBagConstraints();
228:                gbc.fill = GridBagConstraints.HORIZONTAL;
229:                gbc.anchor = GridBagConstraints.CENTER;
230:                gbc.insets = new Insets(6, 6, 0, 0);
231:                gbc.weighty = 1.0;
232:                UIUtil.jGridBagAdd(buttonPanel, jButtonOK, gbc,
233:                        GridBagConstraints.RELATIVE);
234:                UIUtil.jGridBagAdd(buttonPanel, jButtonCancel, gbc,
235:                        GridBagConstraints.REMAINDER);
236:
237:                JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT,
238:                        0, 0));
239:                southPanel.add(buttonPanel);
240:
241:                //  Wrap the whole thing in an empty border
242:                JPanel mainPanel = new JPanel(new BorderLayout());
243:                mainPanel
244:                        .setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
245:                mainPanel.add(centerPanel, BorderLayout.CENTER);
246:                mainPanel.add(southPanel, BorderLayout.SOUTH);
247:
248:                //  Build the main panel
249:                getContentPane().add(mainPanel);
250:
251:                //
252:                jPasswordField.grabFocus();
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.