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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations