usr/src/java/vpanels/client/org/opensolaris/os/vp/client/common/RadLoginManager.java
author Stephen Talley <stephen.talley@oracle.com>
Mon, 28 Mar 2011 10:53:34 -0400
changeset 685 767674b0a2fb
parent 677 fbc09f84f958
child 700 fe2885279e58
permissions -rw-r--r--
18094 s/StringBuffer/StringBuilder/g
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
    23
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
package org.opensolaris.os.vp.client.common;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
import java.io.*;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    29
import java.net.*;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    30
import java.security.*;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    31
import java.security.cert.*;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    32
import java.security.cert.Certificate;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    33
import java.util.*;
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
    34
import java.util.logging.*;
438
5341dd3e7a04 14761 simplify login dialog
Stephen Talley <stephen.talley@sun.com>
parents: 433
diff changeset
    35
import javax.management.*;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    36
import javax.management.remote.*;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    37
import javax.swing.JOptionPane;
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
    38
import org.opensolaris.os.adr.Stability;
438
5341dd3e7a04 14761 simplify login dialog
Stephen Talley <stephen.talley@sun.com>
parents: 433
diff changeset
    39
import org.opensolaris.os.rad.*;
5341dd3e7a04 14761 simplify login dialog
Stephen Talley <stephen.talley@sun.com>
parents: 433
diff changeset
    40
import org.opensolaris.os.rad.api.pam.*;
668
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
    41
import org.opensolaris.os.rad.api.zoneadmin.*;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    42
import org.opensolaris.os.rad.jmx.RadConnector;
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
    43
import org.opensolaris.os.rad.jmx.IncompatibleVersionException;
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
    44
import org.opensolaris.os.rad.jmx.RadJMX;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    45
import org.opensolaris.os.vp.common.panel.MBeanUtil;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    46
import org.opensolaris.os.vp.panel.common.*;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
    47
import org.opensolaris.os.vp.panel.common.action.*;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    48
import org.opensolaris.os.vp.util.misc.*;
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
    49
