Search in sources :

Example 31 with UserMessage

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

the class ProjectUnassignUserService method sendUserRemovedFromProjectEvent.

@IsSendingAsyncMessage(MessageID.USER_REMOVED_FROM_PROJECT)
private void sendUserRemovedFromProjectEvent(String projectId, User user) {
    DomainMessage request = new DomainMessage(MessageID.USER_REMOVED_FROM_PROJECT);
    UserMessage projectToUserData = new UserMessage();
    projectToUserData.setUserId(user.getName());
    projectToUserData.setProjectIds(Arrays.asList(projectId));
    request.set(MessageDataKeys.PROJECT_TO_USER_DATA, projectToUserData);
    eventBus.sendAsynchron(request);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) IsSendingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)

Example 32 with UserMessage

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

the class AnonymousUserRequestsNewApiTokenService method sendUserNewApiTokenRequested.

@IsSendingAsyncMessage(MessageID.USER_NEW_API_TOKEN_REQUESTED)
private void sendUserNewApiTokenRequested(String userEmail, 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(userEmail);
    /*
         * 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("Your request for a new SecHub API token");
    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 33 with UserMessage

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

the class InternalInitialDataService 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 34 with UserMessage

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

the class NotificationMessageHandlerTest method an_event_about_email_updatedeleted_user_triggers_UserEmailAddressChangedNotificationService.

@Test
public void an_event_about_email_updatedeleted_user_triggers_UserEmailAddressChangedNotificationService() {
    /* prepare */
    UserMessage userMessage = mock(UserMessage.class);
    DomainMessage request = mock(DomainMessage.class);
    when(request.getMessageId()).thenReturn(MessageID.USER_EMAIL_ADDRESS_CHANGED);
    when(request.get(MessageDataKeys.USER_EMAIL_ADDRESS_CHANGE_DATA)).thenReturn(userMessage);
    /* execute */
    handlerToTest.receiveAsyncMessage(request);
    /* test */
    verify(mockedUserEmailAddressChangedNotificationService).notify(userMessage);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

Example 35 with UserMessage

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

the class NotificationMessageHandlerTest method an_event_about_requested_new_api_token_triggers_newApiTokenRequestedUserNotificationService.

@Test
public void an_event_about_requested_new_api_token_triggers_newApiTokenRequestedUserNotificationService() {
    /* prepare */
    UserMessage userMessage = mock(UserMessage.class);
    DomainMessage request = mock(DomainMessage.class);
    when(request.getMessageId()).thenReturn(MessageID.USER_NEW_API_TOKEN_REQUESTED);
    when(request.get(MessageDataKeys.USER_ONE_TIME_TOKEN_INFO)).thenReturn(userMessage);
    /* execute */
    handlerToTest.receiveAsyncMessage(request);
    /* test */
    verify(mockedNewApiTokenRequestedUserNotificationService).notify(userMessage);
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.Test)

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