Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface for hawkBits repository implementation #200

Merged
merged 48 commits into from
Jun 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6654d71
Started with #100 by means of splitting the management services into API
kaizimmerm May 13, 2016
3c0d539
Removed default implementations as JaCoCo has problems with those. Split
kaizimmerm May 18, 2016
3e5330a
Completed management separation.
kaizimmerm May 19, 2016
e3041aa
Started to split the actual model.
kaizimmerm May 20, 2016
8b7b241
Merge remote-tracking branch
kaizimmerm May 20, 2016
f0a7836
Continued on the model API extraction. Merged rest api split branch.
kaizimmerm May 21, 2016
9301de0
Worked on the interfaces and documentation.
kaizimmerm May 22, 2016
1e91643
Adapted repo scan
kaizimmerm May 24, 2016
cf450da
Merge remote-tracking branch 'eclipse/master' into
kaizimmerm May 24, 2016
f2e13b8
Split into separate maven modules.
kaizimmerm May 25, 2016
eeee57f
Refactored package names.
kaizimmerm May 26, 2016
e6ff96d
Completed maven module split.
kaizimmerm May 27, 2016
53156cb
Javadoc, sonar issue, package cycles.
kaizimmerm May 27, 2016
a4e0fc2
Fixed a broken query.
kaizimmerm May 27, 2016
2d90900
fix javadoc
michahirsch May 31, 2016
7a98c58
refactored test data generation. Refactored entity factor methods.
kaizimmerm May 31, 2016
b369369
add javadoc
michahirsch May 31, 2016
002e0d3
Merge branch 'feature_split_repo_into_api_impl' of
michahirsch May 31, 2016
b1a2a58
fix mock test by mocking action and target
michahirsch May 31, 2016
a0ec726
Small fixes
MelleD May 31, 2016
c2cb42d
add javadoc
michahirsch May 31, 2016
14cb962
fix sonar rule don't use generic wildcard
michahirsch May 31, 2016
b14d3bb
Small fixes
MelleD May 31, 2016
62a2e2c
introduce own interfaces for registering the currentTenantKeyGenerator
michahirsch May 31, 2016
32e5d36
Merge branch 'feature_split_repo_into_api_impl' of https://github.com…
michahirsch May 31, 2016
f1e3406
Move jackson dependendy from repo to rest-core
MelleD May 31, 2016
965e283
Merge branch 'feature_split_repo_into_api_impl' of https://github.com…
MelleD May 31, 2016
252f409
fix generic wildcard
michahirsch May 31, 2016
310071d
Merge branch 'feature_split_repo_into_api_impl' of https://github.com…
michahirsch May 31, 2016
a8bca3d
fix sonar issue unused local variable
michahirsch May 31, 2016
1117bbe
re-add json dependency for tests
michahirsch May 31, 2016
91fd94b
Migrated MySQL schema creation to test package. Small doc improvements
kaizimmerm May 31, 2016
e054a17
Merge branch 'feature_split_repo_into_api_impl' of https://github.com…
kaizimmerm May 31, 2016
13f9791
Removed JPA dependencies from runtime. Test only now.
kaizimmerm May 31, 2016
1881880
Added findactions method.
kaizimmerm Jun 1, 2016
4bea2ae
Merge remote-tracking branch 'eclipse/master' into feature_split_repo…
kaizimmerm Jun 1, 2016
615cbe2
Added null check for selected target
kaizimmerm Jun 1, 2016
561e6b9
Fixed event processing.
kaizimmerm Jun 1, 2016
935ca2f
Fixed broken repo access security checks.
kaizimmerm Jun 2, 2016
5d17a7d
Added sonar exceptions.
kaizimmerm Jun 2, 2016
8c904f9
Ignoring springBeans meta file.
kaizimmerm Jun 2, 2016
e3156b1
Merge remote-tracking branch 'eclipse/master' into feature_split_repo…
kaizimmerm Jun 2, 2016
e12fcd8
Fixed default ds gen.
kaizimmerm Jun 2, 2016
2769170
Created constants in API for default tenant type setup.
kaizimmerm Jun 2, 2016
7468d89
Completed constants.
kaizimmerm Jun 3, 2016
aab2503
Merge branch 'master' into feature_create_repo_api
kaizimmerm Jun 3, 2016
706c825
Added test for DoSFilter.
kaizimmerm Jun 3, 2016
a73d72b
Fixed header.
kaizimmerm Jun 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ local.properties
# Maven
maven.properties
/*/maven.properties

hawkbit-repository/hawkbit-repository-jpa/.springBeans
5 changes: 5 additions & 0 deletions examples/hawkbit-custom-theme-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
<artifactId>hawkbit-http-security</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Spring -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.EnableJpaRepository;
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;

/**
* A {@link SpringBootApplication} annotated class with a main method to start.
* The minimal configuration for the stand alone hawkBit server.
*
*/
@SpringBootApplication
@Import({ RepositoryApplicationConfiguration.class })
@EnableHawkbitManagedSecurityConfiguration
// Exception squid:S1118 - Spring boot standard behavior
@SuppressWarnings({ "squid:S1118" })
@EnableJpaRepository
public class Start {
/**
* Main method to start the spring-boot application.
Expand Down
6 changes: 0 additions & 6 deletions examples/hawkbit-device-simulator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-jackson</artifactId>
<version>8.14.1</version>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-core</artifactId>
<version>8.12.1</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ private static UpdateStatus downloadUrl(final String url, final String targetTok
}

final File tempFile = File.createTempFile("uploadFile", null);

// Exception squid:S2070 - not used for hashing sensitive
// data
@SuppressWarnings("squid:S2070")
final MessageDigest md = MessageDigest.getInstance("SHA-1");

try (final DigestOutputStream dos = new DigestOutputStream(new FileOutputStream(tempFile), md)) {
Expand Down
5 changes: 5 additions & 0 deletions examples/hawkbit-example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
<artifactId>hawkbit-http-security</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Spring -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@
*/
package org.eclipse.hawkbit.app;

import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.EnableJpaRepository;
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
import org.eclipse.hawkbit.ddi.EnableDdiApi;
import org.eclipse.hawkbit.mgmt.EnableMgmtApi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;

/**
* A {@link SpringBootApplication} annotated class with a main method to start.
* The minimal configuration for the stand alone hawkBit server.
*
*/
@SpringBootApplication
@Import({ RepositoryApplicationConfiguration.class })
@EnableHawkbitManagedSecurityConfiguration
@EnableMgmtApi
@EnableDdiApi
@EnableJpaRepository
// Exception squid:S1118 - Spring boot standard behavior
@SuppressWarnings({ "squid:S1118" })
public class Start {
Expand Down
1 change: 1 addition & 0 deletions examples/hawkbit-example-mgmt-simulator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target/
/bin/
/.apt_generated/
/.springBeans
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ public DbArtifact store(final InputStream content, final String filename, final
try {
LOGGER.debug("storing file {} of content {}", filename, contentType);
tempFile = File.createTempFile("uploadFile", null);
try (final FileOutputStream os = new FileOutputStream(tempFile)) {
try (BufferedOutputStream bos = new BufferedOutputStream(os)) {
try (BufferedInputStream bis = new BufferedInputStream(content)) {
return store(content, contentType, bos, tempFile, hash);
}
try (final BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tempFile))) {
try (BufferedInputStream bis = new BufferedInputStream(content)) {
return store(bis, contentType, bos, tempFile, hash);
}
}
} catch (final IOException | MongoException e1) {
Expand Down Expand Up @@ -207,6 +205,9 @@ private static String computeSHA1Hash(final InputStream stream, final OutputStre
throws NoSuchAlgorithmException, IOException {
String sha1Hash;
// compute digest
// Exception squid:S2070 - not used for hashing sensitive
// data
@SuppressWarnings("squid:S2070")
final MessageDigest md = MessageDigest.getInstance("SHA-1");
try (final DigestOutputStream dos = new DigestOutputStream(os, md)) {
ByteStreams.copy(stream, dos);
Expand Down
2 changes: 1 addition & 1 deletion hawkbit-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository</artifactId>
<artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import org.eclipse.hawkbit.eventbus.EventBusSubscriberProcessor;
import org.eclipse.hawkbit.eventbus.EventSubscriber;
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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.autoconfigure.repository;

import org.eclipse.hawkbit.EnableJpaRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
* Auto-Configuration for enabling the REST-Resources.
*
*/
@Configuration
@ConditionalOnClass({ EnableJpaRepository.class })
@Import({ EnableJpaRepository.class })
public class JpaRepositoryAutoConfiguration {

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.im.authentication.TenantAwareAuthenticationDetails;
import org.eclipse.hawkbit.im.authentication.UserAuthenticationFilter;
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
import org.eclipse.hawkbit.security.DdiSecurityProperties;
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,60 +30,45 @@ public enum TenantConfigurationKey {
/**
* boolean value {@code true} {@code false}.
*/
AUTHENTICATION_MODE_HEADER_ENABLED("authentication.header.enabled",
"hawkbit.server.ddi.security.authentication.header.enabled", Boolean.class, Boolean.FALSE.toString(),
TenantConfigurationBooleanValidator.class),
AUTHENTICATION_MODE_HEADER_ENABLED("authentication.header.enabled", "hawkbit.server.ddi.security.authentication.header.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
/**
*
*/
AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME("authentication.header.authority",
"hawkbit.server.ddi.security.authentication.header.authority", String.class, Boolean.FALSE.toString(),
TenantConfigurationStringValidator.class),
AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME("authentication.header.authority", "hawkbit.server.ddi.security.authentication.header.authority", String.class, Boolean.FALSE.toString(), TenantConfigurationStringValidator.class),
/**
* boolean value {@code true} {@code false}.
*/
AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED("authentication.targettoken.enabled",
"hawkbit.server.ddi.security.authentication.targettoken.enabled", Boolean.class, Boolean.FALSE.toString(),
TenantConfigurationBooleanValidator.class),
AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED("authentication.targettoken.enabled", "hawkbit.server.ddi.security.authentication.targettoken.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),

/**
* boolean value {@code true} {@code false}.
*/
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED("authentication.gatewaytoken.enabled",
"hawkbit.server.ddi.security.authentication.gatewaytoken.enabled", Boolean.class, Boolean.FALSE.toString(),
TenantConfigurationBooleanValidator.class),
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED("authentication.gatewaytoken.enabled", "hawkbit.server.ddi.security.authentication.gatewaytoken.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class),
/**
* string value which holds the name of the security token key.
*/
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME("authentication.gatewaytoken.name",
"hawkbit.server.ddi.security.authentication.gatewaytoken.name", String.class, null,
TenantConfigurationStringValidator.class),
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_NAME("authentication.gatewaytoken.name", "hawkbit.server.ddi.security.authentication.gatewaytoken.name", String.class, null, TenantConfigurationStringValidator.class),

/**
* string value which holds the actual security-key of the gateway security
* token.
*/
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY("authentication.gatewaytoken.key",
"hawkbit.server.ddi.security.authentication.gatewaytoken.key", String.class, null,
TenantConfigurationStringValidator.class),
AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY("authentication.gatewaytoken.key", "hawkbit.server.ddi.security.authentication.gatewaytoken.key", String.class, null, TenantConfigurationStringValidator.class),

/**
* string value which holds the polling time interval in the format HH:mm:ss
*/
POLLING_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null,
TenantConfigurationPollingDurationValidator.class),
POLLING_TIME_INTERVAL("pollingTime", "hawkbit.controller.pollingTime", String.class, null, TenantConfigurationPollingDurationValidator.class),

/**
* string value which holds the polling time interval in the format HH:mm:ss
*/
POLLING_OVERDUE_TIME_INTERVAL("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", String.class, null,
TenantConfigurationPollingDurationValidator.class),
POLLING_OVERDUE_TIME_INTERVAL("pollingOverdueTime", "hawkbit.controller.pollingOverdueTime", String.class, null, TenantConfigurationPollingDurationValidator.class),

/**
* boolean value {@code true} {@code false}.
*/
ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled",
Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);
ANONYMOUS_DOWNLOAD_MODE_ENABLED("anonymous.download.enabled", "hawkbit.server.download.anonymous.enabled", Boolean.class, Boolean.FALSE.toString(), TenantConfigurationBooleanValidator.class);

private final String keyName;
private final String defaultKeyName;
Expand Down Expand Up @@ -140,8 +125,9 @@ public String getDefaultValue() {
* @return the data type of the tenant configuration value. (e.g.
* Integer.class, String.class)
*/
public Class<?> getDataType() {
return dataType;
@SuppressWarnings("unchecked")
public <T> Class<T> getDataType() {
return (Class<T>) dataType;
}

/**
Expand Down
16 changes: 14 additions & 2 deletions hawkbit-ddi-resource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository</artifactId>
<artifactId>hawkbit-repository-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand All @@ -48,6 +48,18 @@


<!-- Test -->
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-rest-core</artifactId>
Expand Down Expand Up @@ -93,7 +105,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
<artifactId>hawkbit-repository</artifactId>
<artifactId>hawkbit-repository-jpa</artifactId>
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import javax.servlet.http.HttpServletRequest;

import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.cache.CacheWriteNotify;
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlArtifactStoreControllerRestApi;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus;
Expand Down Expand Up @@ -58,15 +59,15 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
@Autowired
private ControllerManagement controllerManagement;

@Autowired
private CacheWriteNotify cacheWriteNotify;

@Autowired
private HawkbitSecurityProperties securityProperties;

@Autowired
private RequestResponseContextHolder requestResponseContextHolder;

@Autowired
private EntityFactory entityFactory;

@Override
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
@AuthenticationPrincipal final String targetid) {
Expand Down Expand Up @@ -96,7 +97,8 @@ public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("fil
requestResponseContextHolder.getHttpServletRequest(), targetid, artifact);
result = RestResourceConversionHelper.writeFileResponse(artifact,
requestResponseContextHolder.getHttpServletResponse(),
requestResponseContextHolder.getHttpServletRequest(), file, cacheWriteNotify, action.getId());
requestResponseContextHolder.getHttpServletRequest(), file, controllerManagement,
action.getId());
} else {
result = RestResourceConversionHelper.writeFileResponse(artifact,
requestResponseContextHolder.getHttpServletResponse(),
Expand Down Expand Up @@ -138,19 +140,19 @@ private Action checkAndReportDownloadByTarget(final HttpServletRequest request,
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), artifact.getSoftwareModule());
final String range = request.getHeader("Range");

final ActionStatus actionStatus = new ActionStatus();
final ActionStatus actionStatus = entityFactory.generateActionStatus();
actionStatus.setAction(action);
actionStatus.setOccurredAt(System.currentTimeMillis());
actionStatus.setStatus(Status.DOWNLOAD);

if (range != null) {
actionStatus.addMessage(ControllerManagement.SERVER_MESSAGE_PREFIX + "Target downloads range " + range
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target downloads range " + range
+ " of: " + request.getRequestURI());
} else {
actionStatus.addMessage(
ControllerManagement.SERVER_MESSAGE_PREFIX + "Target downloads: " + request.getRequestURI());
RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target downloads: " + request.getRequestURI());
}
controllerManagement.addActionStatusMessage(actionStatus);
controllerManagement.addInformationalActionStatus(actionStatus);
return action;
}

Expand Down
Loading