import org.opensolaris.os.vp.util.misc.finder.Finder;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    50
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    51
public abstract class RadLoginManager {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
    52
    //
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    53
    // Inner classes
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    54
    //
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    55
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    56
    private static abstract class AuthPrompter {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    57
	//
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    58
	// Instance data
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    59
	//
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    60
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    61
	private boolean acknowledged;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    62
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    63
	//
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    64
	// AuthPrompter methods
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    65
	//
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    66
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    67
	/**
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    68
	 * _,__/|
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    69
	 *  `O.o'
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    70
	 * =(_x_)=
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    71
	 *    U
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    72
	 */
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    73
	protected void ack() {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    74
	    acknowledged = true;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    75
	}
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    76
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    77
	public boolean isAcknowledged() {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    78
	    return acknowledged;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    79
	}
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    80
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    81
	public abstract Block initiate(LoginRequest request,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    82
	    AuthenticatorMXBean auth) throws ActionAbortedException,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    83
	    ObjectException;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    84
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    85
	public abstract void prompt(LoginRequest request,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    86
	    List<LoginProperty> properties, boolean isFirst)
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
    87
	    throws ActionAbortedException, ActionRegressedException;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    88
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    89
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
    90
    private class UserPrompter extends AuthPrompter {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    91
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    92
	public Block initiate(LoginRequest request,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    93
	    AuthenticatorMXBean auth) throws ActionAbortedException,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    94
	    ObjectException {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    95
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
    96
	    setLoginStatus(request, Finder.getString("login.status.login",
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
    97
		request.getUser().getValue()));
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
    98
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
    99
	    return auth.login(Locale.getDefault().getLanguage(),
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   100
		request.getUser().getValue());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   101
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   102
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   103
	@Override
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   104
	public void prompt(LoginRequest request, List<LoginProperty> properties,
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   105
	    boolean isFirst) throws ActionAbortedException,
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   106
	    ActionRegressedException {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   107
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   108
	    try {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   109
		promptForAuth(request, properties, false, true, isFirst);
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   110
	    } finally {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   111
		ack();
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   112
		request.getHost().setErrored(false);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   113
		request.getUser().setErrored(false);
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   114
	    }
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   115
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   116
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   117
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   118
    private class RolePrompter extends AuthPrompter {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   119
	@Override
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   120
	public Block initiate(LoginRequest request,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   121
	    AuthenticatorMXBean auth) throws ActionAbortedException,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   122
	    ObjectException {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   123
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   124
	    setLoginStatus(request, Finder.getString("login.status.assume",
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   125
		request.getRole().getValue()));
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   126
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   127
	    return auth.assume(Locale.getDefault().getLanguage(),
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   128
		request.getRole().getValue());
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   129
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   130
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   131
	@Override
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   132
	public void prompt(LoginRequest request, List<LoginProperty> properties,
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   133
	    boolean isFirst) throws ActionAbortedException,
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   134
	    ActionRegressedException {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   135
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   136
	    try {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   137
		promptForAuth(request, properties, false, false, isFirst);
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   138
	    } finally {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   139
		ack();
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   140
		request.getRole().setErrored(false);
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   141
	    }
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   142
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   143
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   144
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   145
    private class ZoneUserPrompter extends AuthPrompter {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   146
	@Override
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   147
	public Block initiate(LoginRequest request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   148
	    AuthenticatorMXBean auth) throws ActionAbortedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   149
	    ObjectException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   150
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   151
	    return auth.login(Locale.getDefault().getLanguage(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   152
		request.getZoneUser().getValue());
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   153
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   154
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   155
	@Override
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   156
	public void prompt(LoginRequest request, List<LoginProperty> properties,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   157
	    boolean isFirst) throws ActionAbortedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   158
	    ActionRegressedException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   159
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   160
	    try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   161
		promptForAuth(request, properties, true, true, isFirst);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   162
	    } finally {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   163
		ack();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   164
		request.getZone().setErrored(false);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   165
		request.getZoneUser().setErrored(false);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   166
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   167
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   168
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   169
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   170
    private class ZoneRolePrompter extends AuthPrompter {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   171
	@Override
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   172
	public Block initiate(LoginRequest request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   173
	    AuthenticatorMXBean auth) throws ActionAbortedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   174
	    ObjectException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   175
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   176
	    return auth.assume(Locale.getDefault().getLanguage(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   177
		request.getZoneRole().getValue());
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   178
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   179
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   180
	@Override
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   181
	public void prompt(LoginRequest request, List<LoginProperty> properties,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   182
	    boolean isFirst) throws ActionAbortedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   183
	    ActionRegressedException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   184
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   185
	    try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   186
		promptForAuth(request, properties, true, false, isFirst);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   187
	    } finally {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   188
		ack();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   189
		request.getZoneRole().setErrored(false);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   190
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   191
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   192
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   193
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   194
    private static class LoginData {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   195
	//
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   196
	// Instance data
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   197
	//
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   198
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   199
	private LinkedList<ConnectionInfo> depChain =
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   200
	    new LinkedList<ConnectionInfo>();
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   201
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   202
	private LinkedList<Boolean> acks = new LinkedList<Boolean>();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   203
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   204
	//
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   205
	// LoginData methods
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   206
	//
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   207
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   208
	public boolean isAcknowledged() {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   209
	    return acks.peek();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   210
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   211
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   212
	public List<ConnectionInfo> getDepChain() {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   213
	    return depChain;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   214
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   215
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   216
	public ConnectionInfo peek(int offset) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   217
	    return depChain.get(offset);
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   218
	}
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   219
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   220
	public void pop() {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   221
	    depChain.pop();
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   222
	    acks.pop();
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   223
	}
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   224
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   225
	public void push(ConnectionInfo info, boolean acknowledged) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   226
	    depChain.push(info);
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   227
	    acks.push(acknowledged);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   228
	}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   229
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   230
	public void setDepChain(List<ConnectionInfo> depChain,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   231
	    boolean acknowledged) {
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   232
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   233
	    assert compatible(depChain);
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   234
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   235
	    this.depChain.clear();
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   236
	    acks.clear();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   237
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   238
	    for (int i = depChain.size() - 1; i >= 0; i--) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   239
		push(depChain.get(i), acknowledged);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   240
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   241
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   242
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   243
	//
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   244
	// Object methods
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   245
	//
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   246
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   247
	@Override
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   248
	public String toString() {
685
767674b0a2fb 18094 s/StringBuffer/StringBuilder/g
Stephen Talley <stephen.talley@oracle.com>
parents: 677
diff changeset
   249
	    StringBuilder buffer = new StringBuilder();
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   250
	    for (int i = depChain.size() - 1; i >= 0; i--) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   251
		buffer.append(String.format("%d. %s (%s)\n", i,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   252
		    depChain.get(i), acks.get(i) ? "acknowledged" :
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   253
		    "not acknowledged"));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   254
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   255
	    return buffer.toString();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   256
	}
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   257
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   258
	//
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   259
	// Private methods
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   260
	//
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   261
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   262
	private void clearConnectionsTo(int level) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   263
	    int size = depChain.size();
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   264
	    for (int i = size - 1; i >= level; i--) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   265
		depChain.remove(i);
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   266
	    }
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   267
	}
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   268
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   269
	private boolean compatible(List<ConnectionInfo> depChain) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   270
	    boolean compatible = false;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   271
	    if (depChain.size() == this.depChain.size() + 1) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   272
		compatible = true;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   273
		for (int i = 0, n = this.depChain.size(); i < n; i++) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   274
		    if (!this.depChain.get(i).equals(depChain.get(i + 1))) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   275
			compatible = false;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   276
			break;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   277
		    }
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   278
		}
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   279
	    }
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   280
	    return compatible;
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   281
	}
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   282
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   283
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   284
    //
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   285
    // Static data
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   286
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   287
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   288
    public static final String TRUSTSTORE_PASSWORD = "trustpass";
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   289
    public static final String LOCAL_USER = System.getProperty("user.name");
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   290
    public static final String LOCAL_HOST = "localhost";
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   291
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   292
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   293
    // Instance data
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   294
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   295
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   296
    private ConnectionManager connManager;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   297
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   298
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   299
    // Constructors
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   300
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   301
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   302
    public RadLoginManager(ConnectionManager connManager) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   303
	this.connManager = connManager;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   304
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   305
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   306
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   307
    // RadLoginManager methods
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   308
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   309
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   310
    /**
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   311
     * Creates an empty truststore file.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   312
     */
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   313
    protected void createTrustStore(File truststore) throws KeyStoreException,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   314
	IOException, NoSuchAlgorithmException, CertificateException {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   315
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   316
	File truststoreDir = truststore.getParentFile();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   317
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   318
	if (!truststoreDir.exists()) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   319
	    if (!truststoreDir.mkdirs()) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   320
		throw new IOException(
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   321
		    "could not create truststore directory: " +
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   322
		    truststoreDir.getAbsolutePath());
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   323
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   324
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   325
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   326
	KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   327
	char[] password = getTrustStorePassword().toCharArray();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   328
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   329
	// Create empty keystore
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   330
	keyStore.load(null, password);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   331
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   332
	FileOutputStream fos = new FileOutputStream(truststore);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   333
	keyStore.store(fos, password);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   334
	fos.close();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   335
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   336
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   337
    /**
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   338
     * Guides the user through the login process, then returns a dependency
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   339
     * chain of {@link ConnectionInfo}s.  The first element of the chain is the
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   340
     * {@code ConnectionInfo} that satisfies the given request.  Each additional
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   341
     * {@code ConnectionInfo} is a dependency of the previous {@code
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   342
     * ConnectionInfo}.
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   343
     * <p/>
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   344
     * For example, a role-based connection ("root@nerd (via talley)", say)
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   345
     * would have an dependency on the user-based connection ("talley@nerd")
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   346
     * used to create it.  The returned chain would contain the role-based
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   347
     * connection just before the user-based connection.
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   348
     * <p/>
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   349
     * This chain of {@code ConnectionInfo} dependencies can be {@link
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   350
     * ConnectionManager#add added} to the {@code ConnectionManager} for
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   351
     * automatic dependency-based management.
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   352
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   353
     * @param	    request
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   354
     *		    the {@link LoginRequest} encapsulating the preset values and
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   355
     *		    editability of each core {@link LoginProperty}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   356
     *
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   357
     * @param	    current
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   358
     *		    if non-{@code null}, ensures that the user is aware of any
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   359
     *		    change in login, preventing the use of cached connections
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   360
     *		    without the user's knowledge
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   361
     *
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   362
     * @exception   ActionAbortedException
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   363
     *		    if the user cancels the operation
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   364
     *
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   365
     * @exception   ActionFailedException
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   366
     *		    if the given request fails
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   367
     */
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   368
    @SuppressWarnings({"fallthrough"})
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   369
    public List<ConnectionInfo> getConnectionInfo(LoginRequest request,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   370
	LoginInfo current) throws ActionAbortedException, ActionFailedException
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   371
    {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   372
	LoginData data = new LoginData();
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   373
	Boolean doZone;
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   374
	for (int step = 0; ; ) {
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   375
	    try {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   376
		switch (step) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   377
		case 0:
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   378
		    gatherHostAndUserData(request, data);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   379
		    step++;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   380
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   381
		case 1:
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   382
		    gatherRoleData(request, data);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   383
		    step++;
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   384
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   385
		case 2:
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   386
		    doZone = request.getZonePrompt().getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   387
		    if (doZone != null && doZone) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   388
			gatherZoneHostAndUserData(request, data);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   389
		    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   390
		    step++;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   391
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   392
		case 3:
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   393
		    doZone = request.getZonePrompt().getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   394
		    if (doZone != null && doZone) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   395
			gatherZoneRoleData(request, data);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   396
		    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   397
		    step++;
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   398
		}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   399
		break;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   400
	    } catch (ActionRegressedException e) {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   401
		step--;
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   402
	    }
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   403
	}
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   404
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   405
	List<ConnectionInfo> depChain = data.getDepChain();
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   406
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   407
	// To prevent rogue connections, if the chosen connection differs from
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   408
	// the current one, ensure that the user has acknowledged it at some
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   409
	// point in the authentication process.  If not, prompt for
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   410
	// acknowledgement now.
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   411
	if (!data.isAcknowledged() && !depChain.get(0).matches(current)) {
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   412
	    promptForAck(request);
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   413
	}
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   414
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   415
	return depChain;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   416
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   417
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   418
    public ConnectionManager getConnectionManager() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   419
	return connManager;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   420
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   421
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   422
    /**
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   423
     * Gets the truststore file.
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   424
     */
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   425
    public abstract File getTrustStoreFile();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   426
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   427
    /**
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   428
     * Gets the truststore password.  This default implementation returns
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   429
     * "{@code trustpass}".
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   430
     */
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   431
    public String getTrustStorePassword() {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   432
	return TRUSTSTORE_PASSWORD;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   433
    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   434
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   435
    protected boolean handleCertFailure(String host, File truststore,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   436
	Certificate certificate) throws ActionAbortedException,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   437
	KeyStoreException, IOException, NoSuchAlgorithmException,
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   438
	CertificateException {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   439
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   440
	KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   441
	char[] password = getTrustStorePassword().toCharArray();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   442
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   443
	// Load truststore
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   444
	FileInputStream fis = new FileInputStream(truststore);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   445
	keyStore.load(fis, password);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   446
	fis.close();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   447
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   448
	// Does the truststore already contain the certificate?
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   449
	String alias = keyStore.getCertificateAlias(certificate);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   450
	if (alias != null) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   451
	    return false;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   452
	}
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   453
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   454
	boolean acceptNeeded = true;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   455
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   456
	if (NetUtil.isLocalAddress(host)) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   457
	    FileInputStream certFileIn = null;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   458
	    try {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   459
		File certFile = new File("/etc/rad/cert.pem");
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   460
		certFileIn = new FileInputStream(certFile);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   461
		Certificate localCert = CertificateFactory.
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   462
		    getInstance("X.509").generateCertificate(certFileIn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   463
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   464
		if (localCert.equals(certificate)) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   465
		    acceptNeeded = false;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   466
		}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   467
	    } catch (Throwable ignore) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   468
	    } finally {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   469
		IOUtil.closeIgnore(certFileIn);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   470
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   471
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   472
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   473
	if (acceptNeeded) {
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   474
	    // Display the certificate, prompt user to accept
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   475
	    promptForCertificate(host, certificate);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   476
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   477
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   478
	// Add certificate
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   479
	alias = ((X509Certificate)certificate).getIssuerDN().toString();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   480
	KeyStore.Entry entry =
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   481
	    new KeyStore.TrustedCertificateEntry(certificate);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   482
	keyStore.setEntry(alias, entry, null);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   483
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   484
	FileOutputStream fos = new FileOutputStream(truststore);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   485
	keyStore.store(fos, password);
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   486
	fos.close();
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   487
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   488
	return true;
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   489
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   490
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   491
    /**
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   492
     * Prompt the user to acknowledge or reject the imminent completion of the
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   493
     * given request.
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   494
     *
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   495
     * @param	    request
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   496
     *		    the {@link LoginRequest} encapsulating the preset values of
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   497
     *		    each core {@link LoginProperty}
496
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   498
     *
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   499
     * @exception   ActionAbortedException
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   500
     *		    if the user cancels the operation
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   501
     */
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   502
    protected abstract void promptForAck(LoginRequest request)
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   503
	throws ActionAbortedException;
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   504
3e406d128be1 15339 command line invocations shouldn't attempt to reuse connections
Stephen Talley <stephen.talley@oracle.com>
parents: 487
diff changeset
   505
    /**
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   506
     * Prompts the user to enter data for each of the given {@link
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   507
     * LoginProperty}s required for user or role authentication by the server.
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   508
     *
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   509
     * @param	    request
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   510
     *		    the {@link LoginRequest} encapsulating the preset values and
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   511
     *		    editability of each core {@link LoginProperty}
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   512
     *
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   513
     * @param	    properties
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   514
     *		    a {@code List} of {@link LoginProperty}s from the server
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   515
     *		    ({@code LoginProperty<String>} or {@code
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   516
     *		    PasswordLoginProperty} only)
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   517
     *
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   518
     * @exception   ActionAbortedException
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   519
     *		    if the user cancels the operation
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   520
     *
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   521
     * @exception   ActionRegressedException
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   522
     *		    if the chooses to re-edit the host or user fields
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   523
     *
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   524
     * @param	    isZone
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   525
     *		    {@code true} if prompting for a zone user or role
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   526
     *		    authentication
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   527
     *
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   528
     * @param	    isUserAuth
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   529
     *		    {@code true} if for user authentication, {@code false} if
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   530
     *		    for role authentication
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   531
     *
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   532
     * @param	    isFirst
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   533
     *		    {@code true} if this is the first prompt in the
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   534
     *		    authentication conversation
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   535
     */
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   536
    protected abstract void promptForAuth(LoginRequest request,
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   537
	List<LoginProperty> properties, boolean isZone, boolean isUserAuth,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   538
	boolean isFirst) throws ActionAbortedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   539
	ActionRegressedException;
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   540
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   541
    /**
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   542
     * Display the given {@code Certificate} details and prompt for user
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   543
     * confirmation to add it to the truststore.
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   544
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   545
     * @param	    host
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   546
     *		    the owner of the {@code Certificate}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   547
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   548
     * @param	    certificate
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   549
     *		    the {@code Certificate} to verify
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   550
     *
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   551
     * @exception   ActionAbortedException
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   552
     *		    if the user cancels the operation
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   553
     */
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   554
    protected abstract void promptForCertificate(String host,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   555
	Certificate certificate) throws ActionAbortedException;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   556
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   557
    /**
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   558
     * Prompts the user to acknowledge failure of the given request.
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   559
     *
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   560
     * @param	    request
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   561
     *		    the {@link LoginRequest} encapsulating the values and
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   562
     *		    error status of each core {@link LoginProperty}
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   563
     */
634
d7eeecd22f7f 17699 simplify notifications of failed login requests
Stephen Talley <stephen.talley@oracle.com>
parents: 630
diff changeset
   564
    protected abstract void promptForFailedRequest(LoginRequest request);
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   565
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   566
    /**
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   567
     * Prompt the user to enter host/user data, subject to the editability and
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   568
     * preset values of the host and user {@link LoginProperty}s of the given
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   569
     * request.
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   570
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   571
     * @param	    request
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   572
     *		    the {@link LoginRequest} encapsulating the preset values and
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   573
     *		    editability of each core {@link LoginProperty}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   574
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   575
     * @exception   ActionAbortedException
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   576
     *		    if the user cancels the operation
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   577
     */
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   578
    protected abstract void promptForHostAndUser(LoginRequest request)
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   579
	throws ActionAbortedException;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   580
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   581
    /**
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   582
     * Prompt the user to select a role, subject to the editability and preset
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   583
     * value of the role {@link LoginProperty} of the given request.
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   584
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   585
     * @param	    request
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   586
     *		    the {@link LoginRequest} encapsulating the preset values and
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   587
     *		    editability of each core {@link LoginProperty}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   588
     *
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   589
     * @param	    roles
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   590
     *		    a list of valid roles for the selected user
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   591
     *
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   592
     * @param	    isZone
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   593
     *		    {@code true} if prompting for a zone role
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   594
     *
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   595
     * @exception   ActionAbortedException
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   596
     *		    if the user cancels the operation
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   597
     *
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   598
     * @exception   ActionRegressedException
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
   599
     *		    if the chooses to re-edit the host or user fields
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   600
     */
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   601
    protected abstract void promptForRole(LoginRequest request,
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   602
	List<String> roles, boolean isZone) throws ActionAbortedException,
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   603
	ActionRegressedException;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   604
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   605
    /**
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   606
     * Prompt the user to enter zone/user data, subject to the editability and
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   607
     * preset values of the zone and user {@link LoginProperty}s of the given
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   608
     * request.
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   609
     *
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   610
     * @param	    request
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   611
     *		    the {@link LoginRequest} encapsulating the preset values and
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   612
     *		    editability of each core {@link LoginProperty}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   613
     *
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   614
     * @param	    zones
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   615
     *		    a list of valid zones for the selected host
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   616
     *
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   617
     * @exception   ActionAbortedException
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   618
     *		    if the user cancels the operation
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   619
     *
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   620
     * @exception   ActionRegressedException
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   621
     *		    if the chooses to re-edit the host or user fields
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   622
     */
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   623
    protected abstract void promptForZoneAndUser(LoginRequest request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   624
	List<String> zones) throws ActionAbortedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   625
	ActionRegressedException;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   626
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   627
    /**
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   628
     * Set login status.
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   629
     *
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   630
     * @param	    request
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   631
     *		    the {@link LoginRequest} encapsulating the preset values of
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   632
     *		    each core {@link LoginProperty}
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   633
     *
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   634
     * @param	    status
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   635
     *		    the login status
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   636
     */
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   637
    protected abstract void setLoginStatus(LoginRequest request, String status);
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   638
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   639
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   640
    // Private methods
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   641
    //
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   642
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   643
    @SuppressWarnings({"fallthrough"})
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   644
    private boolean authConverse(LoginRequest request, AuthenticatorMXBean auth,
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   645
	AuthPrompter prompter) throws ActionAbortedException,
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 496
diff changeset
   646
	ActionRegressedException {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   647
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   648
	List<DialogMessage> messages = request.getMessages();
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   649
	boolean isFirst = true;
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   650
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   651
	try {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   652
	    Block answer = prompter.initiate(request, auth);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   653
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   654
	    List<LoginProperty> properties =
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   655
		new LinkedList<LoginProperty>();
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   656
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   657
	    BlockType type;
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   658
	    while (true) {
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   659
		properties.clear();
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   660
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   661
		switch (type = answer.getType()) {
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   662
		case success:
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   663
		    // Display any lingering messages from the server
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   664
		    if (!messages.isEmpty()) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   665
			prompter.prompt(request, properties, isFirst);
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   666
			isFirst = false;
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   667
			messages.clear();
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   668
		    }
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   669
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   670
		    auth.complete();
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   671
		    return true;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   672
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   673
		case error:
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   674
		    return false;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   675
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   676
		default:
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   677
		    assert type == BlockType.conv;
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   678
		case conv:
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   679
		    for (Message m : answer.getMessages()) {
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   680
			String text = m.getMessage();
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   681
			switch (m.getStyle()) {
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   682
			case prompt_echo_off:
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   683
			    properties.add(new PasswordLoginProperty(
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   684
				text, new char[0], true));
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   685
			    break;
468
7fa83d27b9f3 14970 python client misformats setattr requests
David Powell <David.Powell@sun.com>
parents: 442
diff changeset
   686
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   687
			case prompt_echo_on:
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   688
			    properties.add(new LoginProperty<String>(
622
779060a588bc 17589 generic message shouldn't preface every step in PAM conversation
Stephen Talley <stephen.talley@oracle.com>
parents: 620
diff changeset
   689
				text, "", true));
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   690
			    break;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   691
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   692
			case error_msg:
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   693
			    messages.add(new DialogMessage(text,
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   694
				JOptionPane.ERROR_MESSAGE));
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   695
			    break;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   696
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   697
			case text_info:
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   698
			    messages.add(new DialogMessage(text,
619
7c1f7535bc78 17587 rad text_info messages are shown as error messages in login dialog
Stephen Talley <stephen.talley@oracle.com>
parents: 615
diff changeset
   699
				JOptionPane.INFORMATION_MESSAGE));
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   700
			    break;
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   701
			}
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   702
		    }
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   703
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   704
		    if (!properties.isEmpty()) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   705
			prompter.prompt(request, properties, isFirst);
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   706
			isFirst = false;
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   707
			messages.clear();
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   708
		    }
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   709
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   710
		    List<char[]> response = new LinkedList<char[]>();
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   711
		    for (LoginProperty property : properties) {
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   712
			Object value = property.getValue();
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   713
			if (value != null) {
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   714
			    response.add(value instanceof char[] ?
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   715
				(char[])value : ((String)value).toCharArray());
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   716
			}
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   717
		    }
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   718
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
   719
		    answer = auth.submit(response);
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   720
		    // clear out passwords
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   721
		    for (char[] res : response) {
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   722
			Arrays.fill(res, (char)0);
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   723
			res = null;
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   724
		    }
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   725
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   726
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   727
	} catch (ObjectException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   728
	    messages.add(new DialogMessage(
600
c16a7e34499d 17304 - Implement password type
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 598
diff changeset
   729
		Finder.getString("login.err.io",
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
   730
		request.getHost().getValue()),
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   731
		JOptionPane.ERROR_MESSAGE));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   732
	    return false;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   733
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   734
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   735
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   736
    private <T> T createMXBeanProxy(LoginRequest request, ConnectionInfo info,
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   737
	Class<T> ifaceClass, Stability s, String domain, String name)
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   738
	throws ActionFailedException {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   739
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   740
	MBeanServerConnection mbsc = getMBeanServerConnection(request, info);
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   741
	if (mbsc == null) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   742
	    return null;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   743
	}
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   744
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   745
	ObjectName oName = MBeanUtil.makeObjectName(domain, name);
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   746
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   747
	try {
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   748
	    return ifaceClass.cast(RadJMX.newMXBeanProxy(mbsc, oName,
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   749
		ifaceClass, s));
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   750
	} catch (IncompatibleVersionException e) {
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   751
	    List<DialogMessage> messages = request.getMessages();
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   752
	    messages.add(new DialogMessage(Finder.getString(
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   753
		"proxy.error.version", e.getClientVersion(),
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   754
		e.getServerVersion(), ifaceClass.getSimpleName()),
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   755
		JOptionPane.ERROR_MESSAGE));
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   756
	    requestFailed(request);
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   757
	} catch (JMException e) {
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   758
	    List<DialogMessage> messages = request.getMessages();
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   759
	    messages.add(new DialogMessage(Finder.getString(
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   760
		"proxy.error.general", oName),
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   761
		JOptionPane.ERROR_MESSAGE));
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   762
	    requestFailed(request);
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   763
	} catch (IOException e) {
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   764
	    List<DialogMessage> messages = request.getMessages();
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   765
	    messages.add(new DialogMessage(Finder.getString(
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   766
		"proxy.error.io", ifaceClass.getSimpleName()),
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   767
		JOptionPane.ERROR_MESSAGE));
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   768
	    requestFailed(request);
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   769
	}
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   770
	return null;
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   771
    }
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   772
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   773
    private AuthenticatorMXBean createAuthBean(LoginRequest request,
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   774
	ConnectionInfo info) throws ActionFailedException {
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   775
	return createMXBeanProxy(request, info, AuthenticatorMXBean.class,
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   776
	    Stability.PRIVATE, "org.opensolaris.os.rad", "authentication");
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   777
    }
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   778
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   779
    private JMXConnector createConnector(String host)
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   780
	throws KeyStoreException, NoSuchAlgorithmException,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   781
	CertificateException, MalformedURLException, IOException,
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   782
	ActionAbortedException {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   783
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   784
	if (NetUtil.isLocalAddress(host)) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   785
	    String[] paths = {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   786
		"/var/run/radsocket",
646
e1e91f5b0cb1 17807 implicit authorization over uds connection should be optional
Stephen Talley <stephen.talley@oracle.com>
parents: 645
diff changeset
   787
		"/var/run/radsocket-unauth"
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   788
	    };
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   789
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   790
	    for (String path : paths) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   791
		JMXServiceURL url = null;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   792
		try {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   793
		    url = new JMXServiceURL(RadConnector.PROTOCOL_UDS, "", 0,
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   794
			path);
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   795
		    return JMXConnectorFactory.connect(url);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   796
		} catch (IOException e) {
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   797
		    // Not necessarily an error
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   798
		    Logger.getLogger(getClass().getName()).log(Level.CONFIG,
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   799
			"unable to utilize local uds connector: " +
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   800
			(url == null ? path : url), e);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   801
		}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   802
	    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   803
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   804
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   805
	File truststore = getTrustStoreFile();
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   806
	if (!truststore.exists()) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   807
	    createTrustStore(truststore);
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   808
	}
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   809
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   810
	Map<String, Object> env = new HashMap<String, Object>();
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   811
	env.put(RadConnector.KEY_TLS_TRUSTSTORE,
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   812
	    truststore.getAbsolutePath());
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   813
	env.put(RadConnector.KEY_TLS_TRUSTPASS,
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   814
	    getTrustStorePassword());
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   815
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   816
	JMXServiceURL url = new JMXServiceURL(
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   817
	    RadConnector.PROTOCOL_TLS, host, 0);
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   818
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   819
	// Throws MalformedURLException
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   820
	JMXConnector connector = JMXConnectorFactory.newJMXConnector(url, null);
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   821
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   822
	for (;;) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   823
	    RadTrustManager mtm = new RadTrustManager();
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   824
	    env.put(RadConnector.KEY_TLS_RADMANAGER, mtm);
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   825
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   826
	    try {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   827
		connector.connect(env);
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   828
		break;
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   829
	    } catch (IOException e) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   830
		X509Certificate[] chain = mtm.getBadChain();
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   831
		if (chain == null) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   832
		    throw e;
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   833
		}
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   834
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   835
		if (!handleCertFailure(host, truststore, chain[0])) {
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   836
		    throw e;
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   837
		}
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   838
	    }
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   839
	}
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   840
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   841
	return connector;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   842
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   843
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   844
    private JMXConnector createConnector(LoginRequest request)
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   845
	throws ActionAbortedException {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   846
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   847
	JMXConnector connector = null;
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   848
	LoginProperty<String> host = request.getHost();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   849
	String hostVal = host.getValue();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   850
	List<DialogMessage> messages = request.getMessages();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   851
	boolean success = false;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   852
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   853
	try {
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   854
	    setLoginStatus(request, Finder.getString("login.status.host",
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   855
		hostVal));
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
   856
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   857
	    connector = createConnector(hostVal);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   858
	    success = true;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   859
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   860
	// Thrown by JMXConnector.connect
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   861
	} catch (UnknownHostException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   862
	    messages.add(new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   863
		"login.err.host.unknown", hostVal), JOptionPane.ERROR_MESSAGE));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   864
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   865
	// Thrown by JMXConnector.connect
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   866
	} catch (ConnectException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   867
	    messages.add(new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   868
		"login.err.host.refused", hostVal), JOptionPane.ERROR_MESSAGE));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   869
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   870
	// Thrown by JMXConnector.connect
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   871
	} catch (SecurityException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   872
	    messages.add(new DialogMessage(Finder.getString(
481
e35a695aa20c 15629 cryptic message when logging in with root user when root is a role (client)
Stephen Talley <stephen.talley@oracle.com>
parents: 478
diff changeset
   873
		"login.err.security", hostVal),
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   874
		JOptionPane.ERROR_MESSAGE));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   875
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   876
	// Thrown by createTrustStore
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   877
	} catch (KeyStoreException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   878
	    messages.add(new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   879
		"login.err.keystore", e.getMessage()),
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   880
		JOptionPane.ERROR_MESSAGE));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   881
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   882
	// Thrown by createTrustStore
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   883
	} catch (NoSuchAlgorithmException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   884
	    messages.add(new DialogMessage(Finder.getString(
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   885
		"login.err.keystore", e.getMessage()),
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   886
		JOptionPane.ERROR_MESSAGE));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   887
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   888
	// Thrown by getDaemonCertificateChain
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   889
	} catch (CertificateException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   890
	    messages.add(new DialogMessage(Finder.getString(
481
e35a695aa20c 15629 cryptic message when logging in with root user when root is a role (client)
Stephen Talley <stephen.talley@oracle.com>
parents: 478
diff changeset
   891
		"login.err.nocerts", hostVal),
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   892
		JOptionPane.ERROR_MESSAGE));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   893
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   894
	// Thrown by new JMXServiceURL
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   895
	} catch (MalformedURLException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   896
	    messages.add(new DialogMessage(Finder.getString(
481
e35a695aa20c 15629 cryptic message when logging in with root user when root is a role (client)
Stephen Talley <stephen.talley@oracle.com>
parents: 478
diff changeset
   897
		"login.err.url.invalid"),
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   898
		JOptionPane.ERROR_MESSAGE));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   899
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   900
	// Thrown by JMXConnector.connect et al
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   901
	} catch (IOException e) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   902
	    messages.add(new DialogMessage(Finder.getString(
481
e35a695aa20c 15629 cryptic message when logging in with root user when root is a role (client)
Stephen Talley <stephen.talley@oracle.com>
parents: 478
diff changeset
   903
		"login.err.io", hostVal),
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   904
		JOptionPane.ERROR_MESSAGE));
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   905
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   906
	} finally {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   907
	    if (!success) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   908
		host.setErrored(true);
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   909
	    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   910
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
   911
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
   912
	return connector;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   913
    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   914
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   915
    private ZoneAdminMXBean createZoneAdminBean(LoginRequest request,
677
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   916
	ConnectionInfo info) throws ActionFailedException {
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   917
	return createMXBeanProxy(request, info, ZoneAdminMXBean.class,
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   918
	    Stability.PRIVATE, "org.opensolaris.os.rad.api.zoneadmin",
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   919
	    "ZoneAdmin");
fbc09f84f958 18038 CLIENT-2: Expose interface versioning to JMX clients
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 668
diff changeset
   920
    }
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   921
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   922
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   923
    private JMXConnector createZoneConnector(LoginRequest request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   924
	ZoneAdminMXBean bean) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   925
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   926
	JMXConnector connector = null;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   927
	LoginProperty<String> zone = request.getZone();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   928
	String zoneVal = zone.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   929
	String zoneUserVal = request.getZoneUser().getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   930
	List<DialogMessage> messages = request.getMessages();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   931
	boolean success = false;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   932
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   933
	try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   934
	    JMXServiceURL url = new JMXServiceURL(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   935
		RadConnector.PROTOCOL_ZONEADMIN, zoneVal, 0, "/" + zoneUserVal);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   936
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   937
	    Map<String, Object> env = new HashMap<String, Object>();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   938
	    env.put(RadConnector.KEY_ZONEADMIN_MXBEAN, bean);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   939
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   940
	    connector = JMXConnectorFactory.connect(url, env);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   941
	    success = true;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   942
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   943
	// Thrown by JMXConnector.connect
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   944
	} catch (SecurityException e) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   945
	    messages.add(new DialogMessage(Finder.getString(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   946
		"login.err.zone.security", zoneVal, zoneUserVal),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   947
		JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   948
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   949
	// Thrown by new JMXServiceURL
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   950
	} catch (MalformedURLException e) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   951
	    messages.add(new DialogMessage(Finder.getString(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   952
		"login.err.url.invalid"), JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   953
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   954
	// Thrown by JMXConnector.connect et al
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   955
	} catch (IOException e) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   956
	    messages.add(new DialogMessage(Finder.getString(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   957
		"login.err.io", zoneVal), JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   958
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   959
	} finally {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   960
	    if (!success) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   961
		zone.setErrored(true);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   962
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   963
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   964
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   965
	return connector;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   966
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   967
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   968
    private void gatherHostAndUserData(LoginRequest request, LoginData data)
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   969
	throws ActionAbortedException, ActionFailedException {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   970
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   971
	LoginProperty<String> host = request.getHost();
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
   972
	LoginProperty<String> user = request.getUser();
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   973
	LoginProperty<Boolean> zonePrompt = request.getZonePrompt();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   974
	List<DialogMessage> messages = request.getMessages();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   975
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   976
	// Validate any preset values prior to prompting user
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   977
	if (host.getValue() != null || !host.isEditable()) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   978
	    isHostValid(request);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   979
	}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   980
	if (user.getValue() != null || !user.isEditable()) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   981
	    isUserValid(request);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   982
	}
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   983
	if (zonePrompt.getValue() != null || !zonePrompt.isEditable()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   984
	    isPropertyValid(zonePrompt, request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   985
	}
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   986
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   987
	// Loop until connected to host and authenticated as user
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
   988
	while (true) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   989
	    boolean acknowledged = false;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   990
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
   991
	    // Refresh each iteration in case a prop isEditableOnError()
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   992
	    boolean hostEditable = host.isEditable();
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   993
	    boolean userEditable = user.isEditable();
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   994
	    boolean zonePromptEditable = zonePrompt.isEditable();
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
   995
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
   996
	    // If an error cannot be fixed by the user...
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   997
	    if ((!zonePromptEditable && zonePrompt.isErrored()) ||
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   998
		(!hostEditable && (host.isErrored() ||
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
   999
		(!userEditable && user.isErrored())))) {
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1000
634
d7eeecd22f7f 17699 simplify notifications of failed login requests
Stephen Talley <stephen.talley@oracle.com>
parents: 630
diff changeset
  1001
		requestFailed(request);
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1002
	    }
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1003
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1004
	    if (hostEditable || userEditable || zonePromptEditable ||
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1005
		!messages.isEmpty()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1006
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1007
		try {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1008
		    promptForHostAndUser(request);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1009
		} finally {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1010
		    acknowledged = true;
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1011
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1012
		    // User only needs to see any message once, presumably
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1013
		    messages.clear();
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1014
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1015
		    host.setErrored(false);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1016
		    user.setErrored(false);
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1017
		    zonePrompt.setErrored(false);
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1018
		}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1019
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1020
		if (!isHostValid(request) || !isUserValid(request) ||
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1021
		    !isPropertyValid(zonePrompt, request)) {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1022
		    continue;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1023
		}
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1024
	    }
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1025
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1026
	    String hostVal = host.getValue();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1027
	    String userVal = user.getValue();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1028
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1029
	    // Search for existing connection
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1030
	    List<ConnectionInfo> depChain =
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1031
		getConnectionManager().getDepChain(hostVal, userVal, null, null,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1032
		null, null);
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1033
	    if (depChain != null) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1034
		data.setDepChain(depChain, acknowledged);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1035
		return;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1036
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1037
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1038
	    // Create connection, append to messages on error
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1039
	    JMXConnector connector = createConnector(request);
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
  1040
	    if (connector != null) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1041
		ConnectionInfo info = new ConnectionInfo(hostVal, userVal, null,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1042
		    connector);
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1043
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
  1044
		// Get/create auth bean, append to messages on error
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1045
		AuthenticatorMXBean auth = createAuthBean(request, info);
630
5dff60eda7bc 17677 login requesters need finer control over login property validation
Stephen Talley <stephen.talley@oracle.com>
parents: 629
diff changeset
  1046
		if (auth != null) {
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
  1047
		    setLoginStatus(request,
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
  1048
			Finder.getString("login.status.user"));
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
  1049
630
5dff60eda7bc 17677 login requesters need finer control over login property validation
Stephen Talley <stephen.talley@oracle.com>
parents: 629
diff changeset
  1050
		    if (userVal.equals(auth.getuser())) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1051
			data.push(info, acknowledged);
630
5dff60eda7bc 17677 login requesters need finer control over login property validation
Stephen Talley <stephen.talley@oracle.com>
parents: 629
diff changeset
  1052
			return;
5dff60eda7bc 17677 login requesters need finer control over login property validation
Stephen Talley <stephen.talley@oracle.com>
parents: 629
diff changeset
  1053
		    }
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
  1054
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
  1055
		    try {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1056
			AuthPrompter prompter = new UserPrompter();
615
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1057
			do {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1058
			    if (authConverse(request, auth, prompter)) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1059
				acknowledged |= prompter.isAcknowledged();
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1060
				data.push(info, acknowledged);
615
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1061
				return;
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1062
			    }
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1063
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1064
			    // Authentication failed
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1065
			    user.setErrored(true);
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
  1066
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1067
			    // Add generic auth failure message if not already
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1068
			    // provided by server
615
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1069
			    if (messages.isEmpty()) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1070
				messages.add(new DialogMessage(
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1071
				    Finder.getString("login.err.user.auth",
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1072
				    hostVal, userVal),
615
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1073
				    JOptionPane.ERROR_MESSAGE));
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1074
			    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1075
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1076
			// No chance to edit, so keep iterating here
615
d3970b657f35 17576 login is overly-verbose when read-only host/user fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 601
diff changeset
  1077
			} while (!host.isEditable() && !user.isEditable());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1078
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1079
		    // Thrown by authConverse
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
  1080
		    } catch (ActionRegressedException e) {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1081
		    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1082
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1083
	    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1084
	}
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1085
    }
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1086
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1087
    private void gatherRoleData(LoginRequest request, LoginData data)
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1088
	throws ActionAbortedException, ActionFailedException,
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1089
	ActionRegressedException {
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1090
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
  1091
	LoginProperty<String> host = request.getHost();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1092
	String hostVal = host.getValue();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1093
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
  1094
	LoginProperty<String> user = request.getUser();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1095
	String userVal = user.getValue();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1096
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1097
	LoginProperty<String> zone = request.getZone();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1098
	String zoneVal = zone.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1099
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1100
	LoginProperty<String> zoneUser = request.getZoneUser();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1101
	String zoneUserVal = zoneUser.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1102
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1103
	// Get/create auth bean, append to messages on error
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1104
	AuthenticatorMXBean userAuth = createAuthBean(request, data.peek(0));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1105
	if (userAuth == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1106
	    // Not likely, but handle it anyway
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1107
	    requestFailed(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1108
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1109
629
98d1255b86eb 17671 LoginRequest et al are too restrictive on property classes
Stephen Talley <stephen.talley@oracle.com>
parents: 626
diff changeset
  1110
	LoginProperty<String> role = request.getRole();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1111
	List<DialogMessage> messages = request.getMessages();
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1112
644
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
  1113
	setLoginStatus(request, Finder.getString("login.status.roles",
91293d42f869 17370 - vp should show more descriptive message during long login process
Dan Labrecque <dan.labrecque@oracle.com>
parents: 639
diff changeset
  1114
	    request.getUser().getValue()));
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1115
	List<String> roles = userAuth.getroles();
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1116
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1117
	// Validate any preset value prior to prompting user
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1118
	if (role.getValue() != null || !role.isEditable()) {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1119
	    isRoleValid(request, roles, false);
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1120
	}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1121
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1122
	// Loop until no role is chosen, or chosen role is authenticated
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1123
	while (true) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1124
	    boolean acknowledged = false;
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1125
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1126
	    // Refresh each iteration in case role.isEditableOnError()
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1127
	    boolean roleEditable = role.isEditable();
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1128
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1129
	    // If an error cannot be fixed by the user...
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1130
	    if (!roleEditable && role.isErrored()) {
634
d7eeecd22f7f 17699 simplify notifications of failed login requests
Stephen Talley <stephen.talley@oracle.com>
parents: 630
diff changeset
  1131
		requestFailed(request);
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1132
	    }
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1133
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1134
	    if ((roleEditable && !roles.isEmpty()) || !messages.isEmpty()) {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1135
		try {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1136
		    promptForRole(request, roles, false);
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1137
		} finally {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1138
		    acknowledged = true;
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1139
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1140
		    // User only needs to see any message once, presumably
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1141
		    messages.clear();
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1142
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1143
		    role.setErrored(false);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1144
		}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1145
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1146
		if (!isRoleValid(request, roles, false)) {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1147
		    continue;
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1148
		}
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1149
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1150
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1151
	    String roleVal = role.getValue();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1152
	    if (roleVal == null) {
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1153
		// No need to keep going
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1154
		return;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1155
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1156
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1157
	    // Search for existing connection
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1158
	    List<ConnectionInfo> depChain = getConnectionManager().getDepChain(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1159
		hostVal, userVal, roleVal, null, null, null);
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1160
	    if (depChain != null) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1161
		data.setDepChain(depChain, acknowledged);
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1162
		return;
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1163
	    }
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1164
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1165
	    try {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1166
		byte[] token = userAuth.createToken();
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1167
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1168
		// Create connection, append to messages on error
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1169
		JMXConnector connector = createConnector(request);
626
16154b98a4ec 17621 RadLoginManager shouldn't assume local connection is authenticated
Stephen Talley <stephen.talley@oracle.com>
parents: 625
diff changeset
  1170
		if (connector != null) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1171
		    ConnectionInfo info = new ConnectionInfo(hostVal, userVal,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1172
			roleVal, connector);
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
  1173
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1174
		    // Create auth bean, append to messages on error
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1175
		    AuthenticatorMXBean roleAuth = createAuthBean(request,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1176
			info);
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1177
		    if (roleAuth != null) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1178
			roleAuth.redeemToken(userVal, token);
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
  1179
620
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1180
			AuthPrompter prompter = new RolePrompter();
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1181
			do {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1182
			    if (authConverse(request, roleAuth, prompter)) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1183
				acknowledged |= prompter.isAcknowledged();
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1184
				data.push(info, acknowledged);
620
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1185
				return;
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1186
			    }
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1187
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1188
			    // Authentication failed
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1189
			    role.setErrored(true);
478
2aa1b1c14fb7 15505 role-based connections should hold a lock on the core user connection
Stephen Talley <stephen.talley@oracle.com>
parents: 474
diff changeset
  1190
620
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1191
			    // Add generic auth failure message if not already
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1192
			    // provided by server
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1193
			    if (messages.isEmpty()) {
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1194
				messages.add(new DialogMessage(
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1195
				    Finder.getString("login.err.role.auth",
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1196
				    hostVal, userVal, roleVal),
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1197
				    JOptionPane.ERROR_MESSAGE));
620
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1198
			    }
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1199
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1200
			// No chance to edit role, so keep iterating here
faf036da4417 17588 login is overly-verbose when read-only role fails authentication
Stephen Talley <stephen.talley@oracle.com>
parents: 619
diff changeset
  1201
			} while (!role.isEditable());
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1202
		    }
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1203
		}
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1204
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1205
	    // Thrown by createToken/redeemToken
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1206
	    } catch (ObjectException e) {
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1207
		messages.add(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
  1208
		    "login.err.io", hostVal), JOptionPane.ERROR_MESSAGE));
487
09d92217e10c 15685 login dialog should support "back" behavior
Stephen Talley <stephen.talley@oracle.com>
parents: 481
diff changeset
  1209
601
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1210
	    // Thrown by authConverse
9d4e3e0ee603 7947 vp should fail if unable to connect to requested host
Stephen Talley <stephen.talley@oracle.com>
parents: 600
diff changeset
  1211
	    } catch (ActionRegressedException e) {
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1212
	    }
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1213
	}
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1214
    }
473
18f221b572ce 14914 all local logins should use AF_UNIX connections
Stephen Talley <stephen.talley@oracle.com>
parents: 468
diff changeset
  1215
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1216
    private void gatherZoneHostAndUserData(LoginRequest request, LoginData data)
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1217
	throws ActionAbortedException, ActionFailedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1218
	ActionRegressedException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1219
668
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1220
	ZoneAdminMXBean zcon = createZoneAdminBean(request, data.peek(0));
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1221
	if (zcon == null) {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1222
	    requestFailed(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1223
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1224
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1225
	LoginProperty<String> zone = request.getZone();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1226
	LoginProperty<String> zoneUser = request.getZoneUser();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1227
	List<DialogMessage> messages = request.getMessages();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1228
668
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1229
	List<String> zones = null;
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1230
	try {
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1231
	    zones = zcon.getZones(ZoneState.RUNNING);
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1232
	} catch (ObjectException e) {
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1233
	    messages.add(new DialogMessage(Finder.getString(
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1234
                "login.err.io", request.getHost().getValue()),
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1235
                JOptionPane.ERROR_MESSAGE));
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1236
	    requestFailed(request);
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1237
	}
1b6bd83ac401 17963 rzd: zoneadmin module should provide rudimentary zone discovery
Stephen Talley <stephen.talley@oracle.com>
parents: 651
diff changeset
  1238
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1239
	// Validate any preset value prior to prompting user
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1240
	if (zone.getValue() != null || !zone.isEditable()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1241
	    isZoneValid(request, zones);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1242
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1243
	if (zoneUser.getValue() != null || !zoneUser.isEditable()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1244
	    isZoneUserValid(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1245
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1246
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1247
	// Loop until connected to zone and authenticated as zoneUser
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1248
	while (true) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1249
	    boolean acknowledged = false;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1250
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1251
	    // Refresh each iteration in case zone/zoneUser.isEditableOnError()
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1252
	    boolean zoneEditable = zone.isEditable();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1253
	    boolean zoneUserEditable = zoneUser.isEditable();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1254
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1255
	    // If an error cannot be fixed by the user...
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1256
	    if (!zoneEditable && (zone.isErrored() ||
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1257
		(!zoneUserEditable && zoneUser.isErrored()))) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1258
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1259
		requestFailed(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1260
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1261
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1262
	    if (zoneEditable || zoneUserEditable || !messages.isEmpty()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1263
		try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1264
		    promptForZoneAndUser(request, zones);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1265
		} finally {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1266
		    acknowledged = true;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1267
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1268
		    // User only needs to see any message once, presumably
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1269
		    messages.clear();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1270
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1271
		    zone.setErrored(false);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1272
		    zoneUser.setErrored(false);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1273
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1274
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1275
		if (!isZoneValid(request, zones) || !isZoneUserValid(request)) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1276
		    continue;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1277
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1278
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1279
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1280
	    String zoneVal = zone.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1281
	    if (zoneVal == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1282
		// No need to keep going
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1283
		return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1284
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1285
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1286
	    String zoneUserVal = zoneUser.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1287
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1288
	    // Search for existing connection
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1289
	    List<ConnectionInfo> depChain =
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1290
		getConnectionManager().getDepChain(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1291
		request.getHost().getValue(), request.getUser().getValue(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1292
		request.getRole().getValue(), zoneVal, zoneUserVal, null);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1293
	    if (depChain != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1294
		data.setDepChain(depChain, acknowledged);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1295
		return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1296
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1297
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1298
	    JMXConnector connector = createZoneConnector(request, zcon);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1299
	    if (connector != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1300
		ConnectionInfo info = new ConnectionInfo(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1301
		    request.getHost().getValue(), request.getUser().getValue(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1302
		    request.getRole().getValue(), zoneVal, zoneUserVal, null,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1303
		    connector);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1304
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1305
		// Get/create auth bean, append to messages on error
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1306
		AuthenticatorMXBean auth = createAuthBean(request, info);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1307
		if (auth != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1308
		    if (zoneUserVal.equals(auth.getuser())) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1309
			data.push(info, acknowledged);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1310
			return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1311
		    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1312
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1313
		    try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1314
			AuthPrompter prompter = new ZoneUserPrompter();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1315
			do {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1316
			    if (authConverse(request, auth, prompter)) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1317
				acknowledged |= prompter.isAcknowledged();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1318
				data.push(info, acknowledged);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1319
				return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1320
			    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1321
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1322
			    // Authentication failed
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1323
			    zoneUser.setErrored(true);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1324
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1325
			    // Add generic auth failure message if not already
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1326
			    // provided by server
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1327
			    if (messages.isEmpty()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1328
				messages.add(new DialogMessage(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1329
				    Finder.getString("login.err.user.auth",
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1330
				    zoneVal, zoneUserVal),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1331
				    JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1332
			    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1333
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1334
			// No chance to edit, so keep iterating here
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1335
			} while (!zone.isEditable() && !zoneUser.isEditable());
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1336
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1337
		    // Thrown by authConverse
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1338
		    } catch (ActionRegressedException e) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1339
		    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1340
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1341
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1342
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1343
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1344
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1345
    private void gatherZoneRoleData(LoginRequest request, LoginData data)
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1346
	throws ActionAbortedException, ActionFailedException,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1347
	ActionRegressedException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1348
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1349
	LoginProperty<String> host = request.getHost();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1350
	String hostVal = host.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1351
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1352
	LoginProperty<String> user = request.getUser();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1353
	String userVal = user.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1354
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1355
	LoginProperty<String> role = request.getRole();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1356
	String roleVal = role.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1357
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1358
	LoginProperty<String> zone = request.getZone();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1359
	String zoneVal = zone.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1360
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1361
	LoginProperty<String> zoneUser = request.getZoneUser();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1362
	String zoneUserVal = zoneUser.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1363
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1364
	// Get/create auth bean, append to messages on error
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1365
	AuthenticatorMXBean userAuth = createAuthBean(request, data.peek(0));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1366
	if (userAuth == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1367
	    // Not likely, but handle it anyway
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1368
	    requestFailed(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1369
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1370
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1371
	LoginProperty<String> zoneRole = request.getZoneRole();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1372
	List<DialogMessage> messages = request.getMessages();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1373
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1374
	setLoginStatus(request, Finder.getString("login.status.roles",
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1375
	    request.getZoneUser().getValue()));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1376
	List<String> roles = userAuth.getroles();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1377
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1378
	// Validate any preset value prior to prompting user
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1379
	if (zoneRole.getValue() != null || !zoneRole.isEditable()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1380
	    isRoleValid(request, roles, true);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1381
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1382
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1383
	ZoneAdminMXBean zcon = null;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1384
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1385
	// Loop until no role is chosen, or chosen role is authenticated
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1386
	while (true) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1387
	    boolean acknowledged = false;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1388
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1389
	    // Refresh each iteration in case zoneRole.isEditableOnError()
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1390
	    boolean zoneRoleEditable = zoneRole.isEditable();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1391
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1392
	    // If an error cannot be fixed by the user...
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1393
	    if (!zoneRoleEditable && zoneRole.isErrored()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1394
		requestFailed(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1395
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1396
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1397
	    if ((zoneRoleEditable && !roles.isEmpty()) || !messages.isEmpty()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1398
		try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1399
		    promptForRole(request, roles, true);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1400
		} finally {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1401
		    acknowledged = true;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1402
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1403
		    // User only needs to see any message once, presumably
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1404
		    messages.clear();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1405
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1406
		    zoneRole.setErrored(false);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1407
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1408
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1409
		if (!isRoleValid(request, roles, true)) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1410
		    continue;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1411
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1412
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1413
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1414
	    String zoneRoleVal = zoneRole.getValue();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1415
	    if (zoneRoleVal == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1416
		// No need to keep going
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1417
		return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1418
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1419
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1420
	    // Search for existing connection
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1421
	    List<ConnectionInfo> depChain = getConnectionManager().getDepChain(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1422
		hostVal, userVal, roleVal, zoneVal, zoneUserVal, zoneRoleVal);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1423
	    if (depChain != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1424
		data.setDepChain(depChain, acknowledged);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1425
		return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1426
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1427
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1428
	    try {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1429
		byte[] token = userAuth.createToken();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1430
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1431
		if (zcon == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1432
		    // Peek back to the host-based connection
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1433
		    zcon = createZoneAdminBean(request, data.peek(1));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1434
		    if (zcon == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1435
			requestFailed(request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1436
		    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1437
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1438
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1439
		// Create connection, append to messages on error
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1440
		JMXConnector connector = createZoneConnector(request, zcon);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1441
		if (connector != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1442
		    ConnectionInfo info = new ConnectionInfo(hostVal, userVal,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1443
			roleVal, zoneVal, zoneUserVal, zoneRoleVal, connector);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1444
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1445
		    // Create auth bean, append to messages on error
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1446
		    AuthenticatorMXBean roleAuth = createAuthBean(request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1447
			info);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1448
		    if (roleAuth != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1449
			roleAuth.redeemToken(userVal, token);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1450
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1451
			AuthPrompter prompter = new ZoneRolePrompter();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1452
			do {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1453
			    if (authConverse(request, roleAuth, prompter)) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1454
				acknowledged |= prompter.isAcknowledged();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1455
				data.push(info, acknowledged);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1456
				return;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1457
			    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1458
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1459
			    // Authentication failed
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1460
			    zoneRole.setErrored(true);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1461
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1462
			    // Add generic auth failure message if not already
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1463
			    // provided by server
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1464
			    if (messages.isEmpty()) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1465
				messages.add(new DialogMessage(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1466
				    Finder.getString("login.err.zonerole.auth",
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1467
				    hostVal, userVal, roleVal, zoneVal,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1468
				    zoneUserVal, zoneRoleVal),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1469
				    JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1470
			    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1471
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1472
			// No chance to edit role, so keep iterating here
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1473
			} while (!zoneRole.isEditable());
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1474
		    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1475
		}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1476
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1477
	    // Thrown by createToken/redeemToken
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1478
	    } catch (ObjectException e) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1479
		messages.add(new DialogMessage(Finder.getString(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1480
		    "login.err.io", hostVal), JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1481
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1482
	    // Thrown by authConverse
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1483
	    } catch (ActionRegressedException e) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1484
	    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1485
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1486
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1487
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1488
    private MBeanServerConnection getMBeanServerConnection(LoginRequest request,
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1489
	ConnectionInfo info) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1490
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1491
	try {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1492
	    return info.getConnector().getMBeanServerConnection();
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1493
	} catch (IOException e) {
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1494
	    request.getMessages().add(new DialogMessage(
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1495
		Finder.getString("login.err.io",
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1496
		request.getHost().getValue()),
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1497
		JOptionPane.ERROR_MESSAGE));
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1498
	}
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1499
	return null;
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1500
    }
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1501
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1502
    private <T> boolean inSet(LoginProperty<T> property, List<T> valid,
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1503
	String resource, LoginRequest request) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1504
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1505
	if (!valid.contains(property.getValue())) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1506
	    String message = Finder.getString(resource,
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1507
		request.getHost().getValue(),
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1508
		request.getUser().getValue(),
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1509
		request.getRole().getValue(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1510
		request.getZone().getValue(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1511
		request.getZoneUser().getValue(),
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1512
		request.getZoneRole().getValue());
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1513
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1514
	    request.getMessages().add(new DialogMessage(message,
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1515
		JOptionPane.ERROR_MESSAGE));
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1516
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1517
	    property.setErrored(true);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1518
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1519
	    if (property.isEditable()) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1520
		property.setValue(null);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1521
	    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1522
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1523
	    return false;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1524
	}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1525
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1526
	return true;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1527
    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1528
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1529
    private boolean isHostValid(LoginRequest request)
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1530
	throws ActionFailedException {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1531
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1532
	LoginProperty<String> host = request.getHost();
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1533
	return isPropertyNonEmpty(host, request, "login.err.host.empty") &&
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1534
	    isPropertyValid(host, request);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1535
    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1536
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1537
    private boolean isPropertyNonEmpty(LoginProperty<String> property,
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1538
	LoginRequest request, String resource) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1539
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1540
	String value = property.getValue();
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1541
	if (value == null || value.isEmpty()) {
645
13b54060dbf4 17759 generalize connection management for arbitrary-length dependency chains
Stephen Talley <stephen.talley@oracle.com>
parents: 644
diff changeset
  1542
	    request.getMessages().add(new DialogMessage(Finder.getString(
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1543
		resource), JOptionPane.ERROR_MESSAGE));
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1544
	    property.setErrored(true);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1545
	    return false;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1546
	}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1547
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1548
	return true;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1549
    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1550
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1551
    private <T> boolean isPropertyValid(LoginProperty<T> property,
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1552
	LoginRequest request, T... valid) throws ActionFailedException {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1553
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1554
	try {
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1555
	    property.validate(request, valid);
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1556
	    return true;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1557
	} catch (LoginPropertyException e) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1558
	    property.setErrored(true);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1559
	    request.getMessages().add(e.getDialogMessage());
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1560
	    if (e.isFatal()) {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1561
		requestFailed(request);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1562
	    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1563
	    return false;
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1564
	}
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1565
    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1566
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1567
    private boolean isRoleValid(LoginRequest request, List<String> roles,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1568
	boolean isZone) throws ActionFailedException {
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1569
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1570
	LoginProperty<String> role = isZone ? request.getZoneRole() :
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1571
	    request.getRole();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1572
639
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1573
	return (role.getValue() == null ||
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1574
	    inSet(role, roles, "login.err.role.invalid", request)) &&
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1575
	    isPropertyValid(role, request,
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1576
	    roles.toArray(new String[roles.size()]));
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1577
    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1578
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1579
    private boolean isUserValid(LoginRequest request)
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1580
	throws ActionFailedException {
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1581
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1582
	LoginProperty<String> user = request.getUser();
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1583
	return isPropertyNonEmpty(user, request, "login.err.user.empty") &&
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1584
	    isPropertyValid(user, request);
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1585
    }
0cfa7516d1da 17746 RadLoginManager makes an ass out of you and me
Stephen Talley <stephen.talley@oracle.com>
parents: 634
diff changeset
  1586
651
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1587
    private boolean isZoneValid(LoginRequest request, List<String> zones)
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1588
	throws ActionFailedException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1589
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1590
	LoginProperty<String> zone = request.getZone();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1591
	if (zone.getValue() == null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1592
	    request.getMessages().add(new DialogMessage(Finder.getString(
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1593
		"login.err.zone.empty"), JOptionPane.ERROR_MESSAGE));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1594
	    zone.setErrored(true);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1595
	    return false;
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1596
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1597
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1598
	String resource = "login.err.zone.invalid";
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1599
	if (request.getRole().getValue() != null) {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1600
	    resource += ".role";
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1601
	}
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1602
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1603
	return inSet(zone, zones, resource, request) &&
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1604
	    isPropertyValid(zone, request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1605
	    zones.toArray(new String[zones.size()]));
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1606
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1607
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1608
    private boolean isZoneUserValid(LoginRequest request)
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1609
	throws ActionFailedException {
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1610
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1611
	LoginProperty<String> zoneUser = request.getZoneUser();
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1612
	return isPropertyNonEmpty(zoneUser, request,
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1613
	    "login.err.zoneuser.empty") && isPropertyValid(zoneUser, request);
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1614
    }
eeb57de7d602 17829 rzd - rad connection to zone through its global zone
Stephen Talley <stephen.talley@oracle.com>
parents: 646
diff changeset
  1615
634
d7eeecd22f7f 17699 simplify notifications of failed login requests
Stephen Talley <stephen.talley@oracle.com>
parents: 630
diff changeset
  1616
    private void requestFailed(LoginRequest request)
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1617
	throws ActionFailedException {
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1618
634
d7eeecd22f7f 17699 simplify notifications of failed login requests
Stephen Talley <stephen.talley@oracle.com>
parents: 630
diff changeset
  1619
	promptForFailedRequest(request);
625
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1620
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1621
	List<DialogMessage> messages = request.getMessages();
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1622
	throw new ActionFailedException(messages.isEmpty() ? null :
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1623
	    messages.get(0).getText());
0ad7f2393529 17606 login/authentication code could be simplified
Stephen Talley <stephen.talley@oracle.com>
parents: 624
diff changeset
  1624
    }
391
71abce159a62 13357 rad
David Powell <David.Powell@sun.com>
parents:
diff changeset
  1625
}