Search in sources :

Example 6 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class UserCreationService method informUserAboutSignupAccepted.

@IsSendingAsyncMessage(MessageID.USER_NEW_API_TOKEN_REQUESTED)
private void informUserAboutSignupAccepted(User user) {
    /* we just send info about new api token */
    DomainMessage infoRequest = new DomainMessage(MessageID.USER_NEW_API_TOKEN_REQUESTED);
    UserMessage userMessage = new UserMessage();
    userMessage.setEmailAdress(user.getEmailAdress());
    /*
         * Security: we do NOT use userid inside this link - if some body got
         * information about the link he/she is not able to use fetched api token
         * because not knowing which userid...
         */
    String linkWithOneTimeToken = environment.getServerBaseUrl() + AdministrationAPIConstants.API_FETCH_NEW_API_TOKEN_BY_ONE_WAY_TOKEN + "/" + user.getOneTimeToken();
    userMessage.setLinkWithOneTimeToken(linkWithOneTimeToken);
    userMessage.setSubject("SecHub user account created");
    infoRequest.set(MessageDataKeys.USER_ONE_TIME_TOKEN_INFO, userMessage);
    eventBusService.sendAsynchron(infoRequest);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 7 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class UserCreationService method createInitialUserAuthData.

private UserMessage createInitialUserAuthData(User user) {
    UserMessage authDataHashed = new UserMessage();
    authDataHashed.setUserId(user.getName());
    authDataHashed.setEmailAdress(user.getEmailAdress());
    return authDataHashed;
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage)

Example 8 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class UserCreationService method informUserCreated.

@IsSendingAsyncMessage(MessageID.USER_CREATED)
private void informUserCreated(User user) {
    DomainMessage infoRequest = new DomainMessage(MessageID.USER_CREATED);
    UserMessage message = createInitialUserAuthData(user);
    infoRequest.set(MessageDataKeys.USER_CREATION_DATA, message);
    eventBusService.sendAsynchron(infoRequest);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 9 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class UserDeleteService method deleteUser.

/* @formatter:off */
@Validated
@UseCaseAdminDeletesUser(@Step(number = 2, name = "Service deletes user.", next = { 3, 4 }, description = "The service will delete the user with dependencies and triggers asynchronous events"))
/* @formatter:on */
@Transactional
public void deleteUser(String userId) {
    auditLogService.log("Triggers delete of user {}", logSanitizer.sanitize(userId, 30));
    assertion.assertIsValidUserId(userId);
    if (userId.contentEquals(userContext.getUserId())) {
        throw new NotAcceptableException("You are not allowed to delete yourself!");
    }
    User user = userRepository.findOrFailUser(userId);
    /* create message containing data before user is deleted */
    UserMessage message = new UserMessage();
    message.setUserId(user.getName());
    message.setEmailAdress(user.getEmailAdress());
    userRepository.deleteUserWithAssociations(user.getName());
    informUserDeleted(message);
}
Also used : UseCaseAdminDeletesUser(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminDeletesUser) NotAcceptableException(com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException) UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) Validated(org.springframework.validation.annotation.Validated) UseCaseAdminDeletesUser(com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminDeletesUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with UserMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage in project sechub by mercedes-benz.

the class AnonymousSignupCreateService method informAboutSignupRequest.

@IsSendingAsyncMessage(MessageID.USER_SIGNUP_REQUESTED)
private void informAboutSignupRequest(Signup signup) {
    DomainMessage infoRequest = new DomainMessage(MessageID.USER_SIGNUP_REQUESTED);
    UserMessage userMessage = new UserMessage();
    userMessage.setEmailAdress(signup.getEmailAdress());
    userMessage.setUserId(signup.getUserId());
    infoRequest.set(MessageDataKeys.USER_SIGNUP_DATA, userMessage);
    eventBusService.sendAsynchron(infoRequest);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Aggregations

UserMessage (com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage)38 DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)21 IsReceivingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)11 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)10 Test (org.junit.Test)8 Test (org.junit.jupiter.api.Test)5 NotAcceptableException (com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException)2 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Validated (org.springframework.validation.annotation.Validated)2 UseCaseAdminDeletesUser (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminDeletesUser)1 UseCaseAdminUpdatesUserEmailAddress (com.mercedesbenz.sechub.sharedkernel.usecases.admin.user.UseCaseAdminUpdatesUserEmailAddress)1