Source Code Cross Referenced for AuthPanel.java in  » Web-Server » Jigsaw » org » w3c » jigadmin » gui » 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 » Web Server » Jigsaw » org.w3c.jigadmin.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // AuthPanel.java
002:        // $Id: AuthPanel.java,v 1.5 2000/08/16 21:37:31 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1998.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigadmin.gui;
007:
008:        import javax.swing.JPanel;
009:        import javax.swing.JTextField;
010:        import javax.swing.JPasswordField;
011:        import javax.swing.JButton;
012:        import javax.swing.JLabel;
013:        import javax.swing.BorderFactory;
014:
015:        import java.awt.event.ActionListener;
016:        import java.awt.event.ActionEvent;
017:
018:        import java.awt.GridLayout;
019:        import java.awt.GridBagLayout;
020:        import java.awt.GridBagConstraints;
021:        import java.awt.Insets;
022:
023:        import org.w3c.www.http.HttpCredential;
024:        import org.w3c.www.http.HttpFactory;
025:
026:        import org.w3c.tools.codec.Base64Encoder;
027:
028:        /**
029:         * The Authentication dialog.
030:         * @version $Revision: 1.5 $
031:         * @author  Benoît Mahé (bmahe@w3.org)
032:         */
033:        public class AuthPanel extends JPanel {
034:
035:            protected boolean ok;
036:            protected ServerBrowser sb;
037:            protected JTextField user;
038:            protected JPasswordField passwd;
039:
040:            /**
041:             * Constructor.
042:             * @param sb The ServerBrowser
043:             * @param name the realm name.
044:             */
045:            protected AuthPanel(ServerBrowser sb, String name) {
046:                this .sb = sb;
047:                this .ok = false;
048:
049:                ActionListener al = new ActionListener() {
050:                    public void actionPerformed(ActionEvent ae) {
051:                        if (ae.getActionCommand().equals("Ok")
052:                                || ae.getSource().equals(passwd)) {
053:                            if (!user.getText().equals("")) {
054:                                HttpCredential credential;
055:                                credential = HttpFactory
056:                                        .makeCredential("Basic");
057:                                String password = new String(passwd
058:                                        .getPassword());
059:                                Base64Encoder encoder = new Base64Encoder(user
060:                                        .getText()
061:                                        + ":" + password);
062:                                credential.setAuthParameter("cookie", encoder
063:                                        .processString());
064:                                AuthPanel.this .sb.getAdminContext()
065:                                        .setCredential(credential);
066:                                AuthPanel.this .sb.dispose(true);
067:                                done();
068:                            } else {
069:                                user.requestFocus();
070:                            }
071:                        } else if (ae.getActionCommand().equals("Cancel")) {
072:                            AuthPanel.this .sb.dispose(false);
073:                            done();
074:                        } else if (ae.getSource().equals(user)) {
075:                            passwd.requestFocus();
076:                        }
077:                    }
078:                };
079:
080:                GridBagLayout gbl = new GridBagLayout();
081:                GridBagConstraints gbc = new GridBagConstraints();
082:                GridBagLayout mgbl = new GridBagLayout();
083:                GridBagConstraints mgbc = new GridBagConstraints();
084:                JLabel l;
085:                JButton b;
086:                JPanel p = new JPanel(gbl);
087:
088:                user = new JTextField(10);
089:
090:                passwd = new JPasswordField(10);
091:                passwd.addActionListener(al);
092:
093:                gbc.fill = GridBagConstraints.HORIZONTAL;
094:                gbc.weightx = 0;
095:                gbc.weighty = 0;
096:                mgbc.fill = GridBagConstraints.NONE;
097:                mgbc.weightx = 0;
098:                mgbc.weighty = 0;
099:                mgbc.insets = new Insets(16, 10, 16, 5);
100:                setLayout(mgbl);
101:
102:                l = new JLabel("User name: ", JLabel.RIGHT);
103:                gbc.gridwidth = 1;
104:                gbl.setConstraints(l, gbc);
105:                p.add(l);
106:                gbc.gridwidth = GridBagConstraints.REMAINDER;
107:                gbl.setConstraints(user, gbc);
108:                p.add(user);
109:
110:                l = new JLabel("Password: ", JLabel.RIGHT);
111:                gbc.gridwidth = 1;
112:                gbl.setConstraints(l, gbc);
113:                p.add(l);
114:                gbc.gridwidth = GridBagConstraints.REMAINDER;
115:                gbl.setConstraints(passwd, gbc);
116:                p.add(passwd);
117:                mgbc.gridwidth = GridBagConstraints.REMAINDER;
118:                mgbl.setConstraints(p, mgbc);
119:                add(p);
120:
121:                // and now the usual button bar
122:                p = new JPanel(new GridLayout(1, 2, 20, 20));
123:                b = new JButton("Ok");
124:                b.addActionListener(al);
125:                p.add(b);
126:                b = new JButton("Cancel");
127:                b.addActionListener(al);
128:                p.add(b);
129:                mgbl.setConstraints(p, mgbc);
130:                add(p);
131:                if (name != null)
132:                    setBorder(BorderFactory
133:                            .createTitledBorder("Realm: " + name));
134:                else
135:                    setBorder(BorderFactory
136:                            .createTitledBorder("Authentication"));
137:            }
138:
139:            /**
140:             * Request the focus on the user TextField.
141:             */
142:            protected void getFocus() {
143:                user.requestFocus();
144:            }
145:
146:            /**
147:             * Notify All thread that the username/password are entered.
148:             */
149:            protected synchronized void done() {
150:                ok = true;
151:                notifyAll();
152:            }
153:
154:            /**
155:             * Wait until it's done.
156:             */
157:            public synchronized boolean waitForCompletion() {
158:                try {
159:                    wait();
160:                } catch (InterruptedException ex) {
161:                    //nothing to do
162:                }
163:                return ok;
164:            }
165:
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.