this.acceptPrivateAddress = acceptPrivateAddress;
}
- public boolean validate(String organisationName, String ipAddress, String expectedServerId) {
- String organization = organisationName.trim();
+ public boolean validate(String organizationName, String ipAddress, String expectedServerId) {
+ String organization = organizationName.trim();
String ip = ipAddress.trim();
if (isBlank(ip) || isBlank(organization) || !isValidOrganizationName(organization)) {
return false;
return toId(organization, inetAddress);
}
- static boolean isValidOrganizationName(String organisation) {
- return ORGANIZATION_PATTERN.matcher(organisation).matches();
+ static boolean isValidOrganizationName(String organization) {
+ return ORGANIZATION_PATTERN.matcher(organization).matches();
}
boolean isFixed(InetAddress address) {
return acceptPrivateAddress || (!address.isLoopbackAddress() && !address.isLinkLocalAddress());
}
- static String toId(String organisation, InetAddress address) {
- String id = new StringBuilder().append(organisation).append("-").append(address.getHostAddress()).toString();
+ static String toId(String organization, InetAddress address) {
+ String id = new StringBuilder().append(organization).append("-").append(address.getHostAddress()).toString();
return VERSION + DigestUtils.sha1Hex(id.getBytes(StandardCharsets.UTF_8)).substring(0, CHECKSUM_SIZE);
}
return Optional.absent();
}
- String organisation = settings.getString(CoreProperties.ORGANISATION);
+ String organization = settings.getString(CoreProperties.ORGANISATION);
String ipAddress = settings.getString(CoreProperties.SERVER_ID_IP_ADDRESS);
- boolean validated = organisation != null
+ boolean validated = organization != null
&& ipAddress != null
- && idGenerator.validate(organisation, ipAddress, rawId.get());
+ && idGenerator.validate(organization, ipAddress, rawId.get());
return Optional.of(new ServerId(rawId.get(), validated));
}
Optional<String> serverId = getSettingValue(properties.get(PERMANENT_SERVER_ID));
if (serverId.isPresent()) {
responseBuilder.setServerId(serverId.get());
- Optional<String> organisation = getSettingValue(properties.get(ORGANISATION));
- if (organisation.isPresent()) {
- responseBuilder.setOrganization(organisation.get());
+ Optional<String> organization = getSettingValue(properties.get(ORGANISATION));
+ if (organization.isPresent()) {
+ responseBuilder.setOrganization(organization.get());
}
Optional<String> ip = getSettingValue(properties.get(SERVER_ID_IP_ADDRESS));
if (ip.isPresent()) {
responseBuilder.setIp(ip.get());
}
- boolean isValidServId = isValidServerId(serverId.get(), organisation, ip);
+ boolean isValidServId = isValidServerId(serverId.get(), organization, ip);
if (!isValidServId) {
responseBuilder.setInvalidServerId(true);
}
PropertyDto serverIdProp = selectProperty(dbSession, propertyKey);
if (serverIdProp != null) {
// a server ID has been generated, let's print out the other useful information that can help debugging license issues
- PropertyDto organisationProp = selectProperty(dbSession, CoreProperties.ORGANISATION);
+ PropertyDto organizationProp = selectProperty(dbSession, CoreProperties.ORGANISATION);
PropertyDto ipAddressProp = selectProperty(dbSession, CoreProperties.SERVER_ID_IP_ADDRESS);
StringBuilder message = new StringBuilder("Server information:\n");
message.append(" - ID : ");
addQuotedValue(serverIdProp, message);
- message.append(" - Organisation : ");
- addQuotedValue(organisationProp, message);
+ message.append(" - Organization : ");
+ addQuotedValue(organizationProp, message);
message.append(" - Registered IP: ");
addQuotedValue(ipAddressProp, message);
private static final String LICENSE_KEY_SAMPLE = "sonar.governance.license.secured";
private static final String LICENSE_NAME_SAMPLE = "Governance";
- private static final String ORGANISATION_SAMPLE = "SonarSource";
+ private static final String ORGANIZATION_SAMPLE = "SonarSource";
private static final String SERVER_ID_SAMPLE = "12345";
private static final String PRODUCT_SAMPLE = "governance";
private static final String TYPE_SAMPLE = "PRODUCTION";
setUserAsSystemAdmin();
addServerIdSettings(SERVER_ID_SAMPLE);
addLicenseSetting(LICENSE_KEY_SAMPLE, LICENSE_NAME_SAMPLE,
- createBase64License(ORGANISATION_SAMPLE, "Other", SERVER_ID_SAMPLE, EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
+ createBase64License(ORGANIZATION_SAMPLE, "Other", SERVER_ID_SAMPLE, EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
ListWsResponse result = executeRequest();
setUserAsSystemAdmin();
addServerIdSettings(SERVER_ID_SAMPLE);
addLicenseSetting(LICENSE_KEY_SAMPLE, LICENSE_NAME_SAMPLE,
- createBase64License(ORGANISATION_SAMPLE, PRODUCT_SAMPLE, "Other", EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
+ createBase64License(ORGANIZATION_SAMPLE, PRODUCT_SAMPLE, "Other", EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
ListWsResponse result = executeRequest();
public void return_bad_server_id_when_server_has_no_server_id() throws Exception {
setUserAsSystemAdmin();
addLicenseSetting(LICENSE_KEY_SAMPLE, LICENSE_NAME_SAMPLE,
- createBase64License(ORGANISATION_SAMPLE, PRODUCT_SAMPLE, SERVER_ID_SAMPLE, EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
+ createBase64License(ORGANIZATION_SAMPLE, PRODUCT_SAMPLE, SERVER_ID_SAMPLE, EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
ListWsResponse result = executeRequest();
public void does_not_return_invalid_server_id_when_all_servers_accepted_and_no_server_id_setting() throws Exception {
setUserAsSystemAdmin();
addLicenseSetting(LICENSE_KEY_SAMPLE, LICENSE_NAME_SAMPLE,
- createBase64License(ORGANISATION_SAMPLE, PRODUCT_SAMPLE, "*", EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
+ createBase64License(ORGANIZATION_SAMPLE, PRODUCT_SAMPLE, "*", EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
ListWsResponse result = executeRequest();
setUserAsSystemAdmin();
addServerIdSettings(SERVER_ID_SAMPLE);
addLicenseSetting(LICENSE_KEY_SAMPLE, LICENSE_NAME_SAMPLE,
- createBase64License(ORGANISATION_SAMPLE, PRODUCT_SAMPLE, "*", EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
+ createBase64License(ORGANIZATION_SAMPLE, PRODUCT_SAMPLE, "*", EXPIRATION_SAMPLE, TYPE_SAMPLE, Collections.emptyMap()));
ListWsResponse result = executeRequest();
setUserAsSystemAdmin();
addServerIdSettings(SERVER_ID_SAMPLE);
addLicenseSetting(LICENSE_KEY_SAMPLE, LICENSE_NAME_SAMPLE,
- createBase64License(ORGANISATION_SAMPLE, PRODUCT_SAMPLE, SERVER_ID_SAMPLE, "2010-01-01", TYPE_SAMPLE, Collections.emptyMap()));
+ createBase64License(ORGANIZATION_SAMPLE, PRODUCT_SAMPLE, SERVER_ID_SAMPLE, "2010-01-01", TYPE_SAMPLE, Collections.emptyMap()));
ListWsResponse result = executeRequest();
return Base64.encodeBase64String((data.getBytes(StandardCharsets.UTF_8)));
}
- private static String createBase64License(@Nullable String organisation, @Nullable String product, @Nullable String serverId, @Nullable String expirationDate,
+ private static String createBase64License(@Nullable String organization, @Nullable String product, @Nullable String serverId, @Nullable String expirationDate,
@Nullable String type, Map<String, String> additionalProperties) {
StringBuilder data = new StringBuilder();
- data.append("Organisation: ").append(organisation).append(" \n");
+ data.append("Organisation: ").append(organization).append(" \n");
data.append("Server: ").append(serverId).append(" \n");
data.append("Product: ").append(product).append(" \n");
data.append("Expiration: ").append(expirationDate).append(" \n");
}
@Test
- public void idShouldBeUniquePerOrganisation() {
+ public void idShouldBeUniquePerOrganization() {
ServerIdGenerator generator = new ServerIdGenerator(true);
String k1 = generator.generate("Corp One", "127.0.0.1");
private static final String AN_ID = "ABC";
private static final String AN_IP = "1.2.3.4";
- public static final String AN_ORGANISATION = "corp";
+ public static final String AN_ORGANIZATION = "corp";
Settings settings = new MapSettings();
ServerIdGenerator idGenerator = mock(ServerIdGenerator.class);
@Test
public void get_returns_absent_if_id_property_is_not_set() {
- settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANISATION);
+ settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANIZATION);
settings.setProperty(CoreProperties.SERVER_ID_IP_ADDRESS, AN_IP);
Optional<ServerId> serverIdOpt = underTest.get();
@Test
public void get_returns_valid_id() {
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, AN_ID);
- settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANISATION);
+ settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANIZATION);
settings.setProperty(CoreProperties.SERVER_ID_IP_ADDRESS, AN_IP);
- when(idGenerator.validate(AN_ORGANISATION, AN_IP, AN_ID)).thenReturn(true);
+ when(idGenerator.validate(AN_ORGANIZATION, AN_IP, AN_ID)).thenReturn(true);
Optional<ServerId> serverIdOpt = underTest.get();
verifyServerId(serverIdOpt.get(), AN_ID, true);
- verify(idGenerator).validate(AN_ORGANISATION, AN_IP, AN_ID);
+ verify(idGenerator).validate(AN_ORGANIZATION, AN_IP, AN_ID);
}
@Test
- public void get_returns_invalid_id_if_id_cant_be_generated_because_missing_organisation() {
+ public void get_returns_invalid_id_if_id_cant_be_generated_because_missing_organization() {
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, AN_ID);
settings.setProperty(CoreProperties.SERVER_ID_IP_ADDRESS, AN_IP);
@Test
public void get_returns_invalid_id_if_id_cant_be_generated_because_missing_ip() {
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, AN_ID);
- settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANISATION);
+ settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANIZATION);
Optional<ServerId> serverIdOpt = underTest.get();
}
@Test
- public void get_returns_invalid_id_if_id_cant_be_generated_because_missing_ip_and_organisation() {
+ public void get_returns_invalid_id_if_id_cant_be_generated_because_missing_ip_and_organization() {
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, AN_ID);
Optional<ServerId> serverIdOpt = underTest.get();
@Test
public void get_returns_invalid_id_if_input_is_different_than_newly_generated_id() {
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, AN_ID);
- settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANISATION);
+ settings.setProperty(CoreProperties.ORGANISATION, AN_ORGANIZATION);
settings.setProperty(CoreProperties.SERVER_ID_IP_ADDRESS, AN_IP);
- when(idGenerator.generate(AN_ORGANISATION, AN_IP)).thenReturn("OTHER");
+ when(idGenerator.generate(AN_ORGANIZATION, AN_IP)).thenReturn("OTHER");
Optional<ServerId> serverIdOpt = underTest.get();
verifyServerId(serverIdOpt.get(), AN_ID, false);
- verify(idGenerator).validate(AN_ORGANISATION, AN_IP, AN_ID);
+ verify(idGenerator).validate(AN_ORGANIZATION, AN_IP, AN_ID);
}
@Test
private void verifyLog(String expectedId, String expectedOrganisation, String expectedIp) {
assertThat(logTester.logs(LoggerLevel.INFO)).contains("Server information:\n"
+ " - ID : " + expectedId + "\n"
- + " - Organisation : " + expectedOrganisation + "\n"
+ + " - Organization : " + expectedOrganisation + "\n"
+ " - Registered IP: " + expectedIp + "\n");
}
property.category.licenses.server_id=Server ID
server_id_configuration.generate_button=Generate ID
server_id_configuration.generating_button=Generating ID...
-server_id_configuration.bad_key=The ID is not valid anymore. Please check the organisation and the IP address.
-server_id_configuration.information=The Server ID is a unique identifier of this SonarQube instance. It is used for example to obtain a license key for the SonarSource's commercial plugins. Two fields have to be provided to generate the ID : organisation name and one of the IP addresses of the machine that hosts this server. There is no need to restart the server after generating a new server ID.
-server_id_configuration.organisation.title=Organisation
-server_id_configuration.organisation.desc=Name of the organisation
+server_id_configuration.bad_key=The ID is not valid anymore. Please check the organization and the IP address.
+server_id_configuration.information=The Server ID is a unique identifier of this SonarQube instance. It is used for example to obtain a license key for the SonarSource's commercial plugins. Two fields have to be provided to generate the ID : organization name and one of the IP addresses of the machine that hosts this server. There is no need to restart the server after generating a new server ID.
+server_id_configuration.organisation.title=Organization
+server_id_configuration.organisation.desc=Name of the organization
server_id_configuration.organisation.pattern=Only letters, digits and whitespaces are allowed.
server_id_configuration.ip.title=Fixed IP Address
server_id_configuration.ip.desc=A server ID is linked to the IP address of the hosting machine that runs SonarQube. If the server IP address was to change, the server ID will have to be regenerated. The valid addresses are :
-server_id_configuration.generation_error=Organisation and/or IP address are not valid.
-server_id_configuration.fields_cannot_be_blank=Organisation and IP address cannot be blank.
-server_id_configuration.does_not_match_organisation_pattern=Organisation does not match the required pattern.
+server_id_configuration.generation_error=Organization and/or IP address are not valid.
+server_id_configuration.fields_cannot_be_blank=Organization and IP address cannot be blank.
+server_id_configuration.does_not_match_organisation_pattern=Organization does not match the required pattern.
licenses.list.product=Product
licenses.list.organization=Organization
licenses.list.expiration=Expiration