Search in sources :

Example 1 with UseCaseUserClicksLinkToGetNewAPIToken

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

the class NewAPITokenAppliedUserNotificationService method notify.

@UseCaseUserClicksLinkToGetNewAPIToken(@Step(number = 4, next = { Step.NO_NEXT_STEP }, name = "Inform user about api token change done"))
public void notify(UserMessage userMessage) {
    StringBuilder emailContent = new StringBuilder();
    emailContent.append("You have requested a new api token.\n");
    emailContent.append(MessageFormat.format("The new api token has been applied to your user: {0}\n\n", userMessage.getUserId()));
    emailContent.append("If you have not triggered an api token change please inform administrators.\n");
    SimpleMailMessage message1 = factory.createMessage("SecHub API token changed");
    message1.setTo(userMessage.getEmailAdress());
    message1.setText(emailContent.toString());
    emailService.send(message1);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) UseCaseUserClicksLinkToGetNewAPIToken(com.mercedesbenz.sechub.sharedkernel.usecases.user.UseCaseUserClicksLinkToGetNewAPIToken)

Example 2 with UseCaseUserClicksLinkToGetNewAPIToken

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

the class AuthUpdateUserApiTokenService method updateAPIToken.

@UseCaseUserClicksLinkToGetNewAPIToken(@Step(number = 3, next = { Step.NO_NEXT_STEP }, name = "Update auth data"))
public void updateAPIToken(String userId, String hashedApiToken) {
    assertion.assertIsValidUserId(userId);
    AuthUser user = userRepo.findOrFail(userId);
    user.setHashedApiToken(hashedApiToken);
    userRepo.save(user);
    LOG.debug("API token for user:{} updated", userId);
}
Also used : AuthUser(com.mercedesbenz.sechub.domain.authorization.AuthUser) UseCaseUserClicksLinkToGetNewAPIToken(com.mercedesbenz.sechub.sharedkernel.usecases.user.UseCaseUserClicksLinkToGetNewAPIToken)

Aggregations

UseCaseUserClicksLinkToGetNewAPIToken (com.mercedesbenz.sechub.sharedkernel.usecases.user.UseCaseUserClicksLinkToGetNewAPIToken)2 AuthUser (com.mercedesbenz.sechub.domain.authorization.AuthUser)1 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)1