Search in sources :

Example 6 with DomainMessage

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

the class UserRoleCalculationService method sendUserRoleChangedEvent.

@IsSendingAsyncMessage(MessageID.USER_ROLES_CHANGED)
private void sendUserRoleChangedEvent(User user, Set<String> roles) {
    DomainMessage roleChangeRequest = new DomainMessage(MessageID.USER_ROLES_CHANGED);
    UserMessage rolesData = new UserMessage();
    rolesData.setUserId(user.getName());
    rolesData.setRoles(roles);
    roleChangeRequest.set(MessageDataKeys.USER_ROLES_DATA, rolesData);
    eventBus.sendAsynchron(roleChangeRequest);
}
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 DomainMessage

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

the class ProjectChangeAccessLevelServiceTest method a_change_from_full_access_to_read_only_does_trigger_one_async_event_containing_old_and_new_access_level.

@Test
void a_change_from_full_access_to_read_only_does_trigger_one_async_event_containing_old_and_new_access_level() {
    /* prepare */
    Project project = new Project();
    when(repository.findOrFailProject(PROJECT1_ID)).thenReturn(project);
    /* execute */
    serviceToTest.changeProjectAccessLevel(PROJECT1_ID, ProjectAccessLevel.READ_ONLY);
    /* test */
    ArgumentCaptor<DomainMessage> eventCaptor = ArgumentCaptor.forClass(DomainMessage.class);
    verify(eventBus).sendAsynchron(eventCaptor.capture());
    DomainMessage sentEvent = eventCaptor.getValue();
    assertEquals(MessageID.PROJECT_ACCESS_LEVEL_CHANGED, sentEvent.getMessageId());
    ProjectMessage eventProjectMessage = sentEvent.get(MessageDataKeys.PROJECT_ACCESS_LEVEL_CHANGE_DATA);
    assertNotNull(eventProjectMessage);
    assertEquals(ProjectAccessLevel.FULL, eventProjectMessage.getFormerAccessLevel());
    assertEquals(ProjectAccessLevel.READ_ONLY, eventProjectMessage.getNewAccessLevel());
}
Also used : ProjectMessage(com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage) DomainMessage(com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage) Test(org.junit.jupiter.api.Test)

Example 8 with DomainMessage

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

the class InternalInitialDataService 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 DomainMessage

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

the class InternalInitialDataService method informUserAPITokenChanged.

@IsSendingAsyncMessage(MessageID.USER_API_TOKEN_CHANGED)
private void informUserAPITokenChanged(User user) {
    DomainMessage infoRequest = new DomainMessage(MessageID.USER_API_TOKEN_CHANGED);
    UserMessage message = createInitialUserAuthData(user);
    message.setHashedApiToken(user.getHashedApiToken());
    infoRequest.set(MessageDataKeys.USER_API_TOKEN_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 10 with DomainMessage

use of com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage 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)

Aggregations

DomainMessage (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage)69 IsSendingAsyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingAsyncMessage)31 UserMessage (com.mercedesbenz.sechub.sharedkernel.messaging.UserMessage)21 Test (org.junit.Test)18 Test (org.junit.jupiter.api.Test)13 ProjectMessage (com.mercedesbenz.sechub.sharedkernel.messaging.ProjectMessage)10 DomainMessageSynchronousResult (com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessageSynchronousResult)8 JobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.JobMessage)6 AdministrationConfigMessage (com.mercedesbenz.sechub.sharedkernel.messaging.AdministrationConfigMessage)5 BatchJobMessage (com.mercedesbenz.sechub.sharedkernel.messaging.BatchJobMessage)4 SecHubConfiguration (com.mercedesbenz.sechub.sharedkernel.configuration.SecHubConfiguration)3 IsSendingSyncMessage (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessage)3 UUID (java.util.UUID)3 ScheduleSecHubJob (com.mercedesbenz.sechub.domain.schedule.job.ScheduleSecHubJob)2 SecHubExecutionException (com.mercedesbenz.sechub.sharedkernel.execution.SecHubExecutionException)2 SecHubRuntimeException (com.mercedesbenz.sechub.commons.model.SecHubRuntimeException)1 AdministrationAutoCleanupConfig (com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig)1 User (com.mercedesbenz.sechub.domain.administration.user.User)1 ScanMockData (com.mercedesbenz.sechub.domain.scan.project.ScanMockData)1 ScanProjectConfig (com.mercedesbenz.sechub.domain.scan.project.ScanProjectConfig)1