Changed return type of SystemManagement.getConfigurationValue()

* changed Return type to wrapper object, adding additional meta data stored in the database
* updated all calls of this method
* updated function calls in tests
* verified correct execution of correspending tests

Signed-off-by: Nonnenmacher Fabian <fabian.nonnenmacher@bosch-si.com>
This commit is contained in:
Fabian Nonnenmacher
2016-01-26 14:31:56 +01:00
committed by Nonnenmacher Fabian
parent f2e7cdb92a
commit 07fce42469
14 changed files with 277 additions and 268 deletions

View File

@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.dmf.json.model.TenantSecruityToken;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
import org.eclipse.hawkbit.security.SecurityProperties;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
@@ -58,6 +59,12 @@ public class AmqpControllerAuthentficationTest {
private SystemManagement systemManagement;
private AmqpControllerAuthentfication authenticationManager;
private static final TenantConfigurationValue<Boolean> CONFIG_VALUE_FALSE = TenantConfigurationValue
.<Boolean> builder().value(Boolean.FALSE).build();
private static final TenantConfigurationValue<Boolean> CONFIG_VALUE_TRUE = TenantConfigurationValue
.<Boolean> builder().value(Boolean.TRUE).build();
@Before
public void before() throws Exception {
amqpMessageHandlerService = new AmqpMessageHandlerService();
@@ -73,7 +80,8 @@ public class AmqpControllerAuthentficationTest {
authenticationManager.setSecruityProperties(secruityProperties);
systemManagement = mock(SystemManagement.class);
authenticationManager.setSystemManagement(systemManagement);
when(systemManagement.getConfigurationValue(any(), any())).thenReturn(Boolean.FALSE);
when(systemManagement.getConfigurationValue(any(), eq(Boolean.class))).thenReturn(CONFIG_VALUE_FALSE);
final ControllerManagement controllerManagement = mock(ControllerManagement.class);
when(controllerManagement.getSecurityTokenByControllerId(anyString())).thenReturn(CONTROLLLER_ID);
@@ -104,8 +112,8 @@ public class AmqpControllerAuthentficationTest {
public void testAuthenticationBadCredantialsWithWrongCredential() {
final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345");
when(systemManagement.getConfigurationValue(
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), any()))
.thenReturn(Boolean.TRUE);
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
.thenReturn(CONFIG_VALUE_TRUE);
securityToken.getHeaders().put(TenantSecruityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLLER_ID);
try {
authenticationManager.doAuthenticate(securityToken);
@@ -121,8 +129,8 @@ public class AmqpControllerAuthentficationTest {
public void testSuccessfullAuthentication() {
final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345");
when(systemManagement.getConfigurationValue(
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), any()))
.thenReturn(Boolean.TRUE);
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
.thenReturn(CONFIG_VALUE_TRUE);
securityToken.getHeaders().put(TenantSecruityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLLER_ID);
final Authentication authentication = authenticationManager.doAuthenticate(securityToken);
assertThat(authentication).isNotNull();
@@ -153,8 +161,8 @@ public class AmqpControllerAuthentficationTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345");
when(systemManagement.getConfigurationValue(
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), any()))
.thenReturn(Boolean.TRUE);
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
.thenReturn(CONFIG_VALUE_TRUE);
securityToken.getHeaders().put(TenantSecruityToken.AUTHORIZATION_HEADER, "TargetToken 12" + CONTROLLLER_ID);
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken,
messageProperties);
@@ -175,8 +183,8 @@ public class AmqpControllerAuthentficationTest {
final MessageProperties messageProperties = createMessageProperties(MessageType.AUTHENTIFICATION);
final TenantSecruityToken securityToken = new TenantSecruityToken(TENANT, CONTROLLLER_ID, "12345");
when(systemManagement.getConfigurationValue(
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), any()))
.thenReturn(Boolean.TRUE);
eq(TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED), eq(Boolean.class)))
.thenReturn(CONFIG_VALUE_TRUE);
securityToken.getHeaders().put(TenantSecruityToken.AUTHORIZATION_HEADER, "TargetToken " + CONTROLLLER_ID);
final Message message = amqpMessageHandlerService.getMessageConverter().toMessage(securityToken,
messageProperties);

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.time.format.DateTimeParseException;
import java.util.List;
import java.util.stream.Collectors;
@@ -21,15 +20,11 @@ import org.eclipse.hawkbit.cache.TenancyCacheManager;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.report.model.SystemUsageReport;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.InvalidDistributionSetTypeException;
import org.eclipse.hawkbit.repository.exception.InvalidPollingTimeException;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.repository.model.TenantMetaData;
import org.eclipse.hawkbit.repository.model.helper.DurationHelper;
import org.eclipse.hawkbit.repository.specifications.DistributionSetTypeSpecification;
import org.eclipse.hawkbit.rest.resource.model.system.SystemConfigurationRequestBodyPut;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.persistence.config.PersistenceUnitProperties;
@@ -330,6 +325,8 @@ public class SystemManagement implements EnvironmentAware {
* Retrieves a configuration value from the e.g. tenant overwritten
* configuration values or in case the tenant does not a have a specific
* configuration the global default value hold in the {@link Environment}.
*
* @param <T>
*
* @param configurationKey
* the key of the configuration
@@ -345,15 +342,26 @@ public class SystemManagement implements EnvironmentAware {
* {@code propertyType}
*/
@Cacheable(value = "tenantConfiguration", key = "#configurationKey.getKeyName()")
public <T> T getConfigurationValue(final TenantConfigurationKey configurationKey, final Class<T> propertyType) {
public <T> TenantConfigurationValue<T> getConfigurationValue(final TenantConfigurationKey configurationKey,
final Class<T> propertyType) {
final TenantConfiguration tenantConfiguration = tenantConfigurationRepository
.findByKey(configurationKey.getKeyName());
if (tenantConfiguration != null) {
return conversionService.convert(tenantConfiguration.getValue(), propertyType);
return TenantConfigurationValue.<T> builder().isGlobal(false).createdBy(tenantConfiguration.getCreatedBy())
.createdAt(tenantConfiguration.getCreatedAt())
.lastModifiedAt(tenantConfiguration.getLastModifiedAt())
.lastModifiedBy(tenantConfiguration.getLastModifiedBy())
.value(conversionService.convert(tenantConfiguration.getValue(), propertyType)).build();
} else if (configurationKey.getDefaultKeyName() != null) {
final T defaultKeyNameValue = environment.getProperty(configurationKey.getDefaultKeyName(), propertyType);
return defaultKeyNameValue != null ? defaultKeyNameValue
: conversionService.convert(configurationKey.getDefaultValue(), propertyType);
final T valueInProperties = environment.getProperty(configurationKey.getDefaultKeyName(), propertyType);
return TenantConfigurationValue.<T> builder().isGlobal(true).createdBy(null).createdAt(null)
.lastModifiedAt(null).lastModifiedBy(null).value(valueInProperties != null ? valueInProperties
: conversionService.convert(configurationKey.getDefaultValue(), propertyType))
.build();
}
return null;
}
@@ -467,29 +475,33 @@ public class SystemManagement implements EnvironmentAware {
}
@Transactional
@Modifying
public void updateTenantConfiguration(SystemConfigurationRequestBodyPut systemConReq) {
DurationHelper dh = new DurationHelper();
TenantMetaData tenantMetaData = getTenantMetadata();
String ddstypeKey = systemConReq.getDefaultDistributionSetType();
if (distributionSetTypeRepository.findAll(DistributionSetTypeSpecification.byKey(ddstypeKey)).isEmpty()) {
throw new InvalidDistributionSetTypeException(
String.format("The specified default distribution set type %s doe not exist.", ddstypeKey));
}
try {
tenantMetaData.setPollingOverdueTime(dh.formattedStringToDuration(systemConReq.getPollingOverdueTime()));
tenantMetaData.setPollingTime(dh.formattedStringToDuration(systemConReq.getPollingTime()));
} catch (DateTimeParseException ex) {
throw new InvalidPollingTimeException(ex);
}
updateTenantMetadata(tenantMetaData);
}
// @Transactional
// @Modifying
// public void updateTenantConfiguration(SystemConfigurationRequestBodyPut
// systemConReq) {
//
// DurationHelper dh = new DurationHelper();
//
// TenantMetaData tenantMetaData = getTenantMetadata();
//
// String ddstypeKey = systemConReq.getDefaultDistributionSetType();
//
// if
// (distributionSetTypeRepository.findAll(DistributionSetTypeSpecification.byKey(ddstypeKey)).isEmpty())
// {
// throw new InvalidDistributionSetTypeException(
// String.format("The specified default distribution set type %s doe not
// exist.", ddstypeKey));
// }
//
// try {
// tenantMetaData.setPollingOverdueTime(dh.formattedStringToDuration(systemConReq.getPollingOverdueTime()));
// tenantMetaData.setPollingTime(dh.formattedStringToDuration(systemConReq.getPollingTime()));
// } catch (DateTimeParseException ex) {
// throw new InvalidPollingTimeException(ex);
// }
//
// updateTenantMetadata(tenantMetaData);
// }
}

View File

@@ -0,0 +1,179 @@
package org.eclipse.hawkbit.repository.model;
/**
* represents a tenant configuration value including some meta data
*
* @param <T>
* type of the configuration value
*/
public class TenantConfigurationValue<T> {
private TenantConfigurationValue() {
}
private T value = null;
private boolean isGlobal = true;
private Long lastModifiedAt = null;
private String lastModifiedBy = null;
private Long createdAt = null;
private String createdBy = null;
/**
* Gets the value.
*
* @return the value
*/
public T getValue() {
return value;
}
/**
* Checks if is global.
*
* @return true, if is global
*/
public boolean isGlobal() {
return isGlobal;
}
/**
* Gets the last modified at.
*
* @return the last modified at
*/
public long getLastModifiedAt() {
return lastModifiedAt;
}
/**
* Gets the last modified by.
*
* @return the last modified by
*/
public String getLastModifiedBy() {
return lastModifiedBy;
}
/**
* Gets the created at.
*
* @return the created at
*/
public long getCreatedAt() {
return createdAt;
}
/**
* Gets the created by.
*
* @return the created by
*/
public String getCreatedBy() {
return createdBy;
}
/**
* Builder.
*
* @param <K>
* the key type
* @return the tenant configuration value builder
*/
public static <K> TenantConfigurationValueBuilder<K> builder() {
return new TenantConfigurationValueBuilder<K>();
}
/**
* builds the tenant configuration value including some meta data
*
* @param <T>
* type of the configuration value
*/
public static class TenantConfigurationValueBuilder<T> {
private final TenantConfigurationValue<T> configuration = new TenantConfigurationValue<>();
/**
* Builds the.
*
* @return the tenant configuration value
*/
public TenantConfigurationValue<T> build() {
return configuration;
}
/**
* sets the configuration value itself
*
* @param value
* the value
* @return the tenant configuration value builder
*/
public TenantConfigurationValueBuilder<T> value(final T value) {
this.configuration.value = value;
return this;
}
/**
* set the is global attribute.
*
* @param isGlobal
* true when there is no tenant specific value, false
* otherwise
* @return the tenant configuration value builder
*/
public TenantConfigurationValueBuilder<T> isGlobal(final boolean isGlobal) {
this.configuration.isGlobal = isGlobal;
return this;
}
/**
* Sets the last modified at attribute
*
* @param lastModifiedAt
* timestamp of last modification
* @return the tenant configuration value builder
*/
public TenantConfigurationValueBuilder<T> lastModifiedAt(final Long lastModifiedAt) {
this.configuration.lastModifiedAt = lastModifiedAt;
return this;
}
/**
* sets the last modified by attribute
*
* @param lastModifiedBy
* the last modified by
* @return the tenant configuration value builder
*/
public TenantConfigurationValueBuilder<T> lastModifiedBy(final String lastModifiedBy) {
this.configuration.lastModifiedBy = lastModifiedBy;
return this;
}
/**
* sets the created at attribute
*
* @param createdAt
* defined when the configuration has been created
* @return the tenant configuration value builder
*/
public TenantConfigurationValueBuilder<T> createdAt(final Long createdAt) {
this.configuration.createdAt = createdAt;
return this;
}
/**
* sets the created by attribute
*
* @param createdBy
* defines by whom the configuration has been created
* @return the tenant configuration value builder
*/
public TenantConfigurationValueBuilder<T> createdBy(final String createdBy) {
this.configuration.createdBy = createdBy;
return this;
}
}
}

View File

@@ -159,7 +159,7 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
assertThat(envPropertyDefault).isNotNull();
// get the configuration from the system management
final String defaultConfigValue = systemManagement.getConfigurationValue(configKey, String.class);
final String defaultConfigValue = systemManagement.getConfigurationValue(configKey, String.class).getValue();
assertThat(envPropertyDefault).isEqualTo(defaultConfigValue);
// update the tenant specific configuration
@@ -169,7 +169,8 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
.addOrUpdateConfiguration(new TenantConfiguration(configKey.getKeyName(), newConfigurationValue));
// verify that new configuration value is used
final String updatedConfigurationValue = systemManagement.getConfigurationValue(configKey, String.class);
final String updatedConfigurationValue = systemManagement.getConfigurationValue(configKey, String.class)
.getValue();
assertThat(updatedConfigurationValue).isEqualTo(newConfigurationValue);
assertThat(systemManagement.getTenantConfigurations()).hasSize(1);
}
@@ -183,11 +184,11 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
// add value first
systemManagement.addOrUpdateConfiguration(new TenantConfiguration(configKey.getKeyName(), value1));
assertThat(systemManagement.getConfigurationValue(configKey, String.class)).isEqualTo(value1);
assertThat(systemManagement.getConfigurationValue(configKey, String.class).getValue()).isEqualTo(value1);
// update to value second
systemManagement.addOrUpdateConfiguration(new TenantConfiguration(configKey.getKeyName(), value2));
assertThat(systemManagement.getConfigurationValue(configKey, String.class)).isEqualTo(value2);
assertThat(systemManagement.getConfigurationValue(configKey, String.class).getValue()).isEqualTo(value2);
}
@Test
@@ -197,7 +198,7 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
final Integer value1 = 123;
systemManagement
.addOrUpdateConfiguration(new TenantConfiguration(configKey.getKeyName(), String.valueOf(value1)));
assertThat(systemManagement.getConfigurationValue(configKey, Integer.class)).isEqualTo(value1);
assertThat(systemManagement.getConfigurationValue(configKey, Integer.class).getValue()).isEqualTo(value1);
}
@Test(expected = ConversionFailedException.class)
@@ -219,7 +220,7 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
// gateway token does not have default value so no configuration value
// is should be available
final String defaultConfigValue = systemManagement.getConfigurationValue(configKey, String.class);
final String defaultConfigValue = systemManagement.getConfigurationValue(configKey, String.class).getValue();
assertThat(defaultConfigValue).isNull();
// update the tenant specific configuration
@@ -229,13 +230,14 @@ public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB {
.addOrUpdateConfiguration(new TenantConfiguration(configKey.getKeyName(), newConfigurationValue));
// verify that new configuration value is used
final String updatedConfigurationValue = systemManagement.getConfigurationValue(configKey, String.class);
final String updatedConfigurationValue = systemManagement.getConfigurationValue(configKey, String.class)
.getValue();
assertThat(updatedConfigurationValue).isEqualTo(newConfigurationValue);
// delete the tenant specific configuration
systemManagement.deleteConfiguration(configKey);
// ensure that now gateway token is set again, because is deleted and
// must be null now
assertThat(systemManagement.getConfigurationValue(configKey, String.class)).isNull();
assertThat(systemManagement.getConfigurationValue(configKey, String.class).getValue()).isNull();
}
}

