Browse code

chore: auth build context, useless user.getComplete

David Phan authored on 13/04/2018 07:38:31
Showing 1 changed files
... ...
@@ -185,7 +185,7 @@ public class Authentication implements IAuthentication, IInCoreAuthentication {
185 185
 			if (context == null) {
186 186
 				logger.info("l: '{}', o: '{}' successfully authentified", login, origin);
187 187
 				resp.authKey = UUID.randomUUID().toString();
188
-				context = buildSecurityContext(resp.authKey, authContext.user, realDomain, settings, origin,
188
+				context = buildSecurityContext(resp.authKey, authContext.user.uid, realDomain, settings, origin,
189 189
 						interactive);
190 190
 
191 191
 				for (ILoginSessionValidator v : sessionValidators) {
... ...
@@ -365,7 +365,7 @@ public class Authentication implements IAuthentication, IInCoreAuthentication {
365 365
 			ServerSideServiceProvider sp = ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM);
366 366
 			Map<String, String> settings = sp.instance(IUserSettings.class, domainPart).get(user.uid);
367 367
 
368
-			SecurityContext context = buildSecurityContext(resp.authKey, user, domainPart, settings,
368
+			SecurityContext context = buildSecurityContext(resp.authKey, user.uid, domainPart, settings,
369 369
 					securityContext.getOrigin(), interactive);
370 370
 
371 371
 			resp.authUser = AuthUser.create(context.getContainerUid(), context.getSubject(), user.displayName,
... ...
@@ -422,19 +422,19 @@ public class Authentication implements IAuthentication, IInCoreAuthentication {
422 422
 		VertxPlatform.eventBus().publish("core.user.push.queue.removed", "client.session." + context.getSessionId());
423 423
 	}
424 424
 
425
-	private SecurityContext buildSecurityContext(String authKey, ItemValue<User> user, String domainUid,
425
+	private SecurityContext buildSecurityContext(String authKey, String userUid, String domainUid,
426 426
 			Map<String, String> config, String origin, boolean interactive) throws ServerFault {
427 427
 		ServerSideServiceProvider sp = ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM);
428
-		List<String> groups = sp.instance(IUser.class, domainUid).memberOfGroups(user.uid);
428
+		List<String> groups = sp.instance(IUser.class, domainUid).memberOfGroups(userUid);
429 429
 
430 430
 		IOrgUnits orgUnits = sp.instance(IOrgUnits.class, domainUid);
431
-		List<OrgUnitPath> ous = orgUnits.listByAdministrator(user.uid);
431
+		List<OrgUnitPath> ous = orgUnits.listByAdministrator(userUid);
432 432
 		Map<String, Set<String>> rolesByOUs = ous.stream() //
433 433
 				.collect(Collectors.toMap( //
434 434
 						ouPath -> ouPath.uid, // key: orgUnit.uid
435
-						ouPath -> orgUnits.getAdministratorRoles(ouPath.uid, user.uid))); // roles
435
+						ouPath -> orgUnits.getAdministratorRoles(ouPath.uid, userUid))); // roles
436 436
 
437
-		return new SecurityContext(authKey, user.uid, groups, new ArrayList<>(getRoles(user.uid, groups, domainUid)),
437
+		return new SecurityContext(authKey, userUid, groups, new ArrayList<>(getRoles(userUid, groups, domainUid)),
438 438
 				rolesByOUs, domainUid, config.get("lang"), origin, interactive);
439 439
 	}
440 440
 
... ...
@@ -450,11 +450,9 @@ public class Authentication implements IAuthentication, IInCoreAuthentication {
450 450
 
451 451
 	@Override
452 452
 	public SecurityContext buildContext(String domainUid, String userUid) throws ServerFault {
453
-		ItemValue<User> user = ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM)
454
-				.instance(IUser.class, domainUid).getComplete(userUid);
455 453
 		Map<String, String> settings = ServerSideServiceProvider.getProvider(SecurityContext.SYSTEM)
456 454
 				.instance(IUserSettings.class, domainUid).get(userUid);
457
-		return buildSecurityContext(null, user, domainUid, settings, securityContext.getOrigin(), false);
455
+		return buildSecurityContext(null, userUid, domainUid, settings, securityContext.getOrigin(), false);
458 456
 	}
459 457
 
460 458
 	@Override