Forward merge client: mgmt server listen default to 0.0.0.0 (#2907)

This commit is contained in:
Rafael Weingärtner 2018-10-22 16:28:48 -03:00
commit 71e5a88fc1
5 changed files with 50 additions and 8 deletions

View File

@ -16,7 +16,8 @@
# under the License. # under the License.
# The binding interface for the management server # The binding interface for the management server
bind.interface=:: # The management server will listen on all interfaces by default
# bind.interface=::
# The service context path where URL requests should be served # The service context path where URL requests should be served
context.path=/client context.path=/client

View File

@ -87,7 +87,7 @@ public class ServerDaemon implements Daemon {
private int sessionTimeout = 30; private int sessionTimeout = 30;
private boolean httpsEnable = false; private boolean httpsEnable = false;
private String accessLogFile = "access.log"; private String accessLogFile = "access.log";
private String bindInterface = ""; private String bindInterface = null;
private String contextPath = "/client"; private String contextPath = "/client";
private String keystoreFile; private String keystoreFile;
private String keystorePassword; private String keystorePassword;
@ -119,7 +119,7 @@ public class ServerDaemon implements Daemon {
if (properties == null) { if (properties == null) {
return; return;
} }
setBindInterface(properties.getProperty(BIND_INTERFACE, "")); setBindInterface(properties.getProperty(BIND_INTERFACE, null));
setContextPath(properties.getProperty(CONTEXT_PATH, "/client")); setContextPath(properties.getProperty(CONTEXT_PATH, "/client"));
setHttpEnable(Boolean.valueOf(properties.getProperty(HTTP_ENABLE, "true"))); setHttpEnable(Boolean.valueOf(properties.getProperty(HTTP_ENABLE, "true")));
setHttpPort(Integer.valueOf(properties.getProperty(HTTP_PORT, "8080"))); setHttpPort(Integer.valueOf(properties.getProperty(HTTP_PORT, "8080")));

View File

@ -25,6 +25,7 @@ import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.utils.security.DigestHelper;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -188,7 +189,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
templateResponse.setPhysicalSize(templatePhysicalSize); templateResponse.setPhysicalSize(templatePhysicalSize);
} }
templateResponse.setChecksum(template.getChecksum()); templateResponse.setChecksum(DigestHelper.getHashValueFromChecksumValue(template.getChecksum()));
if (template.getSourceTemplateId() != null) { if (template.getSourceTemplateId() != null) {
templateResponse.setSourceTemplateId(template.getSourceTemplateUuid()); templateResponse.setSourceTemplateId(template.getSourceTemplateUuid());
} }
@ -320,7 +321,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
isoResponse.setFeatured(iso.isFeatured()); isoResponse.setFeatured(iso.isFeatured());
isoResponse.setCrossZones(iso.isCrossZones()); isoResponse.setCrossZones(iso.isCrossZones());
isoResponse.setPublic(iso.isPublicTemplate()); isoResponse.setPublic(iso.isPublicTemplate());
isoResponse.setChecksum(iso.getChecksum()); isoResponse.setChecksum(DigestHelper.getHashValueFromChecksumValue(iso.getChecksum()));
isoResponse.setOsTypeId(iso.getGuestOSUuid()); isoResponse.setOsTypeId(iso.getGuestOSUuid());
isoResponse.setOsTypeName(iso.getGuestOSName()); isoResponse.setOsTypeName(iso.getGuestOSName());

View File

@ -116,4 +116,19 @@ public class DigestHelper {
} }
} }
} }
/**
* True if the algorithm is present on the checksum value. Format: {ALG}HASH
*/
protected static boolean isAlgorithmPresent(String checksum) {
return StringUtils.isNotBlank(checksum) && checksum.contains("{") && checksum.contains("}") &&
checksum.indexOf("{") == 0 && checksum.indexOf("}") > checksum.indexOf("{");
}
/**
* Returns the checksum HASH from the checksum value which can have the following formats: {ALG}HASH or HASH
*/
public static String getHashValueFromChecksumValue(String checksum) {
return isAlgorithmPresent(checksum) ? new ChecksumValue(checksum).getChecksum() : checksum;
}
} }

View File

@ -26,6 +26,9 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class DigestHelperTest { public class DigestHelperTest {
private final static String INPUT_STRING = "01234567890123456789012345678901234567890123456789012345678901234567890123456789\n"; private final static String INPUT_STRING = "01234567890123456789012345678901234567890123456789012345678901234567890123456789\n";
@ -46,17 +49,17 @@ public class DigestHelperTest {
@Test @Test
public void check_SHA256() throws Exception { public void check_SHA256() throws Exception {
Assert.assertTrue(DigestHelper.check(SHA256_CHECKSUM, inputStream)); assertTrue(DigestHelper.check(SHA256_CHECKSUM, inputStream));
} }
@Test @Test
public void check_SHA1() throws Exception { public void check_SHA1() throws Exception {
Assert.assertTrue(DigestHelper.check(SHA1_CHECKSUM, inputStream)); assertTrue(DigestHelper.check(SHA1_CHECKSUM, inputStream));
} }
@Test @Test
public void check_MD5() throws Exception { public void check_MD5() throws Exception {
Assert.assertTrue(DigestHelper.check(MD5_CHECKSUM, inputStream)); assertTrue(DigestHelper.check(MD5_CHECKSUM, inputStream));
} }
@Test @Test
@ -127,6 +130,28 @@ public class DigestHelperTest {
String checksum = SHA256_CHECKSUM + "XXXXX"; String checksum = SHA256_CHECKSUM + "XXXXX";
DigestHelper.validateChecksumString(checksum); DigestHelper.validateChecksumString(checksum);
} }
@Test
public void testIsAlgorithmPresentPositiveCase() {
assertTrue(DigestHelper.isAlgorithmSupported(SHA256_CHECKSUM));
}
@Test
public void testIsAlgorithmPresentnegativeCase() {
assertTrue(DigestHelper.isAlgorithmSupported(SHA256_NO_PREFIX_CHECKSUM));
}
@Test
public void testGetHashValueFromChecksumValuePrefixPresent() {
String checksum = DigestHelper.getHashValueFromChecksumValue(SHA256_CHECKSUM);
assertEquals(SHA256_NO_PREFIX_CHECKSUM, checksum);
}
@Test
public void testGetHashValueFromChecksumValueNoPrefixPresent() {
String checksum = DigestHelper.getHashValueFromChecksumValue(SHA256_NO_PREFIX_CHECKSUM);
assertEquals(SHA256_NO_PREFIX_CHECKSUM, checksum);
}
} }
//Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme //Generated with love by TestMe :) Please report issues and submit feature requests at: http://weirddev.com/forum#!/testme