Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7 from openconnectivity/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
javiguerra authored Sep 27, 2019
2 parents 83eb1b9 + 550f64c commit 318afe6
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 103 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ The steps required to build the binary of the IoTivity-lite Linux API are shown
```
git checkout swig
```
2. Go to the linux directory.
2. Apply the patch of the OTGC in IoTivity-lite
```
git apply <otgc-linux>/extlibs/patchs/remove_cred_by_credid.patch
```
3. Go to the linux directory.
```
cd <iotivity-lite>/port/linux
```
3. Execute the command to build the library.
4. Execute the command to build the library.
```
make DEBUG=1 SECURE=1 IPV4=1 TCP=0 PKI=1 DYNAMIC=1 CLOUD=0 JAVA=1 IDD=1
```
Expand Down Expand Up @@ -126,4 +130,4 @@ To uninstall the aplication, use the next command:

This library is released under Apache 2.0 license (http://www.apache.org/licenses/LICENSE-2.0.txt).

Please see the file 'LICENSE.md' in the root folder for further information.
Please see the file 'LICENSE.md' in the root folder for further information.
2 changes: 1 addition & 1 deletion build/debian/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: OTGC
Version: 2.0.5
Version: 2.0.6
Section: custom
Priority: optional
Architecture: amd64
Expand Down
2 changes: 1 addition & 1 deletion build/debian/otgc_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# Constants
PROJECT_NAME="otgc"
VERSION="2.0.5"
VERSION="2.0.6"

program=$0

Expand Down
2 changes: 1 addition & 1 deletion extlibs/iotivity-lite
Submodule iotivity-lite updated from 1b955e to 513d1c
17 changes: 8 additions & 9 deletions extlibs/patchs/remove_cred_by_credid.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ index acbab8c..c16b512 100644
}
#endif
diff --git a/security/oc_pki.c b/security/oc_pki.c
index a3ecc4f..97e8fb3 100644
index a9306c2..c9b3b15 100644
--- a/security/oc_pki.c
+++ b/security/oc_pki.c
@@ -334,6 +334,16 @@ oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
@@ -354,6 +354,16 @@ oc_pki_add_trust_anchor(size_t device, const unsigned char *cert,
return pki_add_trust_anchor(device, cert, cert_size, OC_CREDUSAGE_TRUSTCA);
}

Expand All @@ -34,16 +34,15 @@ index a3ecc4f..97e8fb3 100644
typedef int dummy_declaration;
#endif /* !OC_PKI */
diff --git a/swig/swig_interfaces/oc_pki.i b/swig/swig_interfaces/oc_pki.i
index ae654bb..c4bae02 100644
index 2765e56..9910770 100644
--- a/swig/swig_interfaces/oc_pki.i
+++ b/swig/swig_interfaces/oc_pki.i
@@ -32,6 +32,6 @@
%rename (addMfgTrustAnchor) oc_pki_add_mfg_trust_anchor;
%rename (addTrustAnchor) oc_pki_add_trust_anchor;
%rename (setSecurityProfile) oc_pki_set_security_profile;
+%rename (removeCredentialByCredid) oc_pki_remove_credential_by_credid;
@@ -105,4 +105,6 @@ void jni_pki_set_security_profile(size_t device,
}
%}

