Merge branch 'master' into feature_ui_metadata
Conflicts: hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java hawkbit-ui/src/main/resources/messages_en.properties Resolved the conflicts.
This commit is contained in:
@@ -269,8 +269,7 @@ public interface DeploymentManagement {
|
||||
* @return the actions referring a specific rollout and a specific parent
|
||||
* rollout group in a specific status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActionsByRolloutGroupParentAndStatus(@NotNull Rollout rollout,
|
||||
@NotNull RolloutGroup rolloutGroupParent, @NotNull Action.Status actionStatus);
|
||||
|
||||
@@ -496,8 +495,7 @@ public interface DeploymentManagement {
|
||||
* the action to start now.
|
||||
* @return the action which has been started
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Action startScheduledAction(@NotNull Action action);
|
||||
|
||||
/**
|
||||
|
||||
@@ -287,6 +287,7 @@ public interface EntityFactory {
|
||||
|
||||
/**
|
||||
* Generates an empty {@link Target} without persisting it.
|
||||
* {@link Target#getSecurityToken()} is generated.
|
||||
*
|
||||
* @param controllerID
|
||||
* of the {@link Target}
|
||||
@@ -295,6 +296,19 @@ public interface EntityFactory {
|
||||
*/
|
||||
Target generateTarget(@NotEmpty String controllerID);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link Target} without persisting it.
|
||||
*
|
||||
* @param controllerID
|
||||
* of the {@link Target}
|
||||
* @param securityToken
|
||||
* of the {@link Target} for authentication if enabled on tenant.
|
||||
* Generates one if empty or <code>null</code>.
|
||||
*
|
||||
* @return {@link Target} object
|
||||
*/
|
||||
Target generateTarget(@NotEmpty String controllerID, @NotEmpty String securityToken);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link TargetFilterQuery} without persisting it.
|
||||
*
|
||||
|
||||
@@ -61,8 +61,7 @@ public interface RolloutManagement {
|
||||
* this check. This check is only applied if the last check is
|
||||
* less than (lastcheck-delay).
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void checkRunningRollouts(long delayBetweenChecks);
|
||||
|
||||
/**
|
||||
@@ -266,8 +265,7 @@ public interface RolloutManagement {
|
||||
* if given rollout is not in {@link RolloutStatus#RUNNING}.
|
||||
* Only running rollouts can be paused.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void pauseRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
@@ -281,8 +279,7 @@ public interface RolloutManagement {
|
||||
* if given rollout is not in {@link RolloutStatus#PAUSED}. Only
|
||||
* paused rollouts can be resumed.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void resumeRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
@@ -303,8 +300,7 @@ public interface RolloutManagement {
|
||||
* if given rollout is not in {@link RolloutStatus#READY}. Only
|
||||
* ready rollouts can be started.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout startRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
@@ -326,8 +322,7 @@ public interface RolloutManagement {
|
||||
* if given rollout is not in {@link RolloutStatus#READY}. Only
|
||||
* ready rollouts can be started.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout startRolloutAsync(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,16 +39,14 @@ public interface SystemManagement {
|
||||
* @param tenant
|
||||
* to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
void deleteTenant(@NotNull String tenant);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return list of all tenant names in the system.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
List<String> findTenants();
|
||||
|
||||
/**
|
||||
@@ -68,8 +66,8 @@ public interface SystemManagement {
|
||||
/**
|
||||
* Returns {@link TenantMetaData} of given and current tenant. Creates for
|
||||
* new tenants also two {@link SoftwareModuleType} (os and app) and
|
||||
* {@link RepositoryConstants#DEFAULT_DS_TYPES_IN_TENANT} {@link DistributionSetType}s
|
||||
* (os and os_app).
|
||||
* {@link RepositoryConstants#DEFAULT_DS_TYPES_IN_TENANT}
|
||||
* {@link DistributionSetType}s (os and os_app).
|
||||
*
|
||||
* DISCLAIMER: this variant is used during initial login (where the tenant
|
||||
* is not yet in the session). Please user {@link #getTenantMetadata()} for
|
||||
|
||||
@@ -54,8 +54,7 @@ public interface TenantConfigurationManagement {
|
||||
* @return <null> if no default value is set and no database value available
|
||||
* or returns the tenant configuration value
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||
<T> TenantConfigurationValue<T> buildTenantConfigurationValueByKey(TenantConfigurationKey configurationKey,
|
||||
Class<T> propertyType, TenantConfiguration tenantConfiguration);
|
||||
|
||||
@@ -87,8 +86,7 @@ public interface TenantConfigurationManagement {
|
||||
* if the property cannot be converted to the given
|
||||
* {@code propertyType}
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||
<T> TenantConfigurationValue<T> getConfigurationValue(TenantConfigurationKey configurationKey);
|
||||
|
||||
/**
|
||||
@@ -114,8 +112,7 @@ public interface TenantConfigurationManagement {
|
||||
* if the property cannot be converted to the given
|
||||
* {@code propertyType}
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||
<T> TenantConfigurationValue<T> getConfigurationValue(TenantConfigurationKey configurationKey,
|
||||
Class<T> propertyType);
|
||||
|
||||
@@ -139,7 +136,6 @@ public interface TenantConfigurationManagement {
|
||||
* if the property cannot be converted to the given
|
||||
* {@code propertyType}
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||
<T> T getGlobalConfigurationValue(TenantConfigurationKey configurationKey, Class<T> propertyType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if a multi part exception occurred.
|
||||
*
|
||||
*/
|
||||
public final class MultiPartFileUploadException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public MultiPartFileUploadException(final Throwable cause) {
|
||||
super(cause.getMessage(), SpServerError.SP_ARTIFACT_UPLOAD_FAILED, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,4 +58,10 @@ public interface Target extends NamedEntity {
|
||||
*/
|
||||
String getSecurityToken();
|
||||
|
||||
/**
|
||||
* @param token
|
||||
* new securityToken
|
||||
*/
|
||||
void setSecurityToken(String token);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
||||
@@ -87,6 +88,14 @@ public class JpaEntityFactory implements EntityFactory {
|
||||
return new JpaTarget(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Target generateTarget(final String controllerId, final String securityToken) {
|
||||
if (StringUtils.isEmpty(securityToken)) {
|
||||
return new JpaTarget(controllerId);
|
||||
}
|
||||
return new JpaTarget(controllerId, securityToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetTag generateTargetTag() {
|
||||
return new JpaTargetTag();
|
||||
|
||||
@@ -132,7 +132,7 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
final JpaSoftwareModuleType type = softwareModuleTypeRepository.findOne(sm.getId());
|
||||
|
||||
boolean updated = false;
|
||||
if (sm.getDescription() != null && !sm.getDescription().equals(type.getDescription())) {
|
||||
if (sm.getDescription() == null || !sm.getDescription().equals(type.getDescription())) {
|
||||
type.setDescription(sm.getDescription());
|
||||
updated = true;
|
||||
}
|
||||
|
||||
@@ -115,9 +115,21 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
|
||||
* controller ID of the {@link Target}
|
||||
*/
|
||||
public JpaTarget(final String controllerId) {
|
||||
this(controllerId, SecurityTokenGeneratorHolder.getInstance().generateToken());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param controllerId
|
||||
* controller ID of the {@link Target}
|
||||
* @param securityToken
|
||||
* for target authentication if enabled
|
||||
*/
|
||||
public JpaTarget(final String controllerId, final String securityToken) {
|
||||
this.controllerId = controllerId;
|
||||
setName(controllerId);
|
||||
securityToken = SecurityTokenGeneratorHolder.getInstance().generateToken();
|
||||
this.securityToken = securityToken;
|
||||
targetInfo = new JpaTargetInfo(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithSpringAuthorityRule;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithSpringAuthorityRule;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Ensures that retrieving the target security is only permitted with the necessary permissions.")
|
||||
public void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception {
|
||||
final Target createdTarget = targetManagement.createTarget(new JpaTarget("targetWithSecurityToken"));
|
||||
final Target createdTarget = targetManagement.createTarget(new JpaTarget("targetWithSecurityToken", "token"));
|
||||
|
||||
// retrieve security token only with READ_TARGET_SEC_TOKEN permission
|
||||
final String securityTokenWithReadPermission = securityRule.runAs(WithSpringAuthorityRule
|
||||
@@ -80,7 +80,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
return createdTarget.getSecurityToken();
|
||||
});
|
||||
|
||||
assertThat(createdTarget.getSecurityToken()).isNotNull();
|
||||
assertThat(createdTarget.getSecurityToken()).isEqualTo("token");
|
||||
assertThat(securityTokenWithReadPermission).isNotNull();
|
||||
assertThat(securityTokenAsSystemCode).isNotNull();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
|
||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
|
||||
import com.google.common.eventbus.AsyncEventBus;
|
||||
@@ -99,7 +99,7 @@ public class TestConfiguration implements AsyncConfigurer {
|
||||
|
||||
@Bean
|
||||
public Executor asyncExecutor() {
|
||||
return new DelegatingSecurityContextExecutor(Executors.newSingleThreadExecutor());
|
||||
return new DelegatingSecurityContextExecutorService(Executors.newSingleThreadExecutor());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user