use of com.sequenceiq.freeipa.service.freeipa.user.model.EnvironmentAccessRights in project cloudbreak by hortonworks.
the class ActorHandler method handleActor.
public void handleActor(EnvironmentAccessRights environmentAccessRights, FmsUser fmsUser, String actorCrn, Supplier<Collection<String>> groupCrnMembershipSupplier, Supplier<Collection<String>> wagMembershipSupplier, Supplier<WorkloadCredential> workloadCredentialSupplier, List<UserManagementProto.CloudIdentity> cloudIdentityList) {
if (environmentAccessRights.hasEnvironmentAccessRight()) {
String workloadUsername = fmsUser.getName();
// Retrieve all information from UMS before modifying to the UmsUsersState or UsersState. This is so that
// we don't partially modify the state if the member has been deleted after we started the sync
Collection<String> groupCrnsForMember = groupCrnMembershipSupplier.get();
Collection<String> workloadAdministrationGroupsForMember = wagMembershipSupplier.get();
WorkloadCredential workloadCredential = workloadCredentialSupplier.get();
groupCrnsForMember.forEach(gcrn -> {
FmsGroup group = crnToFmsGroup.get(gcrn);
// the group and group membership will be updated on the next sync
if (group != null) {
usersStateBuilder.addMemberToGroup(group.getName(), workloadUsername);
} else {
LOGGER.warn("{} is a member of unexpected group {}. Group must have been added after UMS state calculation started", workloadUsername, gcrn);
}
});
workloadAdministrationGroupsForMember.stream().filter(wagName -> !wagNamesForOtherEnvironments.contains(wagName)).forEach(wagName -> {
usersStateBuilder.addGroup(fmsGroupConverter.nameToGroup(wagName));
usersStateBuilder.addMemberToGroup(wagName, workloadUsername);
});
addMemberToInternalTrackingGroup(usersStateBuilder, workloadUsername);
if (environmentAccessRights.hasAdminFreeIpaRight()) {
usersStateBuilder.addMemberToGroup(UserSyncConstants.ADMINS_GROUP, workloadUsername);
}
umsUsersStateBuilder.addWorkloadCredentials(workloadUsername, workloadCredential);
umsUsersStateBuilder.addUserCloudIdentities(workloadUsername, cloudIdentityList);
usersStateBuilder.addUserMetadata(workloadUsername, new UserMetadata(actorCrn, workloadCredential.getVersion()));
usersStateBuilder.addUser(fmsUser);
}
}
Aggregations