Skip to content

Commit

Permalink
Merge pull request mercedes-benz#2781 from zigfridus/feature-1139-ren…
Browse files Browse the repository at this point in the history
…ame-parts-with-emailAdress

Feature 1139 rename parts with email adress
  • Loading branch information
Jeeppler authored Jan 5, 2024
2 parents 72ae4a1 + 1c6e4bb commit b6c4fcb
Show file tree
Hide file tree
Showing 95 changed files with 335 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class InitialAdminInitializer {

@Value("${sechub.initialadmin.email}")
@MustBeDocumented(value = "Mail of initial administrator")
String initialAdminEmailAdress;
String initialAdminEmailAddress;

@Value("${sechub.initialadmin.apitoken:}") // : so default is empty, making this optional.
@MustBeDocumented(value = "An apitoken for initial admin, will only be used in DEV and INTEGRATIONTEST profiles and is optional!")
Expand All @@ -44,7 +44,7 @@ public CommandLineRunner initialIntegrationTestAdmin(InternalInitialDataService
* production data and also run only on a non productive system, so in this case
* the usage is okay, because automated integration tests run much faster.
*/
internalService.createInitialAdmin(initialAdminUserid, initialAdminEmailAdress, "{noop}" + initialAdminApiToken);
internalService.createInitialAdmin(initialAdminUserid, initialAdminEmailAddress, "{noop}" + initialAdminApiToken);
/*
* an additional test user, has no rights initial. Only for integration tests,
* so password here plain and not configurable
Expand All @@ -58,7 +58,7 @@ public CommandLineRunner initialIntegrationTestAdmin(InternalInitialDataService
@Profile({ Profiles.INITIAL_ADMIN_PREDEFINED }) // used in DEV profile
public CommandLineRunner initialSecHubAdmDevelopmentOnly(InternalInitialDataService internalService) {
return args -> {
internalService.createInitialAdmin(initialAdminUserid, initialAdminEmailAdress, initialAdminApiToken);
internalService.createInitialAdmin(initialAdminUserid, initialAdminEmailAddress, initialAdminApiToken);
};
}

Expand All @@ -67,7 +67,7 @@ public CommandLineRunner initialSecHubAdmDevelopmentOnly(InternalInitialDataServ
@Profile({ Profiles.INITIAL_ADMIN_CREATED }) // used inside PROD profile
public CommandLineRunner initialSecHubAdm(InternalInitialDataService internalService) {
return args -> {
internalService.createInitialAdmin(initialAdminUserid, initialAdminEmailAdress, UUID.randomUUID().toString()); // uses SecureRandom
internalService.createInitialAdmin(initialAdminUserid, initialAdminEmailAddress, UUID.randomUUID().toString()); // uses SecureRandom
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private JobMessage buildMessage(UUID jobUUID) {
return message;
}
message.setOwner(jobInfo.owner);
message.setOwnerEmailAddress(optUser.get().getEmailAdress());
message.setOwnerEmailAddress(optUser.get().getEmailAddress());
return message;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class JobInformation {
/* +-----------------------------------------------------------------------+ */
public static final String TABLE_NAME = "ADM_JOB_INFORMATION";
/**
* Email adress is also the primary key. So no duplicates
* Email address is also the primary key. So no duplicates
*/
public static final String COLUMN_UUID = "UUID";
public static final String COLUMN_JOB_UUID = "JOB_UUID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private JobMessage buildMessage(UUID jobUUID) {
return message;
}
message.setOwner(jobInfo.owner);
message.setOwnerEmailAddress(optUser.get().getEmailAdress());
message.setOwnerEmailAddress(optUser.get().getEmailAddress());
return message;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ private void sendOwnerChangedForProjectEvent(Project project, User previousOwner
DomainMessage request = new DomainMessage(MessageID.PROJECT_OWNER_CHANGED);
ProjectMessage projectData = new ProjectMessage();
projectData.setProjectId(project.id);
projectData.setPreviousProjectOwnerEmailAddress(previousOwner.getEmailAdress());
projectData.setProjectOwnerEmailAddress(newOwner.getEmailAdress());
projectData.setPreviousProjectOwnerEmailAddress(previousOwner.getEmailAddress());
projectData.setProjectOwnerEmailAddress(newOwner.getEmailAddress());

project.users.forEach(user -> {
projectData.addUserEmailAddress(user.getEmailAdress());
projectData.addUserEmailAddress(user.getEmailAddress());
});

request.set(MessageDataKeys.PROJECT_OWNER_CHANGE_DATA, projectData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public void deleteProject(String projectId) {
if (owner == null) {
LOG.warn("No owner found for project {} while deleting", project.getId());
} else {
message.setProjectOwnerEmailAddress(owner.getEmailAdress());
message.setProjectOwnerEmailAddress(owner.getEmailAddress());
owner.getOwnedProjects().remove(project); // handle ORM mapping. Avoid cache conflicts
}

for (User user : project.getUsers()) {
message.addUserEmailAddress(user.getEmailAdress());
message.addUserEmailAddress(user.getEmailAddress());
user.getProjects().remove(project); // handle ORM mapping. Avoid cache conflicts
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ public class AnonymousSignupCreateService {
@UseCaseUserSignup(@Step(number = 2, name = "Persistence", description = "Valid self registration input will be persisted to database."))
public void register(@Valid SignupJsonInput userSelfRegistrationInput) {
String userId = userSelfRegistrationInput.getUserId();
String emailAdress = userSelfRegistrationInput.getEmailAdress();
String emailAddress = userSelfRegistrationInput.getEmailAddress();

LOG.debug("user tries to register himself:{},mail:{}", userId, emailAdress);
LOG.debug("user tries to register himself:{},mail:{}", userId, emailAddress);

assertion.assertIsValidUserId(userId);
assertion.assertIsValidEmailAddress(emailAdress);
assertion.assertIsValidEmailAddress(emailAddress);

assertNotAlreadySignedIn(userId, emailAdress);
assertUsernameNotUsedAlready(userId, emailAdress);
assertEmailAdressNotUsedAlready(userId, emailAdress);
assertNotAlreadySignedIn(userId, emailAddress);
assertUsernameNotUsedAlready(userId, emailAddress);
assertEmailAddressNotUsedAlready(userId, emailAddress);

Signup entity = new Signup();

entity.setEmailAdress(emailAdress);
entity.setEmailAddress(emailAddress);
entity.setUserId(userId);
userSelfRegistrationRepository.save(entity);
LOG.debug("Added registration entry for user:{},mail:{}", entity.getUserId(), entity.getEmailAdress());
LOG.debug("Added registration entry for user:{},mail:{}", entity.getUserId(), entity.getEmailAddress());

/* trigger event */
informAboutSignupRequest(entity);
Expand All @@ -81,37 +81,37 @@ private void informAboutSignupRequest(Signup signup) {
DomainMessage infoRequest = new DomainMessage(MessageID.USER_SIGNUP_REQUESTED);

UserMessage userMessage = new UserMessage();
userMessage.setEmailAdress(signup.getEmailAdress());
userMessage.setEmailAddress(signup.getEmailAddress());
userMessage.setUserId(signup.getUserId());

infoRequest.set(MessageDataKeys.USER_SIGNUP_DATA, userMessage);

eventBusService.sendAsynchron(infoRequest);
}

private void assertEmailAdressNotUsedAlready(String userId, String emailAdress) {
Optional<User> foundUserByMail = userRepository.findByEmailAdress(emailAdress);
private void assertEmailAddressNotUsedAlready(String userId, String emailAddress) {
Optional<User> foundUserByMail = userRepository.findByEmailAddress(emailAddress);

if (foundUserByMail.isPresent()) {
LOG.warn("Self registration coming in for emailadress:{} and user:{} but an existing user does already have this email adress. So not accepted",
emailAdress, userId);
LOG.warn("Self registration coming in for email address:{} and user:{} but an existing user does already have this email address. So not accepted",
emailAddress, userId);
handleRegistrationNotPossible();
}
}

private void assertUsernameNotUsedAlready(String userId, String emailAdress) {
private void assertUsernameNotUsedAlready(String userId, String emailAddress) {
Optional<User> foundUser = userRepository.findById(userId);

if (foundUser.isPresent()) {
LOG.warn("Self registration coming in for emailadress:{} and user:{} but existing user found by name. So not accepted", emailAdress, userId);
LOG.warn("Self registration coming in for email address:{} and user:{} but existing user found by name. So not accepted", emailAddress, userId);
handleRegistrationNotPossible();
}
}

private void assertNotAlreadySignedIn(String userId, String emailAdress) {
private void assertNotAlreadySignedIn(String userId, String emailAddress) {
Optional<Signup> found = userSelfRegistrationRepository.findById(userId);
if (found.isPresent()) {
LOG.warn("Self registration coming in for emailadress:{} and user:{} but signup already exists. So not accepted", emailAdress, userId);
LOG.warn("Self registration coming in for email address:{} and user:{} but signup already exists. So not accepted", emailAddress, userId);
handleRegistrationNotPossible();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public class Signup {
public static final String TABLE_NAME = "ADM_USER_SELFREGISTRATION";

/**
* Email adress is also the primary key. So no duplicates
* Email address is also the primary key. So no duplicates
*/
public static final String COLUMN_EMAIL_ADRESS = "EMAIL_ADRESS";
public static final String COLUMN_EMAIL_ADDRESS = "EMAIL_ADDRESS";
public static final String COLUMN_USER_ID = "USER_ID";

/* +-----------------------------------------------------------------------+ */
Expand All @@ -33,23 +33,23 @@ public class Signup {
@Column(name = COLUMN_USER_ID)
String userId;

@Column(name = COLUMN_EMAIL_ADRESS, nullable = false)
String emailAdress;
@Column(name = COLUMN_EMAIL_ADDRESS, nullable = false)
String emailAddress;

@Version
@Column(name = "VERSION")
Integer version;

public void setEmailAdress(String emailAdress) {
this.emailAdress = emailAdress;
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}

public void setUserId(String userId) {
this.userId = userId;
}

public String getEmailAdress() {
return emailAdress;
public String getEmailAddress() {
return emailAddress;
}

public String getUserId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class SignupJsonInput implements JSONable<SignupJsonInput> {

public static final String PROPERTY_API_VERSION = "apiVersion";
public static final String PROPERTY_USER_ID = "userId";
public static final String PROPERTY_EMAIL_ADRESS = "emailAdress";
public static final String PROPERTY_EMAIL_ADDRESS = "emailAddress";

private String apiVersion;
private String userId;
private String emailAdress;
private String emailAddress;

@Override
public Class<SignupJsonInput> getJSONTargetClass() {
Expand All @@ -38,12 +38,12 @@ public void setUserId(String userId) {
this.userId = userId;
}

public String getEmailAdress() {
return emailAdress;
public String getEmailAddress() {
return emailAddress;
}

public void setEmailAdress(String emailAdress) {
this.emailAdress = emailAdress;
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public void validate(Object target, Errors errors) {
return;
}

ValidationResult emailValidationResult = emailValidation.validate(selfRegistration.getEmailAdress());
ValidationResult emailValidationResult = emailValidation.validate(selfRegistration.getEmailAddress());
if (!emailValidationResult.isValid()) {
errors.rejectValue(PROPERTY_EMAIL_ADRESS, "api.error.email.invalid", "Invalid email adress");
errors.rejectValue(PROPERTY_EMAIL_ADDRESS, "api.error.email.invalid", "Invalid email address");
return;
}
LOG.debug("Selfregistration of {} was accepted", selfRegistration.getUserId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public String createNewAPITokenForUserByOneTimeToken(String oneTimeToken) {
private void sendUserAPITokenChanged(User user) {
DomainMessage request = new DomainMessage(MessageID.USER_API_TOKEN_CHANGED);
UserMessage message = new UserMessage();
message.setEmailAdress(user.getEmailAdress());
message.setEmailAddress(user.getEmailAddress());
message.setUserId(user.getName());
message.setHashedApiToken(user.getHashedApiToken());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class AnonymousUserRequestNewApiTokenRestController {
@CrossOrigin /* to allow call from getsechub.detss and maybe other sites using javascript */
@UseCaseUserRequestsNewApiToken(@Step(number=1, name="Rest API call",description="Rest api called to request new user api token. Normally done by user itself",needsRestDoc=true))
@RequestMapping(path = AdministrationAPIConstants.API_REQUEST_NEW_APITOKEN, method = RequestMethod.POST)
public void anonymousRequestToGetNewApiTokenForUserMailAdress(@PathVariable(name="emailAddress") String emailAdress) {
public void anonymousRequestToGetNewApiTokenForUserEmailAddress(@PathVariable(name="emailAddress") String emailAddress) {
/* @formatter:on */
newApiTokenService.anonymousRequestToGetNewApiTokenForUserMailAdress(emailAdress);
newApiTokenService.anonymousRequestToGetNewApiTokenForUserEmailAddress(emailAddress);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class AnonymousUserRequestsNewApiTokenService {
@Autowired
UserInputAssertion assertion;

public void anonymousRequestToGetNewApiTokenForUserMailAdress(String userEmail) {
public void anonymousRequestToGetNewApiTokenForUserEmailAddress(String userEmail) {
LOG.info("New api token requested for email address: {})", logSanitizer.sanitize(userEmail, 50));

assertion.assertIsValidEmailAddress(userEmail);

Optional<User> found = userRepository.findByEmailAdress(userEmail);
Optional<User> found = userRepository.findByEmailAddress(userEmail);
if (!found.isPresent()) {
/* we just do nothing here - prevent user enumeration by hacking... */
LOG.warn("Anonymous request to get new api token, but user unknown: {})", logSanitizer.sanitize(userEmail, 50));
Expand All @@ -66,7 +66,7 @@ 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);
userMessage.setEmailAddress(userEmail);

/*
* Security: we do NOT use userid inside this link - if some body got
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ public class InternalInitialDataService {
* gained administrator rights
*
* @param userId
* @param emailAdress
* @param fixApiToken - use "{nooop}" as prefix to prevent token encryption
* @param emailAddress
* @param fixApiToken - use "{nooop}" as prefix to prevent token encryption
*/
public void createInitialAdmin(String userId, String emailAdress, String fixApiToken) {
internalCreateInitialUser(userId, emailAdress, fixApiToken, true);
public void createInitialAdmin(String userId, String emailAddress, String fixApiToken) {
internalCreateInitialUser(userId, emailAddress, fixApiToken, true);
}

/**
* Creates an initial test user
*
* @param userId
* @param emailAdress
* @param emailAddress
* @param unencryptedAPItoken - use "{nooop}" as prefix to prevent token
* encryption
*/
public void createInitialTestUser(String userId, String emailAdress, String unencryptedAPItoken) {
internalCreateInitialUser(userId, emailAdress, unencryptedAPItoken, false);
public void createInitialTestUser(String userId, String emailAddress, String unencryptedAPItoken) {
internalCreateInitialUser(userId, emailAddress, unencryptedAPItoken, false);
}

private void internalCreateInitialUser(String userId, String emailAddress, String unencryptedAPItoken, boolean createAsSuperAdmin) {
Expand Down Expand Up @@ -121,7 +121,7 @@ private User createUser(String userId, String emailAddress, String fixApiToken,
} else {
user.hashedApiToken = encryptPassword(fixApiToken);
}
user.emailAdress = emailAddress;
user.emailAddress = emailAddress;
user.superAdmin = superAdmin;

userRepository.save(user);
Expand Down Expand Up @@ -174,7 +174,7 @@ private UserMessage createInitialUserAuthData(User user) {
UserMessage authDataHashed = new UserMessage();

authDataHashed.setUserId(user.getName());
authDataHashed.setEmailAdress(user.getEmailAdress());
authDataHashed.setEmailAddress(user.getEmailAddress());

return authDataHashed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class User {
public static final String COLUMN_USER_ONE_TIME_TOKEN_CREATED = "USER_OTT_CREATED";
public static final String COLUMN_USER_ENABLED = "USER_ENABLED";

public static final String COLUMN_EMAIL_ADRESS = "USER_EMAIL_ADRESS";
public static final String COLUMN_EMAIL_ADDRESS = "USER_EMAIL_ADDRESS";
public static final String COLUMN_USER_ROLES = "USER_ROLES";
public static final String COLUMN_USER_SUPERADMIN = "USER_SUPERADMIN";
public static final String COLUMN_USER_DEACTIVATED = "USER_DEACTIVATED";
Expand All @@ -54,8 +54,8 @@ public class User {
@Column(name = COLUMN_USER_ID, unique = true, nullable = false)
String name;

@Column(name = COLUMN_EMAIL_ADRESS, unique = true, nullable = false)
String emailAdress;
@Column(name = COLUMN_EMAIL_ADDRESS, unique = true, nullable = false)
String emailAddress;

@Column(name = COLUMN_USER_HASHED_API_TOKEN, nullable = false)
String hashedApiToken;
Expand Down Expand Up @@ -100,8 +100,8 @@ public boolean isDeactivated() {
return deactivated;
}

public String getEmailAdress() {
return emailAdress;
public String getEmailAddress() {
return emailAddress;
}

public String getName() {
Expand Down
Loading

0 comments on commit b6c4fcb

Please sign in to comment.