usr/src/java/vpanels/client/org/opensolaris/os/vp/client/swing/LoginPane.java
author Stephen Talley <stephen.talley@oracle.com>
Wed, 10 Nov 2010 10:03:10 -0500
changeset 601 9d4e3e0ee603
parent 600 c16a7e34499d
child 622 779060a588bc
permissions -rw-r--r--
7947 vp should fail if unable to connect to requested host
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
    23
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
package org.opensolaris.os.vp.client.swing;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
import java.awt.*;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    29
import java.util.*;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    30
import java.util.List;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    31
import javax.swing.*;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    32
import javax.swing.event.*;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    33
import javax.swing.text.JTextComponent;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    34
import org.opensolaris.os.vp.panel.common.*;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
    35
import org.opensolaris.os.vp.panel.common.action.*;
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
    36
import org.opensolaris.os.vp.util.misc.DialogMessage;
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
    37
import org.opensolaris.os.vp.util.misc.finder.Finder;
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 173
diff changeset
    38
import org.opensolaris.os.vp.util.swing.*;
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 173
diff changeset
    39
import org.opensolaris.os.vp.util.swing.layout.*;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    40
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    41
@SuppressWarnings({"serial"})
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    42
public class LoginPane extends DialogPane {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    43
    //
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    44
    // Inner classes
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    45
    //
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    46
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    47
    private static abstract class LoginField<C extends Component>
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    48
	extends JPanel {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    49
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    50
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    51
	// Instance data
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    52
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    53
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    54
	private JLabel label;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    55
	private C field;
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    56
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    57
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    58
	// Constructors
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    59
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    60
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    61
	public LoginField() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    62
	    super(new BorderLayout());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    63
	    setOpaque(false);
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    64
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    65
	    label = new JLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    66
	    add(label, BorderLayout.WEST);
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    67
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    68
	    field = createField();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
    69
	    add(field, BorderLayout.NORTH);
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    70
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    71
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    72
	//
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    73
	// LoginField methods
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    74
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    75
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    76
	public abstract C createField();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    77
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    78
	public JLabel getLabel() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    79
	    return label;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    80
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    81
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    82
	public C getField() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    83
	    return field;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    84
	}
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    85
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    86
	public void setEditable(boolean editable) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
    87
	    label.setVisible(!editable);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
    88
	    field.setVisible(editable);
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    89
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
    90
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    91
	public abstract String getValue();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    92
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    93
	public abstract void setValue(String text);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    94
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    95
	public String toDisplayableText(String value) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    96
	    return value;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    97
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    98
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
    99
	protected void updateLabel() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   100
	    getLabel().setText(toDisplayableText(getValue()));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   101
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   102
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   103
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   104
    private static class LoginTextField extends LoginField<JTextField> {
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   105
	//
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   106
	// LoginField methods
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   107
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   108
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   109
	@Override
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   110
	public JTextField createField() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   111
	    JTextField field = new JTextField(GUIUtil.getTextFieldWidth());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   112
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   113
	    field.getDocument().addDocumentListener(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   114
		new DocumentAdapter() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   115
		    @Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   116
		    public void docUpdate(DocumentEvent e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   117
			updateLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   118
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   119
		});
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   120
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   121
	    return field;
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   122
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   123
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   124
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   125
	public String getValue() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   126
	    String value = getField().getText();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   127
	    if (value.isEmpty()) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   128
		value = null;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   129
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   130
	    return value;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   131
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   132
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   133
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   134
	public void setValue(String text) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   135
	    getField().setText(text);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   136
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   137
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   138
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   139
    private static class LoginComboBox extends LoginField<JComboBox> {
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   140
	//
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   141
	// Instance data
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   142
	//
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   143
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   144
	private String nullText;
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   145
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   146
	//
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   147
	// Constructors
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   148
	//
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   149
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   150
	public LoginComboBox(String nullText) {
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   151
	    this.nullText = nullText;
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   152
	    updateLabel();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   153
	}
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   154
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   155
	//
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   156
	// LoginField methods
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   157
	//
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   158
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   159
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   160
	public JComboBox createField() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   161
	    final JComboBox field = new JComboBox();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   162
	    if (!(field.getModel() instanceof DefaultComboBoxModel)) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   163
		field.setModel(new DefaultComboBoxModel());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   164
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   165
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   166
	    final ListCellRenderer renderer = field.getRenderer();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   167
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   168
	    // Handle null values in the model
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   169
	    field.setRenderer(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   170
		new ListCellRenderer() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   171
		    @Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   172
                    public Component getListCellRendererComponent(JList list,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   173
			Object value, int index, boolean isSelected,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   174
			boolean cellHasFocus) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   175
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   176
                        return renderer.getListCellRendererComponent(list,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   177
			    toDisplayableText((String)value), index, isSelected,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   178
			    cellHasFocus);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   179
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   180
                });
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   181
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   182
	    field.getModel().addListDataListener(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   183
		new ListDataListener() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   184
		    @Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   185
		    public void contentsChanged(ListDataEvent e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   186
			updateLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   187
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   188
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   189
		    @Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   190
		    public void intervalAdded(ListDataEvent e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   191
			updateLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   192
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   193
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   194
		    @Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   195
		    public void intervalRemoved(ListDataEvent e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   196
			updateLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   197
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   198
		});
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   199
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   200
	    return field;
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   201
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   202
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   203
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   204
	public String getValue() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   205
	    return (String)getField().getSelectedItem();
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   206
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   207
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   208
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   209
	public void setValue(String text) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   210
	    getField().getModel().setSelectedItem(text);
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   211
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   212
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   213
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   214
	public String toDisplayableText(String value) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   215
	    return value == null ? nullText : value;
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   216
	}
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   217
    }
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   218
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   219
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   220
    // Static data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   221
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   222
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   223
    private static final Color COLOR_LABEL_ERROR = Color.red.darker();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   224
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   225
    private static final String LABEL_HOST =
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   226
	Finder.getString("login.label.host");
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 33
diff changeset
   227
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   228
    private static final String LABEL_USER =
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   229
	Finder.getString("login.label.user");
50
66ec0f9650dd 3253 tab-navigation from impromptu password dialog causes UI paralysis
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   230
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   231
    private static final String LABEL_ROLE =
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   232
	Finder.getString("login.label.role");
50
66ec0f9650dd 3253 tab-navigation from impromptu password dialog causes UI paralysis
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   233
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   234
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   235
    // Instance data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   236
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   237
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   238
    private JPanel fieldPanel;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   239
    private int nCoreFields;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   240
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   241
    private JLabel hostLabel;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   242
    private LoginField hostField;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   243
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   244
    private JLabel userLabel;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   245
    private LoginField userField;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   246
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   247
    private JLabel roleLabel;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   248
    private LoginComboBox roleField;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   249
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   250
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   251
    // Constructors
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   252
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   253
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   254
    public LoginPane() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   255
	createFieldPanel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   256
	setContent(fieldPanel, false, false);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   257
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   258
	SettingsButtonBar buttonBar = getButtonBar();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   259
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   260
	JButton cancel = buttonBar.getCancelButton();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   261
	cancel.addActionListener(setClickedButtonActionListener);
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   262
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   263
	// Move to left side of dialog
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   264
	buttonBar.remove(cancel);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   265
	buttonBar.add(cancel, 0);
50
66ec0f9650dd 3253 tab-navigation from impromptu password dialog causes UI paralysis
Stephen Talley <stephen.talley@sun.com>
parents: 40
diff changeset
   266
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   267
	JButton close = buttonBar.getCloseButton();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   268
	close.addActionListener(setClickedButtonActionListener);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   269
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   270
	JButton back = buttonBar.getBackButton();
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   271
	back.addActionListener(setClickedButtonActionListener);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   272
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   273
	JButton forward = buttonBar.getForwardButton();
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   274
	forward.addActionListener(setClickedButtonActionListener);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   275
	forward.setText(Finder.getString("login.button.forward"));
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   276
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   277
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   278
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   279
    // LoginPane methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   280
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   281
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   282
    public void promptForAck(final LoginRequest request)
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   283
	throws ActionAbortedException {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   284
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   285
	assert !EventQueue.isDispatchThread();
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   286
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   287
	final StringLoginProperty host = request.getHost();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   288
	final StringLoginProperty user = request.getUser();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   289
	final StringLoginProperty role = request.getRole();
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   290
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   291
	GUIUtil.invokeAndWait(
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   292
	    new Runnable() {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   293
		@Override
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   294
		public void run() {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   295
		    DialogMessage help = new DialogMessage(Finder.getString(
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   296
			"login.message.ack", host.getValue(),
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   297
			user.getValue(), role.getValue()));
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   298
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   299
		    List<DialogMessage> messages = request.getMessages();
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   300
		    messages.add(help);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   301
		    getMessagePanel().setMessages(messages);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   302
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   303
		    setHostInUI(host, true);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   304
		    setUserInUI(user, true);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   305
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   306
		    if (role.getValue() == null) {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   307
			hideRole();
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   308
		    } else {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   309
			setRoleInUI(role, true);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   310
		    }
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   311
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   312
		    clearAuthFields();
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   313
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   314
		    getButtonBar().getBackButton().setEnabled(false);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   315
		}
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   316
	});
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   317
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   318
	try {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   319
	    awaitForward();
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   320
	} catch (ActionRegressedException impossible) {
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   321
	}
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   322
    }
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   323
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   324
    public void promptForFailedRequest(final LoginRequest request) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   325
	assert !EventQueue.isDispatchThread();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   326
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   327
	final StringLoginProperty host = request.getHost();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   328
	final StringLoginProperty user = request.getUser();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   329
	final StringLoginProperty role = request.getRole();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   330
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   331
	GUIUtil.invokeAndWait(
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   332
	    new Runnable() {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   333
		@Override
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   334
		public void run() {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   335
		    DialogMessage help = new DialogMessage(Finder.getString(
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   336
                        "login.message.fail", host.getValue(), user.getValue(),
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   337
                        role.getValue()));
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   338
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   339
		    List<DialogMessage> messages = request.getMessages();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   340
		    messages.add(help);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   341
		    getMessagePanel().setMessages(messages);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   342
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   343
		    setHostInUI(host, true);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   344
		    setUserInUI(user, true);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   345
		    setRoleInUI(role, true);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   346
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   347
		    clearAuthFields();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   348
		}
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   349
	});
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   350
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   351
	awaitClose();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   352
    }
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   353
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   354
    public void promptForHostAndUser(final LoginRequest request)
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   355
	throws ActionAbortedException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   356
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   357
	assert !EventQueue.isDispatchThread();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   358
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   359
	final StringLoginProperty host = request.getHost();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   360
	final StringLoginProperty user = request.getUser();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   361
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   362
	GUIUtil.invokeAndWait(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   363
	    new Runnable() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   364
		@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   365
		public void run() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   366
		    String resource = "login.message.hostuser";
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   367
		    if (host.isEditable()) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   368
			resource += ".host";
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   369
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   370
		    if (user.isEditable()) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   371
			resource += ".user";
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   372
		    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   373
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   374
		    DialogMessage help = new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   375
			resource, host.getValue(), user.getValue()));
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   376
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   377
		    List<DialogMessage> messages = request.getMessages();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   378
		    messages.add(help);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   379
		    getMessagePanel().setMessages(messages);
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   380
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   381
		    setHostInUI(host, true);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   382
		    setUserInUI(user, true);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   383
		    hideRole();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   384
		    clearAuthFields();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   385
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   386
		    getButtonBar().getBackButton().setEnabled(false);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   387
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   388
	});
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   389
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   390
	try {
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   391
	    awaitForward();
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   392
	} catch (ActionRegressedException impossible) {
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   393
	}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   394
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   395
	setInProperty(host, hostField);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   396
	setInProperty(user, userField);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   397
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   398
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   399
    public void promptForRole(final LoginRequest request,
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   400
        final List<String> roles) throws ActionAbortedException,
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   401
        ActionRegressedException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   402
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   403
	assert !EventQueue.isDispatchThread();
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 33
diff changeset
   404
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   405
	final StringLoginProperty host = request.getHost();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   406
	final StringLoginProperty user = request.getUser();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   407
	final StringLoginProperty role = request.getRole();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   408
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   409
	GUIUtil.invokeAndWait(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   410
	    new Runnable() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   411
		@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   412
		public void run() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   413
		    DialogMessage help = new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   414
			"login.message.role", host.getValue(),
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   415
			user.getValue()));
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 33
diff changeset
   416
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   417
		    List<DialogMessage> messages = request.getMessages();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   418
		    messages.add(help);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   419
		    getMessagePanel().setMessages(messages);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   420
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   421
		    DefaultComboBoxModel model =
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   422
			(DefaultComboBoxModel)roleField.getField().getModel();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   423
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   424
		    model.removeAllElements();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   425
		    model.addElement(null);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   426
		    for (String r : roles) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   427
			model.addElement(r);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   428
		    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   429
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   430
		    setHostInUI(host, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   431
		    setUserInUI(user, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   432
		    setRoleInUI(role, true);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   433
		    clearAuthFields();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   434
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   435
		    getButtonBar().getBackButton().setEnabled(
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   436
			host.isEditable() || user.isEditable());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   437
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   438
	    });
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   439
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   440
	awaitForward();
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   441
	setInProperty(role, roleField);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   442
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   443
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   444
    /**
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   445
     * Prompt the user for role login information.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   446
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   447
     * @param    request - {@code LoginRequest}.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   448
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   449
     * @param    properties - A {@code List} of {@code LoginProperty} objects.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   450
     *		 NOTE: Only instances of {@code StringLoginProperty} and
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   451
     *		 {@code PasswordLoginProperty} are allowed.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   452
     */
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   453
    public void promptForRoleAuth(LoginRequest request,
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   454
        List<LoginProperty> properties) throws ActionAbortedException,
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   455
        ActionRegressedException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   456
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   457
	assert !EventQueue.isDispatchThread();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   458
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   459
	final StringLoginProperty host = request.getHost();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   460
	final StringLoginProperty user = request.getUser();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   461
	final StringLoginProperty role = request.getRole();
