author | Dan Labrecque <Dan.Labrecque@oracle.com> |
Tue, 14 Dec 2010 14:54:59 -0500 | |
changeset 624 | 23c2892e582e |
parent 601 | 9d4e3e0ee603 |
child 625 | 0ad7f2393529 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
5 |
* Common Development and Distribution License (the "License"). |
|
6 |
* You may not use this file except in compliance with the License. |
|
7 |
* |
|
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
||
22 |
/* |
|
601
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
23 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 24 |
*/ |
25 |
||
26 |
package org.opensolaris.os.vp.client.swing; |
|
27 |
||
257
65e4eb8680e9
7973 login dialog should be modal to window used by the topmost Control on the navigation stack
Stephen Talley <stephen.talley@sun.com>
parents:
256
diff
changeset
|
28 |
import java.awt.*; |
0 | 29 |
import java.io.File; |
30 |
import java.security.cert.Certificate; |
|
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
31 |
import java.util.List; |
0 | 32 |
import org.opensolaris.os.vp.client.common.*; |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
33 |
import org.opensolaris.os.vp.panel.common.*; |
487
09d92217e10c
15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents:
478
diff
changeset
|
34 |
import org.opensolaris.os.vp.panel.common.action.*; |
219
57841c113efe
6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents:
79
diff
changeset
|
35 |
import org.opensolaris.os.vp.util.swing.GUIUtil; |
0 | 36 |
|
391 | 37 |
public class AppLoginManager extends RadLoginManager { |
0 | 38 |
// |
39 |
// Instance data |
|
40 |
// |
|
41 |
||
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
42 |
private HasWindow hasWindow; |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
43 |
private LoginPane loginPane; |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
44 |
private CertificatePane certPane; |
256
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
45 |
private LoginDialog dialog; |
0 | 46 |
|
47 |
// |
|
48 |
// Constructors |
|
49 |
// |
|
50 |
||
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
51 |
public AppLoginManager(ConnectionManager manager, HasWindow hasWindow) { |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
52 |
super(manager); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
53 |
this.hasWindow = hasWindow; |
0 | 54 |
} |
55 |
||
56 |
// |
|
399
c20561845781
13417 vestigial cacao references in javadoc
Stephen Talley <stephen.talley@sun.com>
parents:
391
diff
changeset
|
57 |
// RadLoginManager methods |
0 | 58 |
// |
59 |
||
60 |
@Override |
|
496
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
61 |
public ConnectionInfo[] getConnectionInfo(LoginRequest request, |
601
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
62 |
ConnectionInfo current) throws ActionAbortedException, |
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
63 |
ActionFailedException { |
0 | 64 |
|
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
65 |
final Window owner = hasWindow == null ? |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
66 |
null : hasWindow.getComponent(); |
256
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
67 |
|
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
68 |
if (dialog != null && dialog.getOwner() != owner) { |
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
69 |
dialog.dispose(); |
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
70 |
dialog = null; |
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
71 |
} |
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
72 |
|
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
73 |
if (dialog == null) { |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
74 |
// Lazy create |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
75 |
if (loginPane == null) { |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
76 |
loginPane = new LoginPane(); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
77 |
certPane = new CertificatePane(); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
78 |
} |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
79 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
80 |
dialog = new LoginDialog(owner, loginPane, certPane); |
256
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
81 |
} |
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
82 |
|
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
83 |
EventQueue.invokeLater( |
0 | 84 |
new Runnable() { |
85 |
@Override |
|
86 |
public void run() { |
|
256
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
87 |
dialog.setLocationRelativeTo(owner); |
0 | 88 |
} |
89 |
}); |
|
90 |
||
91 |
try { |
|
496
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
92 |
return super.getConnectionInfo(request, current); |
0 | 93 |
} finally { |
94 |
GUIUtil.invokeAndWait( |
|
95 |
new Runnable() { |
|
96 |
@Override |
|
97 |
public void run() { |
|
256
a570f2e29dbd
7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents:
219
diff
changeset
|
98 |
dialog.setVisible(false); |
0 | 99 |
} |
100 |
}); |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
@Override |
|
105 |
public File getTrustStoreFile() { |
|
106 |
return App.TRUSTSTORE_FILE; |
|
107 |
} |
|
108 |
||
109 |
@Override |
|
496
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
110 |
protected void promptForAck(LoginRequest request) |
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
111 |
throws ActionAbortedException { |
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
112 |
|
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
113 |
dialog.getLoginPane().promptForAck(request); |
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
114 |
} |
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
115 |
|
3e406d128be1
15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents:
487
diff
changeset
|
116 |
@Override |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
117 |
protected void promptForCertificate( |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
118 |
String host, Certificate certificate) throws ActionAbortedException { |
0 | 119 |
|
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
120 |
dialog.getCertificatePane().promptForCertificate(host, certificate); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
121 |
} |
0 | 122 |
|
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
123 |
@Override |
601
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
124 |
protected void promptForFailedRequest(LoginRequest request) { |
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
125 |
dialog.getLoginPane().promptForFailedRequest(request); |
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
126 |
} |
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
127 |
|
9d4e3e0ee603
7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents:
496
diff
changeset
|
128 |
@Override |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
129 |
protected void promptForHostAndUser(LoginRequest request) |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
130 |
throws ActionAbortedException { |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
131 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
132 |
dialog.getLoginPane().promptForHostAndUser(request); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
133 |
} |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
134 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
135 |
@Override |
624
23c2892e582e
17520 - "Change role..." needs better behavior when no roles
Dan Labrecque <Dan.Labrecque@oracle.com>
parents:
601
diff
changeset
|
136 |
protected void promptForEnsureRoles(LoginRequest request) { |
23c2892e582e
17520 - "Change role..." needs better behavior when no roles
Dan Labrecque <Dan.Labrecque@oracle.com>
parents:
601
diff
changeset
|
137 |
dialog.getLoginPane().promptForEnsureRoles(request); |
23c2892e582e
17520 - "Change role..." needs better behavior when no roles
Dan Labrecque <Dan.Labrecque@oracle.com>
parents:
601
diff
changeset
|
138 |
} |
23c2892e582e
17520 - "Change role..." needs better behavior when no roles
Dan Labrecque <Dan.Labrecque@oracle.com>
parents:
601
diff
changeset
|
139 |
|
23c2892e582e
17520 - "Change role..." needs better behavior when no roles
Dan Labrecque <Dan.Labrecque@oracle.com>
parents:
601
diff
changeset
|
140 |
@Override |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
141 |
protected void promptForRole(LoginRequest request, List<String> roles) |
487
09d92217e10c
15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents:
478
diff
changeset
|
142 |
throws ActionAbortedException, ActionRegressedException { |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
143 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
144 |
dialog.getLoginPane().promptForRole(request, roles); |
0 | 145 |
} |
146 |
||
147 |
@Override |
|
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
148 |
protected void promptForRoleAuth(LoginRequest request, |
487
09d92217e10c
15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents:
478
diff
changeset
|
149 |
List<LoginProperty> properties) throws ActionAbortedException, |
09d92217e10c
15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents:
478
diff
changeset
|
150 |
ActionRegressedException { |
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
151 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
152 |
dialog.getLoginPane().promptForRoleAuth(request, properties); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
153 |
} |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
154 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
155 |
@Override |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
156 |
protected void promptForUserAuth(LoginRequest request, |
487
09d92217e10c
15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents:
478
diff
changeset
|
157 |
List<LoginProperty> properties) throws ActionAbortedException, |
09d92217e10c
15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents:
478
diff
changeset
|
158 |
ActionRegressedException { |
0 | 159 |
|
473
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
160 |
dialog.getLoginPane().promptForUserAuth(request, properties); |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
161 |
} |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
162 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
163 |
// |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
164 |
// AppLoginManager methods |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
165 |
// |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
166 |
|
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
167 |
public LoginDialog getDialog() { |
18f221b572ce
14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents:
438
diff
changeset
|
168 |
return dialog; |
0 | 169 |
} |
170 |
} |