summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/connection/JSSConnection.java
blob: 27292b3d93f885fd8accbe2310ee6329f72b2d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.admin.certsrv.connection;

import java.util.*;
import java.net.*;
import java.io.*;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import com.netscape.admin.certsrv.*;
import com.netscape.certsrv.common.*;
import com.netscape.management.client.util.Debug;
import com.netscape.management.client.util.*;
import org.mozilla.jss.ssl.*;
import org.mozilla.jss.*;
import org.mozilla.jss.util.*;
import org.mozilla.jss.crypto.*;
import org.mozilla.jss.pkcs11.*;
import javax.swing.*;
import java.awt.*;

/**
 * JSSConnection deals with establishing a connection to
 * a server, sending requests and reading responses.
 *
 * XXX - Performance optimizations if any, persistent connection
 * support, server auth verification and  client authentication
 * support to be added. NEED TO COME BACK AND CLEAN UP - coding
 * standard.
 *
 * @author Jack Pan-Chen
 * @author kanda
 * @author Christine Ho
 * @version $Revision$, $Date$
 */
public class JSSConnection implements IConnection, SSLCertificateApprovalCallback, 
  SSLClientCertificateSelectionCallback {

    /*==========================================================
     * variables
     *==========================================================*/

	/* static variables */
	static CryptoManager cryptoManager;
	static CertificateFactory cf;
	static SelectCertDialog selectCertDialog = null;
        static PromptForTrustDialog promptForTrustDialog = null;

	/* private valiable */
	private InputStream httpIn;
	private OutputStream httpOut;
	private byte[] body;
	private int bodyLen;
	private String header;
	private int available;
	private int totalRead;
	private boolean endOfHeader = false;

	private static int HTTP_OK_RESPONSE = 200;
	private static final String PANELNAME = "SSLCLIENT";
    private boolean abort = false;;
    private boolean mClientAuth = false;
    private boolean mCertAccepted = true;
    private boolean mClientCertFound = true;
    private boolean mServerCertImported = true;
    private boolean mTokenPasswordInit = true;
    private boolean mTokenPasswdSame = true;

	protected SSLSocket s = null;

	/*==========================================================
	* constructors
	*==========================================================*/
	public JSSConnection(String host, int port)
	    throws IOException, UnknownHostException {

		UtilConsoleGlobals.initJSS();
		cf = UtilConsoleGlobals.getX509CertificateFactory();
        try {
            cryptoManager = CryptoManager.getInstance();    
        } catch (Exception e) {
        }

        // SSLSocket needs to be set before getting an instance
        // to get the ciphers
        SSLSocket.enableSSL2Default(false);
        SSLSocket.enableSSL3Default(true);
        int TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA = 0xC005; 
        int TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xC00A; 

        int ciphers[] = SSLSocket.getImplementedCipherSuites();
        for (int i = 0; ciphers != null && i < ciphers.length; i++) {
            // make sure SSLv2 ciphers are not enabled
            if ((ciphers[i] & 0xfff0) !=0xff00) {
                Debug.println("JSSConnection Debug: non-SSL2 NSS Cipher Supported '0x" + 
                Integer.toHexString(ciphers[i]) + "'"); 
                SSLSocket.setCipherPreferenceDefault(ciphers[i], true);
            } else {
                Debug.println("JSSConnection Debug: SSL2 (turned off) NSS Cipher Supported '0x" + 
                Integer.toHexString(ciphers[i]) + "'"); 
                SSLSocket.setCipherPreferenceDefault(ciphers[i], false);
            }

           /* Enable ECC Cipher */

           if (ciphers[i] == TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA) {
             Debug.println("JSSConnection Debug: found TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, setting preference");
             SSLSocket.setCipherPreferenceDefault(TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, true);
           }
           if (ciphers[i] == TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA) {
             Debug.println("JSSConnection Debug: found TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, setting preference");
             SSLSocket.setCipherPreferenceDefault(TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, true);
           }
        }
		s = new SSLSocket(host, port, null, 0, this, this);
        s.enableSSL2(false);
        s.enableSSL2Default(false);
        s.enableV2CompatibleHello(false);
        s.enableSSL3(true);
        s.enableSSL3Default(true);

		// Initialze Http Input and Output Streams
		httpIn = s.getInputStream();
		httpOut = s.getOutputStream();
        cryptoManager.setPasswordCallback(new pwcb());
        Debug.println("JSSConnection Debug: end of JSSConnection constructor");
	}

    public boolean approve(org.mozilla.jss.crypto.X509Certificate serverCert,
       ValidityStatus status)
    {
        if (!mCertAccepted)
            return false;

        boolean promptForTrust = true;

        //if server auth is not enabled
        if (!(UtilConsoleGlobals.isServerAuthEnabled())) {
            return mCertAccepted;
        }

        Enumeration errors = status.getReasons();
        //if there are more then 1 error we need to propmt user for trust
        promptForTrust = errors.hasMoreElements();

	    /* if trusted already */
	    if (!promptForTrust)
		    return mCertAccepted;

        //the x509certificate pass in by jss is lacking some
        //api.  so I am getting the encoding then
        //use the default security provider provided by sun
        //to decode certificate.
        //due to the fact that current JSS(version2.1) will clobber
        //the way jdk loads the default sun security provider I am
        //using the workaround for now.  Which is to load the sun
        //provider before jss is loaded.  (see static section above)
        X509Certificate x509Cert = null;
        try {
            ByteArrayInputStream bais = new ByteArrayInputStream(serverCert.getEncoded());

            while (bais.available() > 0) {
                x509Cert = (X509Certificate)(cf.generateCertificate(bais));
                Debug.println(x509Cert.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

	    //bring up the trust dialog
	    promptForTrustDialog = new PromptForTrustDialog(getFrame(), x509Cert, status);
	    promptForTrustDialog.setVisible(true);
	    mCertAccepted = promptForTrustDialog.isCertAccepted();
	    if (mCertAccepted) {
            //user want to save this certificate not just this session
            //so we have to store the cert as perm cert.
		    if (!(promptForTrustDialog.isAcceptedForOneSession())) {
			    try {
			        String nickname = serverCert.getNickname();
			
                    CryptoToken internalToken = 
                      cryptoManager.getInternalKeyStorageToken();

                    if (!internalToken.passwordIsInitialized()) {
                        InitPasswordDialog initPasswordDialog = 
                          new InitPasswordDialog(internalToken);
                        initPasswordDialog.setVisible(true);
                        if (initPasswordDialog.isCancel()) {
                            mTokenPasswordInit = false;
                            return false;
                        }
                        if (!initPasswordDialog.isPwdSame()) {
                            mTokenPasswdSame = false;
                            mTokenPasswordInit = false;
                            return false;
                        }
                        if (!initPasswordDialog.isTokenInit()) {
                            mTokenPasswordInit = false;
                            return false;
                        }
                    }

                    if (!internalToken.isLoggedIn()) {
                        internalToken.login(new pwcb());
                    }
                    if (abort) {
                        mServerCertImported = false;
                        mCertAccepted = false;
                        return false;
                    }
			        InternalCertificate internalCert = 
                      cryptoManager.importCertToPerm(serverCert, 
                      (nickname==null)?serverCert.getSubjectDN().toString():nickname);
			        internalCert.setSSLTrust(
                      org.mozilla.jss.crypto.InternalCertificate.TRUSTED_PEER | 
                      org.mozilla.jss.crypto.InternalCertificate.VALID_PEER);
			    } catch (Exception e) {
                    mServerCertImported = false;
                    mCertAccepted = false;
                    if (Debug.getTrace()) {
                        e.printStackTrace();
                    }
                    return false;
                } 
		    }
	    }

        return mCertAccepted;
    }

    public boolean isSamePwd() {
        return mTokenPasswdSame;
    }

    public boolean isTokenPasswordInit() {
        return mTokenPasswordInit;
    }

    public boolean hasClientCert() {
        return mClientCertFound;
    }

    public boolean isClientAuth() {
        return mClientAuth;
    }
 
    public boolean isCertAccepted() {
        return mCertAccepted;
    }

    public boolean isAbortAction() {
        return abort;
    }

    public boolean isServerCertImported() {
        return mServerCertImported;
    }

    public String select(Vector nicknames) 
    { 
        selectCertDialog = null;
        mClientAuth = true;
        if (nicknames == null || nicknames.size() == 0) {
            mClientCertFound = false;
            return "";
        }

        selectCertDialog = new JSSConnection.SelectCertDialog();

        Debug.println("JSSConnection::select(...) - SELECT CERTIFICATE");
        selectCertDialog.setCertList(nicknames);
        selectCertDialog.setVisible(true);
        return (selectCertDialog.isCancel()?"":selectCertDialog.getSelectedCert());
    }

    public class pwcb implements PasswordCallback {
        private int nthPrompt = 0;
        private static final int MAX_PASSWORD_PROMPT = 20;
        GetPasswordDialog getPasswordDialog = null;

        public Password getPasswordFirstAttempt(PasswordCallbackInfo info)
            throws PasswordCallback.GiveUpException {

            if (abort)
                throw new PasswordCallback.GiveUpException();

            nthPrompt++;

            if (getPasswordDialog == null)
                getPasswordDialog = new GetPasswordDialog();

            getPasswordDialog.setPasswordInfo(info, false);
            getPasswordDialog.setVisible(true);

            if (getPasswordDialog.isCancel()) {
                nthPrompt = 0;
                abort = true;
                throw new PasswordCallback.GiveUpException();
            }
        
            return getPasswordDialog.getPassword();
        }

        public Password getPasswordAgain(PasswordCallbackInfo info) 
          throws GiveUpException
        {

            if (abort)
                throw new PasswordCallback.GiveUpException();
            nthPrompt++;
            if (nthPrompt > MAX_PASSWORD_PROMPT || getPasswordDialog.isCancel()) {
                nthPrompt = 0;
                abort = true;
                throw new PasswordCallback.GiveUpException();
            }

            getPasswordDialog.setPasswordInfo(info, true);
            getPasswordDialog.setVisible(true);

            return getPasswordDialog.getPassword();
        }
    }

    /*==========================================================
	 * public methods
     *==========================================================*/

    /**
     * Send request to the server using this connection
     *
     * @param req request object
     * @return status 1-success, 0- failed
     * @excpetion IOExcpetion
     */
	public int sendRequest(String req)
	    throws IOException {

		int stat = 1;
		if (req == null)
		{
			//System.out.println("Request is null");
			return 0;
	  	}
		endOfHeader = false;

		PrintStream ps = new PrintStream(httpOut);
		ps.println(req);
		ps.println();
		ps.flush();
		try
		{
			Thread.sleep(100);
		}
		catch (Exception e) {
            Debug.println("JSSConnection Debug: in sendRequest:"+e.toString());
            System.out.println("sleeping "+e.toString());
        }
		//System.out.println("Request Sent - bytes:" + httpOut.getTotal());

		// Init the Reply stream
		totalRead = 0;
		header = null;
		initReadResponse();
		return stat;
	}

    /**
     * Retrieve the input stream
     */
	public InputStream getInputStream()
	    throws IOException {

		return s.getInputStream();
	}

	/**
	 * Read
	 */
	public int read(byte[] buf)
	    throws IOException {

		return httpIn.read(buf, 0, buf.length);
	}

    /**
     * Get Header
     */
	public String getHeader() {
		if (header == null)
			return "No Header Read";
		else
			return header;
	}

    /**
     * Get response
     */
	public byte[] getResponse() {
		if (totalRead == 0)
			return null;
		else {
			byte[] buf = new byte[bodyLen];
			System.arraycopy(body, 0, buf, 0, bodyLen);
			return buf;
		}
	}

    /**
     * get available
     */
	public int available()
	    throws IOException {

		return httpIn.available();
	}

    /**
     * Disconnect this connection
     */
	public void disconnect() {
	    try {
		    s.close();
	    } catch (Exception e) {
	        //ignor ?
	    }
	}

    /**
     * Set time out
     */
    public void setSoTimeout(int timeout) throws SocketException {
        //System.out.println("JSSConnection: setSoTimeout() - "+timeout);
        s.setSoTimeout(timeout);    
    }
    
    /*==========================================================
	 * private methods
     *==========================================================*/

    private JFrame getFrame() {
        if (UtilConsoleGlobals.getActivatedFrame() != null)
            return UtilConsoleGlobals.getActivatedFrame();
	    return new JFrame();
    }

	private void initReadResponse()
	    throws IOException {

		readHeader();
		readBody();
	}

    private int readLineFromStream(InputStream is, byte line[], 
                       int startpos, int len) throws IOException {
	    //return is.readLine(line, startpos, len);
        int pos = startpos;
        int count = 0;
        while (len > 0) 
        {
          int nRead = httpIn.read(line, pos, 1);
          if (nRead == -1)
            break;
          count++;
          if (line[pos] == '\n') {
            break;
          }
          pos++;
        }
        return count > 0 ? count : -1;
    }

	private void readHeader() throws IOException
	{
		// Read the status line of response and parse for
		// Errors.
		byte[] headerLine = new byte[1096];
		int nRead = readLineFromStream(httpIn, headerLine, 0, 1096);

        //System.out.println("XXX read " + nRead);

		if (requestFailed(new String(headerLine))) {
            Debug.println("JSSConnection Debug: in readHeader requestFailed");
			throw new IOException(getReasonPhrase(new String (headerLine)));
        }

		while (true) {
			nRead = readLineFromStream(httpIn, headerLine, 0, 1096);
			int available = httpIn.available();

			//System.out.println("Available: " + available);

			if (nRead == -1) {
				System.out.println("Unexpected end of stream");
				break;
			}

			processHeader(headerLine, nRead);

			if (endOfHeader) {
				//System.out.println("End of Header");
				break;
			} else {
			    //System.out.println("Header: " + new String(headerLine)
				//		+ ", nRead: " + nRead);
			}
		}
	}

	private boolean endOfHeader(byte[] hdr, int available) {
		if (available == 2) {
			int c1 = (int)hdr[0];
			int c2 = (int)hdr[1];

			//System.out.println("C1= " + c1);
			//System.out.println("C2= " + c2);

			return true;
		} else
			return false;
	}

	private void readBody()
	    throws IOException {

		body = new byte[bodyLen];
		totalRead = 0;
		while (totalRead < bodyLen) {
			int nRead = httpIn.read(body, totalRead, bodyLen - totalRead);
			totalRead +=  nRead;
		}
	}


	private void processHeader(byte[] buf, int nRead)
	{
		if (endOfHeader(buf, nRead)) {
			endOfHeader = true;
			return;
		}

		String hdr = new String(buf, 0, nRead);
		int index = 0;
		if (hdr.toLowerCase().startsWith("content-length: ")) {
			try {
				String length = hdr.substring(hdr.indexOf(": ") + 1);
				bodyLen = Integer.parseInt(length.trim());
				return;
			} catch (Exception e){e.printStackTrace(); }
		}
	}

	private boolean requestFailed(String header) {
		return (header.indexOf(Integer.toString(HTTP_OK_RESPONSE)) > 0) ? false: true;
	}

	private String getReasonPhrase(String header) {
		String str1 = header.substring(header.indexOf(' ') +1);
		return str1.substring(str1.indexOf(' ') +1);
	}

    class InitPasswordDialog extends AbstractDialog {
        protected ResourceBundle mResource =
          ResourceBundle.getBundle(CMSAdminResources.class.getName());
        SingleBytePasswordField pwd;
        SingleBytePasswordField pwdAgain;
        CryptoToken mToken;
        boolean tokenPasswdInit = true;
        boolean pwdSame = true;
        
        public InitPasswordDialog(CryptoToken token) {
            super(null,"",true, OK|CANCEL);
            setMinimumSize(300, 150);
            mToken = token;
            setTitle(mResource.getString("SSLCLIENT_INITPASSWORD_DIALOG_TITLE"));
            Container p = getContentPane();
            p.setLayout(new GridBagLayout());

            int y = 0;
            pwd = new SingleBytePasswordField();
            pwdAgain = new SingleBytePasswordField();
            JLabel pwdLbl = new JLabel();
            JLabel pwdAgainLbl = new JLabel();
            pwdLbl.setText(mResource.getString("SSLCLIENT_INITPASSWORD_PWD_LABEL"));
            pwdAgainLbl.setText(
              mResource.getString("SSLCLIENT_INITPASSWORD_PWDAGAIN_LABEL"));
            GridBagUtil.constrain(p, pwdLbl,
              0, y, 1, 1,
              0.0, 0.0,
              GridBagConstraints.EAST, GridBagConstraints.NONE);
            GridBagUtil.constrain(p, pwd,
              1, y, GridBagConstraints.REMAINDER, 1,
              1.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL);
            GridBagUtil.constrain(p, pwdAgainLbl,
              0, ++y, 1, 1,
              0.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.NONE);
            GridBagUtil.constrain(p, pwdAgain,
              1, y, GridBagConstraints.REMAINDER, 1,
              1.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL);
/*
            GridBagUtil.constrain(p, pwd,
              0, ++y, 1, 1,
              1.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
              0, 0, 0, 0);
*/

            pack();
        }

        protected void okInvoked() {
            if (!pwd.getText().equals(pwdAgain.getText())) {
                pwdSame = false;
                dispose();
                return;
            }

            try {
                mToken.initPassword(null, getPassword());
                dispose();
            } catch (Exception e) {
                tokenPasswdInit = false;     
            }
        }

        public boolean isPwdSame() {
            return pwdSame;
        }

        public boolean isTokenInit() {
            return tokenPasswdInit;
        }

        public void setVisible(boolean visible) {
            pack();
            pwd.grabFocus();
            super.setVisible(visible);
        }
   
        public Password getPassword() {
            Password jssPwd = new Password(pwd.getText().toCharArray());
            return jssPwd;
        }
    }

	class GetPasswordDialog extends AbstractDialog {

        MultilineLabel enterPwdLabel = new MultilineLabel();
	    protected ResourceBundle mResource = 
          ResourceBundle.getBundle(CMSAdminResources.class.getName());
        SingleBytePasswordField pwd;
        public GetPasswordDialog() {
            super(null,"",true, OK|CANCEL);
	        setTitle(mResource.getString("SSLCLIENT_PASSWORD_DIALOG_TITLE"));
            Container p = getContentPane();
            p.setLayout(new GridBagLayout());

            int y = 0;
            GridBagUtil.constrain(p, enterPwdLabel,
               0, y, 1, 1,
               1.0, 0.0,
               GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
               0, 0, 0, 0);

            pwd = new SingleBytePasswordField();
            GridBagUtil.constrain(p, pwd,
              0, ++y, 1, 1,
              1.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
              0, 0, 0, 0);

            pack();
        }

        public void setVisible(boolean visible) {
            pack();
            pwd.grabFocus();
            super.setVisible(visible);
        }
	
	    public void setPasswordInfo(PasswordCallbackInfo info, boolean getPwdAgain) {
            if (getPwdAgain)
                enterPwdLabel.setText(mResource.getString(
                  "SSLCLIENT_PASSWORDAGAIN_DIALOG_LABEL")+" "+info.getName()+":");
            else
                enterPwdLabel.setText(mResource.getString(
                  "SSLCLIENT_PASSWORD_DIALOG_LABEL")+" "+ info.getName()+":");
            Debug.println(info.getName());
        }

        public Password getPassword() {
            Password jssPwd = new Password(pwd.getText().toCharArray());
            return jssPwd;
        }
    }


	class SelectCertDialog extends AbstractDialog {

        JComboBox certList = new JComboBox();
	    protected ResourceBundle mResource = ResourceBundle.getBundle(
          CMSAdminResources.class.getName());
        public SelectCertDialog() {
            super(null,"", true, OK|CANCEL);
	        setTitle(mResource.getString("SSLCLIENT_CERTSELECT_DIALOG_TITLE"));

            Container p = getContentPane();
            p.setLayout(new GridBagLayout());

            int y = 0;
            GridBagUtil.constrain(p, new JLabel(
              mResource.getString("SSLCLIENT_CERTSELECT_DIALOG_LABEL")),
              0, y, 1, 1,
              1.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
              0, 0, 0, 0);

            GridBagUtil.constrain(p, certList,
              0, ++y, 1, 1,
              1.0, 0.0,
              GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
              0, 0, 0, 0);
            pack();
        }

        public void setCertList(Vector nicknames) {
            certList.removeAllItems();
            Enumeration enum1 = nicknames.elements();
            while (enum1.hasMoreElements()) {
                certList.insertItemAt(enum1.nextElement(), 0);
            }
            try {
                certList.setSelectedIndex(0);
            } catch (Exception e) {
            }
        }

        public String getSelectedCert() {
            return certList.getSelectedItem().toString();
        }

	} 

}