39
3dd6445bd848 2463 operations that require privilege should prompt user
Stephen Talley <stephen.talley@sun.com>
parents: 33
diff changeset
   462
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   463
	GUIUtil.invokeAndWait(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   464
	    new Runnable() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   465
		@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   466
		public void run() {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   467
		    setHostInUI(host, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   468
		    setUserInUI(user, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   469
		    setRoleInUI(role, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   470
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   471
                    getButtonBar().getBackButton().setEnabled(
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   472
                        host.isEditable() || user.isEditable() ||
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   473
                        role.isEditable());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   474
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   475
	    });
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   476
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   477
        DialogMessage help = new DialogMessage(Finder.getString(
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   478
            "login.message.roleauth", host.getValue(),
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   479
            user.getValue(), role.getValue()));
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   480
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   481
	promptForAuth(request.getMessages(), help, properties);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   482
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   483
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   484
    /**
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   485
     * Prompt the user for user login information.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   486
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   487
     * @param    request - {@code LoginRequest}.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   488
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   489
     * @param    properties - A {@code List} of {@code LoginProperty} objects.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   490
     *		 NOTE: Only instances of {@code StringLoginProperty} and
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   491
     *		 {@code PasswordLoginProperty} are allowed.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   492
     */
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   493
    public void promptForUserAuth(LoginRequest request,
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   494
        List<LoginProperty> properties) throws ActionAbortedException,
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   495
        ActionRegressedException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   496
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   497
	final StringLoginProperty host = request.getHost();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   498
	final StringLoginProperty user = request.getUser();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   499
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   500
	GUIUtil.invokeAndWait(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   501
	    new Runnable() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   502
		@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   503
		public void run() {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   504
		    setHostInUI(host, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   505
		    setUserInUI(user, false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   506
		    hideRole();
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   507
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   508
		    getButtonBar().getBackButton().setEnabled(
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   509
			host.isEditable() || user.isEditable());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   510
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   511
	    });
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   512
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   513
        DialogMessage help = new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   514
	    "login.message.userauth", host.getValue(), user.getValue()));
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   515
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   516
	promptForAuth(request.getMessages(), help, properties);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   517
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   518
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   519
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   520
    // Private methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   521
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   522
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   523
    private void awaitClose() {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   524
	SettingsButtonBar bar = getButtonBar();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   525
	AbstractButton closeButton = bar.getCloseButton();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   526
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   527
	for (AbstractButton button : bar.getButtons()) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   528
	    button.setVisible(button == closeButton);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   529
	}
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   530
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   531
	while (awaitClickedButton() != closeButton);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   532
    }
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   533
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   534
    private void awaitForward() throws ActionAbortedException,
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   535
	ActionRegressedException {
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   536
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   537
	SettingsButtonBar bar = getButtonBar();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   538
	AbstractButton backButton = bar.getBackButton();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   539
	AbstractButton forwardButton = bar.getForwardButton();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   540
	AbstractButton cancelButton = bar.getCancelButton();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   541
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   542
	for (AbstractButton button : bar.getButtons()) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   543
	    button.setVisible(button == backButton ||
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   544
		button == forwardButton || button == cancelButton);
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   545
	}
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   546
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   547
	JButton clicked = null;
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   548
	while (clicked != forwardButton) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   549
	    clicked = awaitClickedButton();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   550
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   551
	    if (clicked == backButton) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   552
		throw new ActionRegressedException();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   553
	    }
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   554
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   555
	    if (clicked == cancelButton) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   556
		throw new ActionAbortedException();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   557
	    }
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   558
	}
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   559
    }
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   560
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   561
    private void clearAuthFields() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   562
	// Remove all but the "core" fields (host, user, role)
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   563
	while (fieldPanel.getComponentCount() > nCoreFields) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   564
	    fieldPanel.remove(nCoreFields);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   565
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   566
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   567
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   568
    private void createFieldPanel() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   569
	hostField = new LoginTextField();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   570
	hostLabel = new JLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   571
	hostLabel.setLabelFor(hostField);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   572
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   573
	userField = new LoginTextField();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   574
	userLabel = new JLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   575
	userLabel.setLabelFor(userField);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   576
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   577
        roleField = new LoginComboBox(
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   578
	    Finder.getString("login.field.role.none"));
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   579
	roleLabel = new JLabel();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   580
	roleLabel.setLabelFor(roleField);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   581
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   582
	int gap = GUIUtil.getHalfGap();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   583
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   584
	HasAnchors a = new SimpleHasAnchors(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   585
	    HorizontalAnchor.LEFT, VerticalAnchor.CENTER);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   586
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   587
	TableLayout layout = new TableLayout(1, 2, gap, gap);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   588
	layout.setHorizontalAnchor(HorizontalAnchor.LEFT);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   589
	layout.setDefaultConstraint(a);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   590
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   591
	fieldPanel = new JPanel(layout);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   592
	fieldPanel.setOpaque(false);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   593
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   594
	fieldPanel.add(hostLabel);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   595
	fieldPanel.add(hostField);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   596
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   597
	fieldPanel.add(userLabel);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   598
	fieldPanel.add(userField);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   599
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   600
	fieldPanel.add(roleLabel);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   601
	fieldPanel.add(roleField);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   602
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   603
	nCoreFields = fieldPanel.getComponentCount();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   604
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   605
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   606
    private void hideRole() {
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   607
	roleLabel.setVisible(false);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   608
	roleField.setVisible(false);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   609
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   610
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   611
    /**
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   612
     * Prompt the user for login information.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   613
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   614
     * @param    messages - messages to instruct the user
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   615
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   616
     * @param    help - on-screen help.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   617
     *
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   618
     * @param    properties - A {@code List} of {@code LoginProperty} objects.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   619
     *		 NOTE: Only instances of {@code StringLoginProperty} and
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   620
     *		 {@code PasswordLoginProperty} are allowed.
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   621
     */
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   622
    private void promptForAuth(final List<DialogMessage> messages,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   623
        DialogMessage help, final List<LoginProperty> properties)
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   624
        throws ActionAbortedException, ActionRegressedException {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   625
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   626
	assert !EventQueue.isDispatchThread();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   627
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   628
	messages.add(help);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   629
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   630
	final Map<LoginProperty, JTextComponent> map =
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   631
	    new HashMap<LoginProperty, JTextComponent>();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   632
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   633
	GUIUtil.invokeAndWait(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   634
	    new Runnable() {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   635
		@Override
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   636
		public void run() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   637
		    getMessagePanel().setMessages(messages);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   638
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   639
		    clearAuthFields();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   640
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   641
		    int cols = GUIUtil.getTextFieldWidth();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   642
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   643
		    if (properties != null) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   644
			for (LoginProperty property : properties) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   645
			    JLabel label = new JLabel(property.getName());
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   646
			    JTextComponent field = null;
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   647
			    String value = null;
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   648
			    if (property instanceof PasswordLoginProperty) {
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   649
				field = new JPasswordField(cols);
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   650
				value = new String((char[])property.getValue());
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   651
			    } else {
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   652
				field = new JTextField(cols);
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   653
				value = (String)property.getValue();
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   654
			    }
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   655
			    field.setText(value);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   656
			    fieldPanel.add(label);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   657
			    fieldPanel.add(field);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   658
			    map.put(property, field);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   659
			}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   660
		    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   661
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   662
	    });
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   663
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   664
	final boolean[] success = {false};
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   665
	try {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   666
	    awaitForward();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   667
	    success[0] = true;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   668
	} finally {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   669
	    GUIUtil.invokeAndWait(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   670
		new Runnable() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   671
		    @Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   672
		    public void run() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   673
			for (Map.Entry<LoginProperty, JTextComponent> entry :
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   674
			    map.entrySet()) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   675
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   676
			    JTextComponent field = entry.getValue();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   677
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   678
			    if (success[0]) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   679
				if (field instanceof JPasswordField) {
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   680
				    ((PasswordLoginProperty)entry.getKey()).
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   681
					setValue(((JPasswordField)field).
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   682
					getPassword());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   683
				} else {
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   684
				    ((StringLoginProperty)entry.getKey()).
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   685
					setValue(field.getText());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   686
				}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   687
			    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   688
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   689
			    // Remove any sensitive information
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   690
			    field.setText(null);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   691
			}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   692
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   693
		});
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   694
	}
