annotate src/myVncProxy/AuthPanel.java @ 191:b2f0cd0cff6c default tip

Added tag Version-1.0 for changeset 79046b4e5990
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Nov 2011 15:52:44 +0900
parents 87b29d6039a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
87b29d6039a6 add package myVncProxy
e085711
parents: 0
diff changeset
1 package myVncProxy;
0
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
2 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
3 // Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
4 // Copyright (C) 2002-2006 Constantin Kaplinsky. All Rights Reserved.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
5 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
6 // This is free software; you can redistribute it and/or modify
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
7 // it under the terms of the GNU General Public License as published by
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
8 // the Free Software Foundation; either version 2 of the License, or
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
9 // (at your option) any later version.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
10 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
11 // This software is distributed in the hope that it will be useful,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
14 // GNU General Public License for more details.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
15 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
16 // You should have received a copy of the GNU General Public License
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
17 // along with this software; if not, write to the Free Software
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
19 // USA.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
20 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
21
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
22 import java.awt.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
23 import java.awt.event.*;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
24
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
25 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
26 // The panel which implements the user authentication scheme
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
27 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
28
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
29 class AuthPanel extends Panel implements ActionListener {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
30
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
31 TextField passwordField;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
32 Button okButton;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
33
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
34 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
35 // Constructor.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
36 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
37
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
38 public AuthPanel(VncViewer viewer)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
39 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
40 Label titleLabel = new Label("VNC Authentication", Label.CENTER);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
41 titleLabel.setFont(new Font("Helvetica", Font.BOLD, 18));
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
42
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
43 Label promptLabel = new Label("Password:", Label.CENTER);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
44
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
45 passwordField = new TextField(10);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
46 passwordField.setForeground(Color.black);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
47 passwordField.setBackground(Color.white);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
48 passwordField.setEchoChar('*');
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
49
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
50 okButton = new Button("OK");
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
51
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
52 GridBagLayout gridbag = new GridBagLayout();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
53 GridBagConstraints gbc = new GridBagConstraints();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
54
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
55 setLayout(gridbag);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
56
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
57 gbc.gridwidth = GridBagConstraints.REMAINDER;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
58 gbc.insets = new Insets(0,0,20,0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
59 gridbag.setConstraints(titleLabel,gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
60 add(titleLabel);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
61
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
62 gbc.fill = GridBagConstraints.NONE;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
63 gbc.gridwidth = 1;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
64 gbc.insets = new Insets(0,0,0,0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
65 gridbag.setConstraints(promptLabel,gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
66 add(promptLabel);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
67
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
68 gridbag.setConstraints(passwordField,gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
69 add(passwordField);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
70 passwordField.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
71
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
72 // gbc.ipady = 10;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
73 gbc.gridwidth = GridBagConstraints.REMAINDER;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
74 gbc.fill = GridBagConstraints.BOTH;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
75 gbc.insets = new Insets(0,20,0,0);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
76 gbc.ipadx = 30;
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
77 gridbag.setConstraints(okButton,gbc);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
78 add(okButton);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
79 okButton.addActionListener(this);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
80 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
81
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
82 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
83 // Move keyboard focus to the default object, that is, the password
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
84 // text field.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
85 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
86
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
87 public void moveFocusToDefaultField()
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
88 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
89 passwordField.requestFocus();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
90 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
91
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
92 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
93 // This method is called when a button is pressed or return is
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
94 // pressed in the password text field.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
95 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
96
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
97 public synchronized void actionPerformed(ActionEvent evt)
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
98 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
99 if (evt.getSource() == passwordField || evt.getSource() == okButton) {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
100 passwordField.setEnabled(false);
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
101 notify();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
102 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
103 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
104
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
105 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
106 // Wait for user entering a password, and return it as String.
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
107 //
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
108
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
109 public synchronized String getPassword() throws Exception
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
110 {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
111 try {
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
112 wait();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
113 } catch (InterruptedException e) { }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
114 return passwordField.getText();
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
115 }
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
116
30bb7074acb1 upload all file of tighVNCProxy
e085711
parents:
diff changeset
117 }