View File

@@ -17,161 +17,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class SystemConfigurationRest {
@JsonProperty
private String pollingTime;
@JsonProperty
private String pollingOverdueTime;
@JsonProperty
private String defaultDistributionSetType;
@JsonProperty
private String createdBy;
@JsonProperty
private String lastModifiedBy;
@JsonProperty
private Long createdAt;
@JsonProperty
private Long lastModifiedAt;
@JsonProperty
private Map<String, Object> authenticationConfiguration;
/**
* Gets the polling time.
*
* @return the polling time
*/
public String getPollingTime() {
return pollingTime;
}
/**
* Sets the polling time.
*
* @param pollingTime
* the new polling time
*/
public void setPollingTime(String pollingTime) {
this.pollingTime = pollingTime;
}
/**
* Gets the polling overdue time.
*
* @return the polling overdue time
*/
public String getPollingOverdueTime() {
return pollingOverdueTime;
}
/**
* Sets the polling overdue time.
*
* @param pollingOverdueTime
* the new polling overdue time
*/
public void setPollingOverdueTime(String pollingOverdueTime) {
this.pollingOverdueTime = pollingOverdueTime;
}
/**
* Gets the default distribution set type.
*
* @return the default distribution set type
*/
public String getDefaultDistributionSetType() {
return defaultDistributionSetType;
}
/**
* Sets the default distribution set type.
*
* @param defaultDistributionSetType
* the new default distribution set type
*/
public void setDefaultDistributionSetType(String defaultDistributionSetType) {
this.defaultDistributionSetType = defaultDistributionSetType;
}
/**
* Gets the created by.
*
* @return the created by
*/
public String getCreatedBy() {
return createdBy;
}
/**
* Sets the created by.
*
* @param createdBy
* the new created by
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
/**
* Gets the last modified by.
*
* @return the last modified by
*/
public String getLastModifiedBy() {
return lastModifiedBy;
}
/**
* Sets the last modified by.
*
* @param lastModifiedBy
* the new last modified by
*/
public void setLastModifiedBy(String lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
/**
* Gets the created at.
*
* @return the created at
*/
public Long getCreatedAt() {
return createdAt;
}
/**
* Sets the created at.
*
* @param createdAt
* the new created at
*/
public void setCreatedAt(Long createdAt) {
this.createdAt = createdAt;
}
/**
* Gets the last modified at.
*
* @return the last modified at
*/
public Long getLastModifiedAt() {
return lastModifiedAt;
}
/**
* Sets the last modified at.
*
* @param lastModifiedAt
* the new last modified at
*/
public void setLastModifiedAt(Long lastModifiedAt) {
this.lastModifiedAt = lastModifiedAt;
}
private Map<String, Object> configuration;
/**
* Sets the authentication configuration.
@@ -180,7 +26,7 @@ public class SystemConfigurationRest {
* the authentication configuration
*/
public void setAuthenticationConfiguration(Map<String, Object> authenticationConfiguration) {
this.authenticationConfiguration = authenticationConfiguration;
this.configuration = authenticationConfiguration;
}
/**
@@ -189,6 +35,6 @@ public class SystemConfigurationRest {
* @return the authentication configuration
*/
public Map<String, Object> getAuthenticationConfiguration() {
return this.authenticationConfiguration;
return this.configuration;
}
}

View File

@@ -3,7 +3,6 @@ package org.eclipse.hawkbit.rest.resource;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SystemManagement;
import org.eclipse.hawkbit.repository.model.TenantMetaData;
import org.eclipse.hawkbit.repository.model.helper.DurationHelper;
@@ -23,65 +22,25 @@ final public class SystemMapper {
private static DurationHelper dh = new DurationHelper();
public static SystemConfigurationRest toResponse(SystemManagement systemManagement) {
public static SystemConfigurationRest toResponse(final SystemManagement systemManagement) {
TenantMetaData tenantMetaData = systemManagement.getTenantMetadata();
final SystemConfigurationRest sysconf = new SystemConfigurationRest();
SystemConfigurationRest sysconf = new SystemConfigurationRest();
final Map<String, Object> authconf = new HashMap<String, Object>();
sysconf.setDefaultDistributionSetType(tenantMetaData.getDefaultDsType().getKey());
sysconf.setCreatedAt(tenantMetaData.getCreatedAt());
sysconf.setCreatedBy(tenantMetaData.getCreatedBy());
sysconf.setLastModifiedAt(tenantMetaData.getLastModifiedAt());
sysconf.setLastModifiedBy(tenantMetaData.getLastModifiedBy());
sysconf.setPollingOverdueTime(dh.durationToFormattedString(tenantMetaData.getPollingOverdueTime()));
sysconf.setPollingTime(dh.durationToFormattedString(tenantMetaData.getPollingTime()));
Map<String, Object> authconf = new HashMap<String, Object>();
for (TenantConfigurationKey key : TenantConfigurationKey.values()) {
Object value;
switch (key) {
case AUTHENTICATION_MODE_HEADER_ENABLED:
case AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED:
case AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED:
value = systemManagement.getConfigurationValue(key, Boolean.class);
break;
case AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME:
case AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY:
case AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME:
value = systemManagement.getConfigurationValue(key, String.class);
break;
default:
LOG.warn("There is no data type specified for TenantConfigurationKey {}.", key.getKeyName());
value = systemManagement.getConfigurationValue(key, String.class);
}
for (final TenantConfigurationKey key : TenantConfigurationKey.values()) {
final Object value = systemManagement.getConfigurationValue(key);
authconf.put(key.getKeyName(), value);
}
sysconf.setAuthenticationConfiguration(authconf);
return sysconf;
}
public static TenantMetaData fromRequest(SystemManagement systemManagement,
SystemConfigurationRequestBodyPut systemConReq, DistributionSetManagement distributionSetManagement) {
TenantMetaData tenantMetaData = systemManagement.getTenantMetadata();
String ddstypeKey = systemConReq.getDefaultDistributionSetType();
if (distributionSetManagement.findDistributionSetTypeByKey(ddstypeKey) == null) {
throw new IllegalArgumentException(
String.format("The specified default distribution set type %s doe not exist.", ddstypeKey));
}
tenantMetaData.setPollingOverdueTime(dh.formattedStringToDuration(systemConReq.getPollingOverdueTime()));
tenantMetaData.setPollingTime(dh.formattedStringToDuration(systemConReq.getPollingTime()));
public static TenantMetaData fromRequest(final SystemManagement systemManagement,
final SystemConfigurationRequestBodyPut systemConReq) {
// TODO
return null;
}
}

View File

@@ -39,7 +39,7 @@ public class SystemResource {
public ResponseEntity<SystemConfigurationRest> updateSoftwareModuleType(
@RequestBody final SystemConfigurationRequestBodyPut systemConReq) {
systemManagement.updateTenantConfiguration(systemConReq);
// systemManagement.updateTenantConfiguration(systemConReq);
return new ResponseEntity<>(SystemMapper.toResponse(systemManagement), HttpStatus.OK);
}

View File

@@ -54,7 +54,7 @@ public abstract class AbstractControllerAuthenticationFilter implements PreAuthe
@Override
public Boolean run() {
LOGGER.trace("retrieving configuration value for configuration key {}", getTenantConfigurationKey());
return systemManagement.getConfigurationValue(getTenantConfigurationKey(), Boolean.class);
return systemManagement.getConfigurationValue(getTenantConfigurationKey(), Boolean.class).getValue();
}
}

View File

@@ -85,7 +85,7 @@ public class ControllerPreAuthenticatedGatewaySecurityTokenFilter extends Abstra
LOGGER.trace("retrieving configuration value for configuration key {}",
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY);
return systemManagement.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class);
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class).getValue();
}
}

