synchronized public void setUseClientMode ( boolean flag ) { switch ( connectionState ) { case cs_START : /* * If we need to change the engine mode and the enabled * protocols haven't specifically been set by the user, * change them to the corresponding default ones. */ if ( roleIsServer != ( ! flag ) && sslContext . isDefaultProtocolList ( enabledProtocols ) ) { enabledProtocols = sslContext . getDefaultProtocolList ( ! flag ) ; } roleIsServer = ! flag ; serverModeSet = true ; break ; case cs_HANDSHAKE : /* * If we have a handshaker, but haven't started * SSL traffic, we can throw away our current * handshaker, and start from scratch. Don't * need to call doneConnect() again, we already * have the streams. */ assert ( handshaker != null ) ; if ( ! handshaker . activated ( ) ) { /* * If we need to change the engine mode and the enabled * protocols haven't specifically been set by the user, * change them to the corresponding default ones. */ if ( roleIsServer != ( ! flag ) && sslContext . isDefaultProtocolList ( enabledProtocols ) ) { enabledProtocols = sslContext . getDefaultProtocolList ( ! flag ) ; } roleIsServer = ! flag ; connectionState = cs_START ; initHandshaker ( ) ; break ; } // If handshake has started, that's an error. Fall through... default : if ( debug != null && Debug . isOn ( "ssl" ) ) { System . out . println ( threadName ( ) + ", setUseClientMode() invoked in state = " + connectionState ) ; } /* * We can let them continue if they catch this correctly, * we don't need to shut this down. */ throw new IllegalArgumentException ( "Cannot change mode after SSL traffic has started" ) ; } }
Sets the flag controlling whether the engine is in SSL client or server mode . Must be called before any SSL traffic has started .