-
-%include "oc_pki.h"
\ No newline at end of file
+%rename (removeCredentialByCredid) oc_pki_remove_credential_by_credid;
+
+%include "oc_pki.h"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>otgc</groupId>
<artifactId>otgc</artifactId>
<version>2.0.5</version>
<version>2.0.6</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Completable initOICStack() {
public int initialize() {
LOG.debug("In OCMainInitHandler.initilize()");
int ret = OCMain.initPlatform("OCF");
ret |= OCMain.addDevice("/oic/d", "oic.d.phone", "OTGC", "ocf.2.4.0", "ocf.res.1.3.0");
ret |= OCMain.addDevice("/oic/d", "oic.wk.d", "OTGC", "ocf.2.4.0", "ocf.res.1.3.0");
return ret;
}

Expand Down Expand Up @@ -443,7 +443,7 @@ public Single<List<OcResource>> findVerticalResources(String host) {
List<OcResource> resourceList = new ArrayList<>();
for (OcResource resource : ocRes.getResourceList()) {
for (String resourceType : resource.getResourceTypes()) {
if (!RESOURCE_TYPES_TO_FILTER.contains(resourceType)
if (OcfResourceType.isVerticalResourceType(resourceType)
&& !resourceType.startsWith("oic.d.")) {
resourceList.add(resource);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public Single<Device> execute(Device deviceToOffboard) {

return doxsRepository.resetDevice(deviceToOffboard.getDeviceId())
.delay(delay, TimeUnit.SECONDS, schedulersFacade.ui())
.andThen(getUpdatedOcSecureResource)
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)));
.andThen(getUpdatedOcSecureResource
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public Single<Device> execute(Device deviceToOnboard, OcfOxmType oxm) {

return doxsRepository.doOwnershipTransfer(deviceToOnboard.getDeviceId(), oxm)
.delay(delay, TimeUnit.SECONDS, schedulersFacade.ui())
.andThen(getUpdatedOcSecureResource)
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)));
.andThen(getUpdatedOcSecureResource
.onErrorResumeNext(error -> getUpdatedOcSecureResource
.retry(2)
.onErrorResumeNext(Single.error(error)))
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2019 DEKRA Testing and Certification, S.A.U. All Rights Reserved.
*
* ****************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.openconnectivity.otgc.domain.usecase;

import io.reactivex.Completable;
import org.openconnectivity.otgc.data.repository.ProvisionRepository;
import org.openconnectivity.otgc.data.repository.SettingRepository;
import org.openconnectivity.otgc.utils.constant.OtgcMode;

import javax.inject.Inject;

public class ResetClientModeUseCase {

private final ProvisionRepository provisionRepository;
private final SettingRepository settingRepository;

@Inject
public ResetClientModeUseCase(ProvisionRepository provisionRepository,
SettingRepository settingRepository) {
this.provisionRepository = provisionRepository;
this.settingRepository = settingRepository;
}

public Completable execute() {
return provisionRepository.resetSvrDb()
.andThen(settingRepository.set(SettingRepository.MODE_KEY, OtgcMode.CLIENT));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2019 DEKRA Testing and Certification, S.A.U. All Rights Reserved.
*
* ****************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.openconnectivity.otgc.domain.usecase;

import io.reactivex.Completable;
import org.openconnectivity.otgc.data.repository.DoxsRepository;
import org.openconnectivity.otgc.data.repository.IotivityRepository;
import org.openconnectivity.otgc.data.repository.ProvisionRepository;
import org.openconnectivity.otgc.data.repository.SettingRepository;
import org.openconnectivity.otgc.utils.constant.OtgcMode;

import javax.inject.Inject;
import java.util.concurrent.TimeUnit;

public class ResetObtModeUseCase {

private final IotivityRepository iotivityRepository;
private final DoxsRepository doxsRepository;
private final ProvisionRepository provisioningRepository;
private final SettingRepository settingRepository;

@Inject
public ResetObtModeUseCase(IotivityRepository iotivityRepository,
DoxsRepository doxsRepository,
ProvisionRepository provisioningRepository,
SettingRepository settingRepository) {
this.iotivityRepository = iotivityRepository;
this.doxsRepository = doxsRepository;
this.provisioningRepository = provisioningRepository;
this.settingRepository = settingRepository;
}

public Completable execute() {
int delay = Integer.parseInt(settingRepository.get(SettingRepository.REQUESTS_DELAY_KEY, SettingRepository.REQUESTS_DELAY_DEFAULT_VALUE));

return iotivityRepository.scanOwnedDevices()
.flatMapCompletable(device -> doxsRepository.resetDevice(device.getDeviceId()))
.delay(delay, TimeUnit.SECONDS)
.andThen(provisioningRepository.resetSvrDb())
.andThen(settingRepository.set(SettingRepository.MODE_KEY, OtgcMode.OBT));
}
}
11 changes: 0 additions & 11 deletions src/main/java/org/openconnectivity/otgc/view/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
final Object lock = new Object();
Platform.runLater(() -> {
ButtonType yesButton = new ButtonType("Yes", ButtonBar.ButtonData.OK_DONE);
ButtonType noButton = new ButtonType("No", ButtonBar.ButtonData.CANCEL_CLOSE);

Alert alertDialog = new Alert(Alert.AlertType.CONFIRMATION);
alertDialog.setTitle("Insert random PIN");
Expand All @@ -91,7 +90,6 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
alertDialog.getDialogPane().setGraphic(input);
alertDialog.getButtonTypes().clear();
alertDialog.getButtonTypes().add(yesButton);
alertDialog.getButtonTypes().add(noButton);

Optional<ButtonType> result = alertDialog.showAndWait();
if (result.get() == yesButton) {
Expand All @@ -104,15 +102,6 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage());
}
} else if (result.get() == noButton) {
alertDialog.close();
try {
synchronized (lock) {
lock.notifyAll();
}
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage());
}
}
});

Expand Down
Loading

0 comments on commit 318afe6

Please sign in to comment.