1 | //
|
---|
2 | // Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
|
---|
3 | //
|
---|
4 | // This is free software; you can redistribute it and/or modify
|
---|
5 | // it under the terms of the GNU General Public License as published by
|
---|
6 | // the Free Software Foundation; either version 2 of the License, or
|
---|
7 | // (at your option) any later version.
|
---|
8 | //
|
---|
9 | // This software is distributed in the hope that it will be useful,
|
---|
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | // GNU General Public License for more details.
|
---|
13 | //
|
---|
14 | // You should have received a copy of the GNU General Public License
|
---|
15 | // along with this software; if not, write to the Free Software
|
---|
16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
---|
17 | // USA.
|
---|
18 | //
|
---|
19 | package mindbright.vnc;
|
---|
20 |
|
---|
21 | import java.awt.*;
|
---|
22 |
|
---|
23 | //
|
---|
24 | // The panel which implements the user authentication scheme
|
---|
25 | //
|
---|
26 |
|
---|
27 | public class authenticationPanel extends Panel {
|
---|
28 |
|
---|
29 | Label title, retry, prompt;
|
---|
30 | public TextField sshUser;
|
---|
31 | public TextField sshPassword;
|
---|
32 | public TextField vncHost;
|
---|
33 | public TextField vncPassword;
|
---|
34 | Button ok;
|
---|
35 |
|
---|
36 | //
|
---|
37 | // Constructor.
|
---|
38 | //
|
---|
39 |
|
---|
40 | public authenticationPanel() {
|
---|
41 |
|
---|
42 | title = new Label("SSH/VNC Authentication",Label.CENTER);
|
---|
43 | title.setFont(new Font("Helvetica", Font.BOLD, 18));
|
---|
44 |
|
---|
45 | sshUser = new TextField(10);
|
---|
46 | sshUser.setForeground(Color.black);
|
---|
47 | sshUser.setBackground(Color.white);
|
---|
48 |
|
---|
49 | sshPassword = new TextField(10);
|
---|
50 | sshPassword.setForeground(Color.black);
|
---|
51 | sshPassword.setBackground(Color.white);
|
---|
52 | sshPassword.setEchoCharacter('*');
|
---|
53 |
|
---|
54 | vncHost = new TextField(10);
|
---|
55 | vncHost.setForeground(Color.black);
|
---|
56 | vncHost.setBackground(Color.white);
|
---|
57 |
|
---|
58 | vncPassword = new TextField(10);
|
---|
59 | vncPassword.setForeground(Color.black);
|
---|
60 | vncPassword.setBackground(Color.white);
|
---|
61 | vncPassword.setEchoCharacter('*');
|
---|
62 |
|
---|
63 | ok = new Button("Connect");
|
---|
64 |
|
---|
65 | retry = new Label("",Label.CENTER);
|
---|
66 | retry.setFont(new Font("Courier", Font.BOLD, 12));
|
---|
67 |
|
---|
68 | GridBagLayout gridbag = new GridBagLayout();
|
---|
69 | GridBagConstraints gbc = new GridBagConstraints();
|
---|
70 |
|
---|
71 | setLayout(gridbag);
|
---|
72 |
|
---|
73 | gbc.gridwidth = GridBagConstraints.REMAINDER;
|
---|
74 | gbc.anchor = GridBagConstraints.CENTER;
|
---|
75 | gridbag.setConstraints(title,gbc);
|
---|
76 | add(title);
|
---|
77 |
|
---|
78 | gbc.fill = GridBagConstraints.HORIZONTAL;
|
---|
79 | gridbag.setConstraints(retry,gbc);
|
---|
80 | add(retry);
|
---|
81 |
|
---|
82 | gbc.fill = GridBagConstraints.NONE;
|
---|
83 | gbc.anchor = GridBagConstraints.WEST;
|
---|
84 | gbc.gridwidth = 1;
|
---|
85 |
|
---|
86 | gbc.gridy = 2;
|
---|
87 | prompt = new Label("SSH User",Label.CENTER);
|
---|
88 | gridbag.setConstraints(prompt,gbc);
|
---|
89 | add(prompt);
|
---|
90 | gridbag.setConstraints(sshUser,gbc);
|
---|
91 | add(sshUser);
|
---|
92 |
|
---|
93 | gbc.gridy = 3;
|
---|
94 | prompt = new Label("SSH Password",Label.CENTER);
|
---|
95 | gridbag.setConstraints(prompt,gbc);
|
---|
96 | add(prompt);
|
---|
97 | gridbag.setConstraints(sshPassword,gbc);
|
---|
98 | add(sshPassword);
|
---|
99 |
|
---|
100 | gbc.gridy = 4;
|
---|
101 | prompt = new Label("VNC Host [:display]",Label.CENTER);
|
---|
102 | gridbag.setConstraints(prompt,gbc);
|
---|
103 | add(prompt);
|
---|
104 | gridbag.setConstraints(vncHost,gbc);
|
---|
105 | add(vncHost);
|
---|
106 |
|
---|
107 | gbc.gridy = 5;
|
---|
108 | prompt = new Label("VNC Password",Label.CENTER);
|
---|
109 | gridbag.setConstraints(prompt,gbc);
|
---|
110 | add(prompt);
|
---|
111 | gridbag.setConstraints(vncPassword,gbc);
|
---|
112 | add(vncPassword);
|
---|
113 |
|
---|
114 | gbc.fill = GridBagConstraints.BOTH;
|
---|
115 | gbc.gridwidth = GridBagConstraints.REMAINDER;
|
---|
116 | gbc.gridy = 6;
|
---|
117 | gbc.insets = new Insets(5,5,5,5);
|
---|
118 | gridbag.setConstraints(ok,gbc);
|
---|
119 | add(ok);
|
---|
120 |
|
---|
121 | sshUser.requestFocus();
|
---|
122 | }
|
---|
123 |
|
---|
124 | //
|
---|
125 | // action() is called when a button is pressed or return is pressed in the
|
---|
126 | // password text field.
|
---|
127 | //
|
---|
128 |
|
---|
129 | public synchronized boolean action(Event evt, Object arg) {
|
---|
130 | if ((evt.target == vncPassword) || (evt.target == ok)) {
|
---|
131 | if(sshUser.getText().length() != 0 &&
|
---|
132 | sshPassword.getText().length() != 0 &&
|
---|
133 | vncHost.getText().length() != 0 &&
|
---|
134 | vncPassword.getText().length() != 0) {
|
---|
135 | retry.setText("Connecting...");
|
---|
136 | notify();
|
---|
137 | } else {
|
---|
138 | retry.setText("Please fill in all fields");
|
---|
139 | }
|
---|
140 | return true;
|
---|
141 | }
|
---|
142 | return false;
|
---|
143 | }
|
---|
144 |
|
---|
145 | //
|
---|
146 | // retry().
|
---|
147 | //
|
---|
148 |
|
---|
149 | public void retry(String reason) {
|
---|
150 | retry.setText(reason);
|
---|
151 | }
|
---|
152 |
|
---|
153 | }
|
---|