1717
1818package com .cloud .consoleproxy ;
1919
20+ import java .security .NoSuchAlgorithmException ;
21+ import java .security .SecureRandom ;
2022import java .util .Date ;
21- import java .util .Random ;
2223
24+ import org .apache .commons .codec .binary .Base64 ;
2325import org .apache .log4j .Logger ;
2426
2527import com .google .gson .Gson ;
@@ -66,7 +68,6 @@ public abstract class AgentHookBase implements AgentHook {
6668 ConfigurationDao _configDao ;
6769 AgentManager _agentMgr ;
6870 KeystoreManager _ksMgr ;
69- final Random _random = new Random (System .currentTimeMillis ());
7071 KeysManager _keysMgr ;
7172
7273 public AgentHookBase (VMInstanceDao instanceDao , HostDao hostDao , ConfigurationDao cfgDao , KeystoreManager ksMgr , AgentManager agentMgr , KeysManager keysMgr ) {
@@ -188,8 +189,6 @@ public AgentControlAnswer onConsoleAccessAuthentication(ConsoleAccessAuthenticat
188189 @ Override
189190 public void startAgentHttpHandlerInVM (StartupProxyCommand startupCmd ) {
190191 StartConsoleProxyAgentHttpHandlerCommand cmd = null ;
191- String storePassword = String .valueOf (_random .nextLong ());
192- byte [] ksBits = _ksMgr .getKeystoreBits (ConsoleProxyManager .CERTIFICATE_NAME , ConsoleProxyManager .CERTIFICATE_NAME , storePassword );
193192
194193 try {
195194 SecureRandom random = SecureRandom .getInstance ("SHA1PRNG" );
@@ -213,13 +212,16 @@ public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd) {
213212 HostVO consoleProxyHost = findConsoleProxyHost (startupCmd );
214213
215214 assert (consoleProxyHost != null );
216-
217- Answer answer = _agentMgr .send (consoleProxyHost .getId (), cmd );
218- if (answer == null || !answer .getResult ()) {
219- s_logger .error ("Console proxy agent reported that it failed to execute http handling startup command" );
220- } else {
221- s_logger .info ("Successfully sent out command to start HTTP handling in console proxy agent" );
215+ if (consoleProxyHost != null ) {
216+ Answer answer = _agentMgr .send (consoleProxyHost .getId (), cmd );
217+ if (answer == null || !answer .getResult ()) {
218+ s_logger .error ("Console proxy agent reported that it failed to execute http handling startup command" );
219+ } else {
220+ s_logger .info ("Successfully sent out command to start HTTP handling in console proxy agent" );
221+ }
222222 }
223+ }catch (NoSuchAlgorithmException e ) {
224+ s_logger .error ("Unexpected exception in SecureRandom Algorithm selection " , e );
223225 } catch (AgentUnavailableException e ) {
224226 s_logger .error ("Unable to send http handling startup command to the console proxy resource for proxy:" + startupCmd .getProxyVmId (), e );
225227 } catch (OperationTimedoutException e ) {
0 commit comments