1 23 package com.sun.appserv.management.client; 24 25 import java.io.File ; 26 27 import javax.net.ssl.X509TrustManager; 28 import javax.net.ssl.HandshakeCompletedListener; 29 30 37 public final class TLSParams 38 { 39 private final X509TrustManager[] mTrustManagers; 40 private final HandshakeCompletedListener mHandshakeCompletedListener; 41 42 50 public static X509TrustManager[] 51 getTrustManagers( 52 final File trustStore, 53 final char[] trustStorePassword, 54 final boolean prompt ) 55 { 56 final TrustStoreTrustManager mgr = 57 new TrustStoreTrustManager( trustStore, trustStorePassword ); 58 mgr.setPrompt( prompt ); 59 60 final X509TrustManager[] trustMgrs = new X509TrustManager[] { mgr }; 61 62 return( trustMgrs ); 63 } 64 65 71 public 72 TLSParams( 73 final File trustStore, 74 final char[] trustStorePassword, 75 final boolean prompt, 76 final HandshakeCompletedListener handshakeCompletedListener ) 77 { 78 this( getTrustManagers( trustStore, trustStorePassword, prompt), handshakeCompletedListener ); 79 80 } 81 82 86 public 87 TLSParams( 88 final X509TrustManager[] trustManagers, 89 final HandshakeCompletedListener handshakeCompletedListener ) 90 { 91 if ( trustManagers == null ) 92 { 93 throw new IllegalArgumentException (); 94 } 95 96 mTrustManagers = trustManagers; 97 mHandshakeCompletedListener = handshakeCompletedListener; 98 } 99 100 104 public 105 TLSParams( 106 final X509TrustManager trustManager, 107 final HandshakeCompletedListener handshakeCompletedListener ) 108 { 109 this( new X509TrustManager[] { trustManager }, handshakeCompletedListener ); 110 } 111 112 115 public X509TrustManager[] 116 getTrustManagers( ) 117 { 118 return( mTrustManagers ); 119 } 120 121 124 public HandshakeCompletedListener 125 getHandshakeCompletedListener( ) 126 { 127 return( mHandshakeCompletedListener ); 128 } 129 } 130 | Popular Tags |