@@ -61,11 +61,11 @@ public class SecretSessionBaseService {
6161 private final TeeTaskComputeSecretService teeTaskComputeSecretService ;
6262
6363 public SecretSessionBaseService (
64- Web3SecretService web3SecretService ,
65- Web2SecretService web2SecretService ,
66- TeeChallengeService teeChallengeService ,
67- TeeServicesProperties teeServicesConfig ,
68- TeeTaskComputeSecretService teeTaskComputeSecretService ) {
64+ final Web3SecretService web3SecretService ,
65+ final Web2SecretService web2SecretService ,
66+ final TeeChallengeService teeChallengeService ,
67+ final TeeServicesProperties teeServicesConfig ,
68+ final TeeTaskComputeSecretService teeTaskComputeSecretService ) {
6969 this .web3SecretService = web3SecretService ;
7070 this .web2SecretService = web2SecretService ;
7171 this .teeChallengeService = teeChallengeService ;
@@ -79,7 +79,7 @@ public SecretSessionBaseService(
7979 * @param request session request details
8080 * @return All common tokens for a session, whatever TEE technology is used
8181 */
82- public SecretSessionBase getSecretsTokens (TeeSessionRequest request ) throws TeeSessionGenerationException {
82+ public SecretSessionBase getSecretsTokens (final TeeSessionRequest request ) throws TeeSessionGenerationException {
8383 if (request == null ) {
8484 throw new TeeSessionGenerationException (
8585 NO_SESSION_REQUEST ,
@@ -90,11 +90,10 @@ public SecretSessionBase getSecretsTokens(TeeSessionRequest request) throws TeeS
9090 NO_TASK_DESCRIPTION ,
9191 "Task description must not be null" );
9292 }
93- SecretSessionBaseBuilder sessionBase = SecretSessionBase .builder ();
94- TaskDescription taskDescription = request .getTaskDescription ();
93+ final SecretSessionBaseBuilder sessionBase = SecretSessionBase .builder ();
94+ final TaskDescription taskDescription = request .getTaskDescription ();
9595 // pre-compute
96- final boolean isPreComputeRequired = taskDescription .containsDataset () ||
97- taskDescription .containsInputFiles ();
96+ final boolean isPreComputeRequired = taskDescription .containsDataset () || taskDescription .containsInputFiles ();
9897 if (isPreComputeRequired ) {
9998 sessionBase .preCompute (getPreComputeTokens (request ));
10099 }
@@ -112,21 +111,20 @@ public SecretSessionBase getSecretsTokens(TeeSessionRequest request) throws TeeS
112111 * @return {@link SecretEnclaveBase} instance
113112 * @throws TeeSessionGenerationException if dataset secret is not found
114113 */
115- public SecretEnclaveBase getPreComputeTokens (TeeSessionRequest request )
116- throws TeeSessionGenerationException {
117- SecretEnclaveBaseBuilder enclaveBase = SecretEnclaveBase .builder ();
114+ SecretEnclaveBase getPreComputeTokens (final TeeSessionRequest request ) throws TeeSessionGenerationException {
115+ final SecretEnclaveBaseBuilder enclaveBase = SecretEnclaveBase .builder ();
118116 enclaveBase .name ("pre-compute" );
119- Map <String , Object > tokens = new HashMap <>();
120- TaskDescription taskDescription = request .getTaskDescription ();
121- String taskId = taskDescription .getChainTaskId ();
117+ final Map <String , Object > tokens = new HashMap <>();
118+ final TaskDescription taskDescription = request .getTaskDescription ();
119+ final String taskId = taskDescription .getChainTaskId ();
122120 enclaveBase .mrenclave (teeServicesConfig .getPreComputeProperties ().getFingerprint ());
123121 tokens .put (IEXEC_PRE_COMPUTE_OUT , IexecFileHelper .SLASH_IEXEC_IN );
124122 // `IS_DATASET_REQUIRED` still meaningful?
125123 tokens .put (IS_DATASET_REQUIRED , taskDescription .containsDataset ());
126124
127- List <String > trustedEnv = new ArrayList <>();
125+ final List <String > trustedEnv = new ArrayList <>();
128126 if (taskDescription .containsDataset ()) {
129- String datasetKey = web3SecretService
127+ final String datasetKey = web3SecretService
130128 .getDecryptedValue (taskDescription .getDatasetAddress ())
131129 .orElseThrow (() -> new TeeSessionGenerationException (
132130 PRE_COMPUTE_GET_DATASET_SECRET_FAILED ,
@@ -164,19 +162,13 @@ public SecretEnclaveBase getPreComputeTokens(TeeSessionRequest request)
164162 * @return {@link SecretEnclaveBase} instance
165163 * @throws TeeSessionGenerationException if {@code TaskDescription} is {@literal null} or does not contain a {@code TeeEnclaveConfiguration}
166164 */
167- public SecretEnclaveBase getAppTokens (TeeSessionRequest request )
168- throws TeeSessionGenerationException {
169- SecretEnclaveBaseBuilder enclaveBase = SecretEnclaveBase .builder ();
165+ SecretEnclaveBase getAppTokens (final TeeSessionRequest request ) throws TeeSessionGenerationException {
166+ final SecretEnclaveBaseBuilder enclaveBase = SecretEnclaveBase .builder ();
170167 enclaveBase .name ("app" );
171- TaskDescription taskDescription = request .getTaskDescription ();
172- if (taskDescription == null ) {
173- throw new TeeSessionGenerationException (
174- NO_TASK_DESCRIPTION ,
175- "Task description must not be null" );
176- }
168+ final TaskDescription taskDescription = request .getTaskDescription ();
177169
178- Map <String , Object > tokens = new HashMap <>();
179- TeeEnclaveConfiguration enclaveConfig = taskDescription .getAppEnclaveConfiguration ();
170+ final Map <String , Object > tokens = new HashMap <>();
171+ final TeeEnclaveConfiguration enclaveConfig = taskDescription .getAppEnclaveConfiguration ();
180172 if (enclaveConfig == null ) {
181173 throw new TeeSessionGenerationException (
182174 APP_COMPUTE_NO_ENCLAVE_CONFIG ,
@@ -207,7 +199,7 @@ public SecretEnclaveBase getAppTokens(TeeSessionRequest request)
207199 .build ();
208200 }
209201
210- private Map <String , Object > getApplicationComputeSecrets (TaskDescription taskDescription ) {
202+ private Map <String , Object > getApplicationComputeSecrets (final TaskDescription taskDescription ) {
211203 final Map <String , Object > tokens = new HashMap <>();
212204 final List <TeeTaskComputeSecretHeader > ids = getAppComputeSecretsHeaders (taskDescription );
213205 log .debug ("TeeTaskComputeSecret looking for secrets [chainTaskId:{}, count:{}]" ,
@@ -231,7 +223,7 @@ private Map<String, Object> getApplicationComputeSecrets(TaskDescription taskDes
231223 return tokens ;
232224 }
233225
234- private List <TeeTaskComputeSecretHeader > getAppComputeSecretsHeaders (TaskDescription taskDescription ) {
226+ private List <TeeTaskComputeSecretHeader > getAppComputeSecretsHeaders (final TaskDescription taskDescription ) {
235227 final List <TeeTaskComputeSecretHeader > ids = new ArrayList <>();
236228 final String applicationAddress = taskDescription .getAppAddress ();
237229 if (applicationAddress != null ) {
@@ -247,9 +239,9 @@ private List<TeeTaskComputeSecretHeader> getAppComputeSecretsHeaders(TaskDescrip
247239 if (taskDescription .getSecrets () != null && taskDescription .getRequester () != null ) {
248240 for (Map .Entry <String , String > secretEntry : taskDescription .getSecrets ().entrySet ()) {
249241 try {
250- int requesterSecretIndex = Integer .parseInt (secretEntry .getKey ());
242+ final int requesterSecretIndex = Integer .parseInt (secretEntry .getKey ());
251243 if (requesterSecretIndex <= 0 ) {
252- String message = "Application secret indices provided in the deal parameters must be positive numbers"
244+ final String message = "Application secret indices provided in the deal parameters must be positive numbers"
253245 + " [providedApplicationSecretIndex:" + requesterSecretIndex + "]" ;
254246 log .warn (message );
255247 throw new NumberFormatException (message );
@@ -276,17 +268,12 @@ private List<TeeTaskComputeSecretHeader> getAppComputeSecretsHeaders(TaskDescrip
276268 * @return {@link SecretEnclaveBase} instance
277269 * @throws TeeSessionGenerationException if {@code TaskDescription} is {@literal null}
278270 */
279- public SecretEnclaveBase getPostComputeTokens (TeeSessionRequest request )
280- throws TeeSessionGenerationException {
281- SecretEnclaveBaseBuilder enclaveBase = SecretEnclaveBase .builder ()
271+ SecretEnclaveBase getPostComputeTokens (final TeeSessionRequest request ) throws TeeSessionGenerationException {
272+ final SecretEnclaveBaseBuilder enclaveBase = SecretEnclaveBase .builder ()
282273 .name ("post-compute" )
283274 .mrenclave (teeServicesConfig .getPostComputeProperties ().getFingerprint ());
284- Map <String , Object > tokens = new HashMap <>();
285- TaskDescription taskDescription = request .getTaskDescription ();
286- if (taskDescription == null ) {
287- throw new TeeSessionGenerationException (NO_TASK_DESCRIPTION , "Task description must not be null" );
288- }
289-
275+ final Map <String , Object > tokens = new HashMap <>();
276+ final TaskDescription taskDescription = request .getTaskDescription ();
290277 final List <Web2SecretHeader > ids = getPostComputeSecretHeaders (taskDescription , request .getWorkerAddress ());
291278 log .debug ("Web2Secret looking for secrets [chainTaskId:{}, count:{}]" ,
292279 taskDescription .getChainTaskId (), ids .size ());
@@ -332,14 +319,14 @@ public SecretEnclaveBase getPostComputeTokens(TeeSessionRequest request)
332319 tokens .putAll (getPostComputeStorageTokens (request , storageToken , storageProxy ));
333320 }
334321 // enclave signature
335- Map <String , String > signTokens = getPostComputeSignTokens (request );
322+ final Map <String , String > signTokens = getPostComputeSignTokens (request );
336323 tokens .putAll (signTokens );
337324 return enclaveBase
338325 .environment (tokens )
339326 .build ();
340327 }
341328
342- List <Web2SecretHeader > getPostComputeSecretHeaders (TaskDescription taskDescription , String workerAddress ) {
329+ List <Web2SecretHeader > getPostComputeSecretHeaders (final TaskDescription taskDescription , final String workerAddress ) {
343330 final List <Web2SecretHeader > ids = new ArrayList <>();
344331 if (taskDescription .isResultEncryption ()) {
345332 ids .add (new Web2SecretHeader (taskDescription .getBeneficiary (), IEXEC_RESULT_ENCRYPTION_PUBLIC_KEY ));
@@ -354,12 +341,12 @@ List<Web2SecretHeader> getPostComputeSecretHeaders(TaskDescription taskDescripti
354341 return ids ;
355342 }
356343
357- public Map <String , String > getPostComputeEncryptionTokens (TeeSessionRequest request , String resultEncryptionKey )
344+ Map <String , String > getPostComputeEncryptionTokens (final TeeSessionRequest request , final String resultEncryptionKey )
358345 throws TeeSessionGenerationException {
359- TaskDescription taskDescription = request .getTaskDescription ();
360- String taskId = taskDescription .getChainTaskId ();
361- Map <String , String > tokens = new HashMap <>();
362- boolean shouldEncrypt = taskDescription .isResultEncryption ();
346+ final TaskDescription taskDescription = request .getTaskDescription ();
347+ final String taskId = taskDescription .getChainTaskId ();
348+ final Map <String , String > tokens = new HashMap <>();
349+ final boolean shouldEncrypt = taskDescription .isResultEncryption ();
363350 // TODO use boolean with quotes instead of yes/no
364351 tokens .put (RESULT_ENCRYPTION , booleanToYesNo (shouldEncrypt ));
365352 tokens .put (RESULT_ENCRYPTION_PUBLIC_KEY , EMPTY_STRING_VALUE );
@@ -379,13 +366,13 @@ public Map<String, String> getPostComputeEncryptionTokens(TeeSessionRequest requ
379366 // to the beneficiary private storage space waiting for
380367 // that feature we only allow to push to the requester
381368 // private storage space
382- public Map <String , String > getPostComputeStorageTokens (final TeeSessionRequest request ,
383- final String storageToken ,
384- final String resultProxyUrl ) throws TeeSessionGenerationException {
385- TaskDescription taskDescription = request .getTaskDescription ();
386- String taskId = taskDescription .getChainTaskId ();
387- Map <String , String > tokens = new HashMap <>();
388- boolean isCallbackRequested = taskDescription .containsCallback ();
369+ Map <String , String > getPostComputeStorageTokens (final TeeSessionRequest request ,
370+ final String storageToken ,
371+ final String resultProxyUrl ) throws TeeSessionGenerationException {
372+ final TaskDescription taskDescription = request .getTaskDescription ();
373+ final String taskId = taskDescription .getChainTaskId ();
374+ final Map <String , String > tokens = new HashMap <>();
375+ final boolean isCallbackRequested = taskDescription .containsCallback ();
389376 tokens .put (RESULT_STORAGE_CALLBACK , booleanToYesNo (isCallbackRequested ));
390377 tokens .put (RESULT_STORAGE_PROVIDER , EMPTY_STRING_VALUE );
391378 tokens .put (RESULT_STORAGE_PROXY , EMPTY_STRING_VALUE );
@@ -408,11 +395,10 @@ public Map<String, String> getPostComputeStorageTokens(final TeeSessionRequest r
408395 return tokens ;
409396 }
410397
411- public Map <String , String > getPostComputeSignTokens (TeeSessionRequest request )
412- throws TeeSessionGenerationException {
413- String taskId = request .getTaskDescription ().getChainTaskId ();
414- String workerAddress = request .getWorkerAddress ();
415- Map <String , String > tokens = new HashMap <>();
398+ Map <String , String > getPostComputeSignTokens (final TeeSessionRequest request ) throws TeeSessionGenerationException {
399+ final String taskId = request .getTaskDescription ().getChainTaskId ();
400+ final String workerAddress = request .getWorkerAddress ();
401+ final Map <String , String > tokens = new HashMap <>();
416402 if (StringUtils .isEmpty (workerAddress )) {
417403 throw new TeeSessionGenerationException (
418404 POST_COMPUTE_GET_SIGNATURE_TOKENS_FAILED_EMPTY_WORKER_ADDRESS ,
@@ -423,13 +409,13 @@ public Map<String, String> getPostComputeSignTokens(TeeSessionRequest request)
423409 POST_COMPUTE_GET_SIGNATURE_TOKENS_FAILED_EMPTY_PUBLIC_ENCLAVE_CHALLENGE ,
424410 "Empty public enclave challenge - taskId: " + taskId );
425411 }
426- Optional <TeeChallenge > teeChallenge = teeChallengeService .getOrCreate (taskId , true );
412+ final Optional <TeeChallenge > teeChallenge = teeChallengeService .getOrCreate (taskId , true );
427413 if (teeChallenge .isEmpty ()) {
428414 throw new TeeSessionGenerationException (
429415 POST_COMPUTE_GET_SIGNATURE_TOKENS_FAILED_EMPTY_TEE_CHALLENGE ,
430416 "Empty TEE challenge - taskId: " + taskId );
431417 }
432- EthereumCredentials enclaveCredentials = teeChallenge .get ().getCredentials ();
418+ final EthereumCredentials enclaveCredentials = teeChallenge .get ().getCredentials ();
433419 if (enclaveCredentials == null || enclaveCredentials .getPrivateKey ().isEmpty ()) {
434420 throw new TeeSessionGenerationException (
435421 POST_COMPUTE_GET_SIGNATURE_TOKENS_FAILED_EMPTY_TEE_CREDENTIALS ,
0 commit comments