use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class UserEmailAddressUpdateService method updateUserEmailAddress.
/* @formatter:off */
@Validated
@UseCaseAdminUpdatesUserEmailAddress(@Step(number = 2, name = "Service updates user email address.", next = { 3 }, description = "The service will update the user email address and also trigger events."))
/* @formatter:on */
@Transactional
public void updateUserEmailAddress(String userId, String newEmailAddress) {
assertion.assertIsValidUserId(userId);
assertion.assertIsValidEmailAddress(newEmailAddress);
User user = userRepository.findOrFailUser(userId);
String formerEmailAddress = user.getEmailAdress();
if (newEmailAddress.equalsIgnoreCase(formerEmailAddress)) {
throw new NotAcceptableException("User has already this email address");
}
/* parameters valid, we audit log the change */
auditLogService.log("Changed email adress of user {}", logSanitizer.sanitize(userId, 30));
user.emailAdress = newEmailAddress;
/* create message containing data before user email has changed */
UserMessage message = new UserMessage();
message.setUserId(user.getName());
message.setEmailAdress(user.getEmailAdress());
message.setFormerEmailAddress(formerEmailAddress);
message.setSubject("A SecHub administrator has changed your email address");
userRepository.save(user);
informUserEmailAddressUpdated(message);
}
use of com.mercedesbenz.sechub.sharedkernel.error.NotAcceptableException in project sechub by mercedes-benz.
the class FalsePositiveMetaDataFactory method createMetaData.
/**
* Creates meta data for given finding
*
* @param finding
* @return meta data, never <code>null</code>
*/
public FalsePositiveMetaData createMetaData(SecHubFinding finding) {
ScanType type = finding.getType();
if (type == null) {
/* hmm.. maybe an old report where type was not set */
SecHubCodeCallStack callstack = finding.getCode();
if (callstack == null) {
throw new IllegalStateException("Sorry, cannot determine scan type which is necessary for false positive handling. Please start a new scanjob and use this job UUID and retry.");
}
type = ScanType.CODE_SCAN;
LOG.warn("scan type was not given - fallback to {}", type);
}
switch(type) {
case CODE_SCAN:
return createCodeScan(finding);
case WEB_SCAN:
return createWebScan(finding);
default:
throw new NotAcceptableException("A false positive handling for type " + type + " is currently not implemented!");
}
}
Aggregations