256
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   695
    }
a570f2e29dbd 7971 login dialog should be external and modal
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   696
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   697
    private void setHostInUI(StringLoginProperty property, boolean allowEdit) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   698
	setInUI(property, hostLabel, hostField, LABEL_HOST, allowEdit);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   699
    }
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   700
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   701
    private void setInProperty(StringLoginProperty property, LoginField field) {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   702
	if (property.isEditable()) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   703
	    property.setValue(field.getValue());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   704
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   705
	property.setErrored(false);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   706
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   707
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   708
    private void setInUI(StringLoginProperty property, JLabel label,
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   709
        final LoginField field, String defaultLabel, boolean allowEdit) {
76
af5a052967b0 3415 login panel error details shouldn't launch another window
Stephen Talley <stephen.talley@sun.com>
parents: 74
diff changeset
   710
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   711
	String labelText = property.getName();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   712
	label.setText(labelText != null ? labelText : defaultLabel);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   713
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   714
	boolean editable = allowEdit && property.isEditable();
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   715
	Color foreground = null;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   716
	int style = Font.PLAIN;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   717
	if (property.isErrored()) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   718
	    foreground = COLOR_LABEL_ERROR;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   719
	    style = Font.BOLD;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   720
	    if (editable) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   721
		EventQueue.invokeLater(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   722
		    new Runnable() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   723
			@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   724
			public void run() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   725
			    Component comp = field.getField();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   726
			    if (comp instanceof JTextComponent) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   727
				((JTextComponent)comp).selectAll();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   728
			    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   729
			    comp.requestFocusInWindow();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   730
			}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   731
		    });
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   732
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   733
	}
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   734
	label.setForeground(foreground);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   735
	label.setFont(label.getFont().deriveFont(style));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   736
	label.setVisible(true);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   737
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   738
	field.setValue(property.getValue());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   739
	field.setEditable(editable);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 470
diff changeset
   740
	field.setVisible(true);
33
3c3f3e185efd 2506 "Specify a role..." should use a flip-down triangle, not a link
Stephen Talley <stephen.talley@sun.com>
parents: 19
diff changeset
   741
    }
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   742
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   743
    private void setRoleInUI(StringLoginProperty property, boolean allowEdit) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   744
	setInUI(property, roleLabel, roleField, LABEL_ROLE, allowEdit);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   745
    }
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   746
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 591
diff changeset
   747
    private void setUserInUI(StringLoginProperty property, boolean allowEdit) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   748
	setInUI(property, userLabel, userField, LABEL_USER, allowEdit);
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 484
diff changeset
   749
    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   750
}