Feature hawkbit uaa extension (#317)

* use UserPrincipal to determine tenant at runtime

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>

* add hawkbit-uaa extension

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>

* adapt WithSpringAuthorityRule with UserPrincipal for determine tenant

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>

* fix String principal in DDI download resource

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>

* merge the email to the UserPrincipal from the master manually

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>

* Fixed some grammar issues and typos

Signed-off-by: Dominic Schabel <dominic.schabel@bosch-si.com>
This commit is contained in:
Michael Hirsch
2016-10-31 13:16:03 +01:00
committed by GitHub
parent b7f5bf3d79
commit 22272ba3c1
15 changed files with 654 additions and 59 deletions

View File

@@ -16,6 +16,7 @@ import javax.servlet.http.HttpServletRequest;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.ddi.dl.rest.api.DdiDlArtifactStoreControllerRestApi;
import org.eclipse.hawkbit.im.authentication.UserPrincipal;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
@@ -70,7 +71,7 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
@Override
public ResponseEntity<InputStream> downloadArtifactByFilename(@PathVariable("tenant") final String tenant,
@PathVariable("fileName") final String fileName, @AuthenticationPrincipal final String targetid) {
@PathVariable("fileName") final String fileName, @AuthenticationPrincipal final Object principal) {
final List<Artifact> foundArtifacts = artifactManagement.findArtifactByFilename(fileName);
if (foundArtifacts.isEmpty()) {
@@ -92,9 +93,11 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
// we set a download status only if we are aware of the
// targetid, i.e. authenticated and not anonymous
if (targetid != null && !"anonymous".equals(targetid)) {
if (principal instanceof UserPrincipal && ((UserPrincipal) principal).getUsername() != null
&& !"anonymous".equals(((UserPrincipal) principal).getUsername())) {
final ActionStatus actionStatus = checkAndReportDownloadByTarget(
requestResponseContextHolder.getHttpServletRequest(), targetid, artifact);
requestResponseContextHolder.getHttpServletRequest(), ((UserPrincipal) principal).getUsername(),
artifact);
result = RestResourceConversionHelper.writeFileResponse(artifact,
requestResponseContextHolder.getHttpServletResponse(),
requestResponseContextHolder.getHttpServletRequest(), file, controllerManagement,