@@ -77,11 +77,11 @@ public void onApplicationEvent(final ApplicationReadyEvent event) {
7777
7878 verbRegistry .scanClasspath ();
7979
80- final UserDTO user = UserDTO .builder ()
80+ UserDTO user = UserDTO .builder ()
8181 .username (zeroTrustClientService .getUsername ())
8282 .build ();
8383 var execution = agentExecutionService .getAgentExecution (user );
84-
84+
8585 var keyPair = agentKeyService .getKeyPair ();
8686 try {
8787 agentClientService .heartbeat (execution , execution .getUser ().getUsername ());
@@ -104,7 +104,7 @@ public void onApplicationEvent(final ApplicationReadyEvent event) {
104104 log .info ("Registering v1.0.2 agent failed. Retrying in 10 seconds..." );
105105
106106 try {
107- var agentName = agentConfigOptions . getNamePrefix () + "-" + UUID . randomUUID (). toString ();
107+ var agentName = execution . getUser (). getUsername ();
108108 var base64PublicKey = agentKeyService .getBase64PublicKey (keyPair .getPublic ());
109109 var agentRegistrationDTO = agentClientService .bootstrap (
110110 agentName , base64PublicKey
@@ -119,10 +119,11 @@ public void onApplicationEvent(final ApplicationReadyEvent event) {
119119 decryptedSecret
120120 );
121121
122- final UserDTO newUserDTO = UserDTO .builder ()
122+ user = UserDTO .builder ()
123123 .username (zeroTrustClientService .getUsername ())
124124 .build ();
125- execution = agentExecutionService .getAgentExecution (newUserDTO );
125+
126+ execution = agentExecutionService .getAgentExecution (user );
126127 } catch (Exception e1 ) {
127128 log .error ("Failed to bootstrap agent" , e1 );
128129 } catch (ZtatException ex ) {
@@ -136,15 +137,16 @@ public void onApplicationEvent(final ApplicationReadyEvent event) {
136137 }
137138 }
138139
140+ UserDTO finalUser = user ;
139141 workerThread = new Thread (() -> {
140142 try {
141143
142- log .info ("Username: {}" , user .getUsername ());
144+ log .info ("Username: {}" , finalUser .getUsername ());
143145 log .info ("Registering v1.0.2 agent..." );
144146
145147
146148
147- var agentExecution = agentExecutionService .getAgentExecution (user );
149+ var agentExecution = agentExecutionService .getAgentExecution (finalUser );
148150 var response = promptAgent (agentExecution );
149151 while (running ) {
150152 try {
0 commit comments