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

Bug 562012 license is not recognized when USB disk is plugged #195

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
public class OshiHardwareInspector implements HardwareInspector {

private final Map<String, String> hardwareProperties = new LinkedHashMap<>();
private SystemInfo systemInfo;

private LicensingReporter licensingReporter = SystemReporter.INSTANCE;

@Activate
Expand All @@ -53,7 +51,7 @@ public void activate() {

private void initHardwareProperties() {
try {
systemInfo = new SystemInfo();
SystemInfo systemInfo = new SystemInfo();
OperatingSystem os = systemInfo.getOperatingSystem();
hardwareProperties.put(HardwareInspector.PROPERTY_OS_MANUFACTURER, os.getManufacturer());
hardwareProperties.put(HardwareInspector.PROPERTY_OS_FAMILY, os.getFamily());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import static org.eclipse.passage.lic.base.LicensingProperties.LICENSING_CONDITION_TYPE_ID;
import static org.eclipse.passage.lic.base.LicensingProperties.LICENSING_CONDITION_TYPE_NAME;

import java.util.Arrays;

import org.eclipse.passage.lic.api.access.PermissionEmitter;
import org.eclipse.passage.lic.api.inspector.HardwareInspector;
import org.eclipse.passage.lic.base.access.BasePermissionEmitter;
Expand All @@ -24,6 +26,8 @@
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import oshi.SystemInfo;

@Component(property = { LICENSING_CONDITION_TYPE_ID + '=' + OshiHal.CONDITION_TYPE_HARDWARE,
LICENSING_CONDITION_TYPE_NAME + '=' + "Hardware", LICENSING_CONDITION_TYPE_DESCRIPTION + '='
+ "Evaluates node-locked conditions using runtime hardware information" })
Expand All @@ -47,6 +51,12 @@ public void unbindHardwareInspector(HardwareInspector inspector) {

@Override
protected boolean evaluateSegment(String key, String expected) {
// FIXME: EP: fast hack for 562012,
// to be solved properly with formats alternations in 0.9
if (key.equals(HardwareInspector.PROPERTY_HWDISK_SERIAL)) {
return Arrays.stream(new SystemInfo().getHardware().getDiskStores()) //
.anyMatch(disk -> LicensingConditions.evaluateSegmentValue(expected, disk.getSerial()));
}
String actual = hardwareInspector.inspectProperty(key);
return LicensingConditions.evaluateSegmentValue(expected, actual);
}
Expand Down