View File

@@ -143,7 +143,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont
@Override
public String run() {
return systemManagement.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class);
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class).getValue();
}
}
}

View File

@@ -66,7 +66,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
*/
@Override
public boolean isConfigEnabled() {
boolean b = systemManagement.getConfigurationValue(configurationKey, Boolean.class);
final boolean b = systemManagement.getConfigurationValue(configurationKey, Boolean.class).getValue();
return b;
}

View File

@@ -153,13 +153,15 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
configurationEnabledChange = false;
configurationCaRootAuthorityChanged = false;
configurationEnabled = getSystemManagement().getConfigurationValue(getConfigurationKey(), Boolean.class);
configurationEnabled = getSystemManagement().getConfigurationValue(getConfigurationKey(), Boolean.class)
.getValue();
caRootAuthorityTextField.setValue(getCaRootAuthorityValue());
}
private String getCaRootAuthorityValue() {
return getSystemManagement()
.getConfigurationValue(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class);
.getConfigurationValue(TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)
.getValue();
}
private void setDetailVisible(final boolean visible) {

View File

@@ -168,12 +168,12 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
private String getSecurityTokenName() {
return getSystemManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME, String.class);
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME, String.class).getValue();
}
private String getSecurityTokenKey() {
return getSystemManagement().getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class);
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class).getValue();
}
@Override

View File

@@ -96,6 +96,7 @@ public class TargetSecurityTokenAuthenticationConfigurationItem extends Abstract
@Override
public void undo() {
configurationEnabledChange = false;
configurationEnabled = getSystemManagement().getConfigurationValue(getConfigurationKey(), Boolean.class);
configurationEnabled = getSystemManagement().getConfigurationValue(getConfigurationKey(), Boolean.class)
.getValue();
}
}