Search in sources :

Example 1 with UseCaseAdminGrantsAdminRightsToUser

use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser in project sechub by mercedes-benz.

the class UserGrantSuperAdminRightsService method grantSuperAdminRightsFor.

/* @formatter:off */
@Validated
@UseCaseAdminGrantsAdminRightsToUser(@Step(number = 2, name = "Service grants user admin rights.", next = { 3, 4 }, description = "The service will grant user admin righs and triggers asynchronous events"))
public /* @formatter:on */
void grantSuperAdminRightsFor(String userId) {
    auditLogService.log("Triggered granting admin rights for user {}", logSanitizer.sanitize(userId, 30));
    assertion.assertIsValidUserId(userId);
    User user = userRepository.findOrFailUser(userId);
    if (user.isSuperAdmin()) {
        LOG.info("User:{} was already a super administrator, so just ignored", user.getName());
        return;
    }
    user.superAdmin = true;
    userRepository.save(user);
    requestUserRoleRecalculaton(user);
    informUserBecomesSuperadmin(user);
}
Also used : UseCaseAdminGrantsAdminRightsToUser(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser) Validated(org.springframework.validation.annotation.Validated) UseCaseAdminGrantsAdminRightsToUser(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser)

Example 2 with UseCaseAdminGrantsAdminRightsToUser

use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser in project sechub by mercedes-benz.

the class InformAdminsThatUserBecomesAdminNotificationService method notify.

@UseCaseAdminGrantsAdminRightsToUser(@Step(number = 4, next = { Step.NO_NEXT_STEP }, name = "Inform SecHub admins that another user became administrator"))
public void notify(UserMessage userMessage, String baseUrl) {
    SimpleMailMessage message = factory.createMessage("SecHub: Granted administrator rights to " + userMessage.getUserId());
    message.setTo(notificationConfiguration.getEmailAdministrators());
    message.setText(createEmailContent(userMessage, baseUrl));
    emailService.send(message);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) UseCaseAdminGrantsAdminRightsToUser(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser)

Example 3 with UseCaseAdminGrantsAdminRightsToUser

use of com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser in project sechub by mercedes-benz.

the class InformUserThatUserBecomesAdminNotificationService method notify.

@UseCaseAdminGrantsAdminRightsToUser(@Step(number = 3, next = { 4 }, name = "Inform user that he/she became administrator"))
public void notify(UserMessage userMessage, String baseUrl) {
    SimpleMailMessage message = factory.createMessage("SecHub administrator privileges granted");
    message.setTo(userMessage.getEmailAdress());
    message.setText(createEmailContent(userMessage, baseUrl));
    emailService.send(message);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) UseCaseAdminGrantsAdminRightsToUser(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser)

Aggregations

UseCaseAdminGrantsAdminRightsToUser (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminGrantsAdminRightsToUser)3 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)2 Validated (org.springframework.validation.annotation.Validated)1