Merge pull request #161 from bsinno/feature_add_targettoken_to_dmf

Add target security token to DMF update message
This commit is contained in:
Michael Hirsch
2016-05-09 13:07:51 +02:00
33 changed files with 618 additions and 289 deletions

View File

@@ -13,7 +13,6 @@ package org.eclipse.hawkbit.api;
* URLs to specific artifacts.
*
*/
@FunctionalInterface
public interface ArtifactUrlHandler {
/**
@@ -34,4 +33,11 @@ public interface ArtifactUrlHandler {
*/
String getUrl(String controllerId, final Long softwareModuleId, final String filename, final String sha1Hash,
final UrlProtocol protocol);
/**
* @param protocol
* to check support for
* @return <code>true</code> of the handler supports given protocol.
*/
boolean protocolSupported(UrlProtocol protocol);
}

View File

@@ -78,6 +78,12 @@ public class ArtifactUrlHandlerProperties {
* @return the pattern to build the URL.
*/
String getPattern();
/**
* @return <code>true</code> if the {@link ProtocolProperties} is
* enabled.
*/
boolean isEnabled();
}
/**
@@ -93,6 +99,20 @@ public class ArtifactUrlHandlerProperties {
*/
private String pattern = "{protocol}://{hostname}:{port}/{tenant}/controller/v1/{targetId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}";
/**
* Enables HTTP URI generation in DDI and DMF.
*/
private boolean enabled = true;
@Override
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@Override
public String getHostname() {
return hostname;
@@ -143,6 +163,20 @@ public class ArtifactUrlHandlerProperties {
*/
private String pattern = "{protocol}://{hostname}:{port}/{tenant}/controller/v1/{targetId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}";
/**
* Enables HTTPS URI generation in DDI and DMF.
*/
private boolean enabled = true;
@Override
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@Override
public String getHostname() {
return hostname;
@@ -193,6 +227,20 @@ public class ArtifactUrlHandlerProperties {
*/
private String pattern = "{protocol}://{ip}:{port}/fw/{tenant}/{targetId}/sha1/{artifactSHA1}";
/**
* Enables CoAP URI generation in DMF.
*/
private boolean enabled = true;
@Override
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
@Override
public String getHostname() {
return hostname;

View File

@@ -84,4 +84,15 @@ public class PropertyBasedArtifactUrlHandler implements ArtifactUrlHandler {
return replaceMap;
}
@Override
public boolean protocolSupported(final UrlProtocol protocol) {
final String protocolString = protocol.name().toLowerCase();
final ProtocolProperties properties = urlHandlerProperties.getProperties(protocolString);
if (properties == null || properties.getPattern() == null) {
return false;
}
return properties.isEnabled();
}
}