Search in sources :

Example 11 with UserMessage

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

the class AnonymousUserGetAPITokenByOneTimeTokenService method sendUserAPITokenChanged.

@IsSendingAsyncMessage(MessageID.USER_API_TOKEN_CHANGED)
private void sendUserAPITokenChanged(User user) {
    DomainMessage request = new DomainMessage(MessageID.USER_API_TOKEN_CHANGED);
    UserMessage message = new UserMessage();
    message.setEmailAdress(user.getEmailAdress());
    message.setUserId(user.getName());
    message.setHashedApiToken(user.getHashedApiToken());
    request.set(MessageDataKeys.USER_API_TOKEN_DATA, message);
    eventBusService.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 12 with UserMessage

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

the class ScheduleMessageHandlerTest method when_sending_message_id_USER_DELETED_the_revokeUserService_is_called.

@Test
void when_sending_message_id_USER_DELETED_the_revokeUserService_is_called() {
    /* prepare */
    DomainMessage request = new DomainMessage(MessageID.USER_DELETED);
    UserMessage content = new UserMessage();
    content.setUserId("userId1");
    request.set(MessageDataKeys.USER_DELETE_DATA, content);
    /* execute */
    simulateEventSend(request, scheduleHandlerToTest);
    /* test */
    verify(scheduleHandlerToTest.revokeUserService).revokeUserAccess("userId1");
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 13 with UserMessage

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

the class ScheduleMessageHandlerTest method when_sending_message_id_USER_REMOVED_FROM_PROJECT_the_revokeUserFromProjectService_is_called.

@Test
void when_sending_message_id_USER_REMOVED_FROM_PROJECT_the_revokeUserFromProjectService_is_called() {
    /* prepare */
    DomainMessage request = new DomainMessage(MessageID.USER_REMOVED_FROM_PROJECT);
    UserMessage content = new UserMessage();
    content.setProjectId("projectId1");
    content.setUserId("userId1");
    request.set(MessageDataKeys.PROJECT_TO_USER_DATA, content);
    /* execute */
    simulateEventSend(request, scheduleHandlerToTest);
    /* test */
    verify(scheduleHandlerToTest.revokeUserFromProjectService).revokeUserAccessFromProject("userId1", "projectId1");
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 14 with UserMessage

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

the class ScheduleMessageHandler method handleUserDeleted.

@IsReceivingAsyncMessage(MessageID.USER_DELETED)
private void handleUserDeleted(DomainMessage request) {
    UserMessage data = request.get(MessageDataKeys.USER_DELETE_DATA);
    revokeUserService.revokeUserAccess(data.getUserId());
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

Example 15 with UserMessage

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

the class ScheduleMessageHandler method handleUserRemovedFromProject.

@IsReceivingAsyncMessage(MessageID.USER_REMOVED_FROM_PROJECT)
private void handleUserRemovedFromProject(DomainMessage request) {
    UserMessage data = request.get(MessageDataKeys.PROJECT_TO_USER_DATA);
    revokeUserFromProjectService.revokeUserAccessFromProject(data.getUserId(), data.getProjectId());
}
Also used : UserMessage(com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage) IsReceivingAsyncMessage(com.mercedesbenz.sechub.sharedkernel.messaging.IsReceivingAsyncMessage)

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