Unverified Commit f70dcdba authored by Javier Guerra's avatar Javier Guerra Committed by GitHub

Merge pull request #4 from openconnectivity/develop

Merge develop into master
parents a0162d27 d3909235
Package: OTGC
Version: 2.0.2
Version: 2.0.3
Section: custom
Priority: optional
Architecture: amd64
......
......@@ -11,7 +11,7 @@
# Constants
PROJECT_NAME="otgc"
VERSION="2.0.2"
VERSION="2.0.3"
program=$0
......
......@@ -6,7 +6,7 @@
<groupId>otgc</groupId>
<artifactId>otgc</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -69,9 +69,8 @@ public class DeviceEntity {
this.hosts = new ArrayList<>();
while(endpoints != null) {
String[] endpointStr = new String[1];
OCEndpointUtil.toString(endpoints, endpointStr);
this.hosts.add(endpointStr[0]);
String endpointStr = OCEndpointUtil.toString(endpoints);
this.hosts.add(endpointStr);
endpoints = endpoints.getNext();
}
......
......@@ -77,6 +77,8 @@ public class DoxsRepository {
emitter.onError(new Exception(error));
}
});
} else if (oxm == OcfOxmType.OC_OXMTYPE_MFG_CERT) {
ret = OCObt.performCertOtm(uuid, handler);
}
if (ret >= 0) {
......
......@@ -20,7 +20,6 @@
package org.openconnectivity.otgc.data.repository;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.reactivex.Observable;
import io.reactivex.Single;
import org.apache.log4j.Logger;
......@@ -105,7 +104,7 @@ public class IotivityRepository {
public int initialize() {
LOG.debug("In OCMainInitHandler.initilize()");
int ret = OCMain.initPlatform("OCF");
ret |= OCMain.addDevice("/oic/d", "oic.d.phone", "OTGC", "ocf.1.0.0", "ocf.res.1.3.0");
ret |= OCMain.addDevice("/oic/d", "oic.d.phone", "OTGC", "ocf.2.4.0", "ocf.res.1.3.0");
return ret;
}
......@@ -375,7 +374,7 @@ public class IotivityRepository {
public Single<String> getDeviceName(String deviceId) {
return Single.create(emitter -> {
DeviceEntity device = deviceDao.findById(deviceId);
emitter.onSuccess(device.getName());
emitter.onSuccess(device.getName() != null ? device.getName() : "Unnamed");
});
}
......
......@@ -53,17 +53,16 @@ public class Device implements Comparable<Device> {
this.permits = permits;
while(endpoints != null) {
String[] endpointStr = new String[1];
OCEndpointUtil.toString(endpoints, endpointStr);
if (endpointStr[0].startsWith("coaps://") && endpointStr[0].contains(".")) {
ipv4SecureHost = endpointStr[0];
} else if (endpointStr[0].startsWith("coaps://")) {
ipv6SecureHost = endpointStr[0];
} else if (endpointStr[0].startsWith("coap://") && endpointStr[0].contains(".")) {
ipv4Host = endpointStr[0];
} else if (endpointStr[0].startsWith("coap://")){
ipv6Host = endpointStr[0];
String endpointStr = OCEndpointUtil.toString(endpoints);
if (endpointStr.startsWith("coaps://") && endpointStr.contains(".")) {
ipv4SecureHost = endpointStr;
} else if (endpointStr.startsWith("coaps://")) {
ipv6SecureHost = endpointStr;
} else if (endpointStr.startsWith("coap://") && endpointStr.contains(".")) {
ipv4Host = endpointStr;
} else if (endpointStr.startsWith("coap://")){
ipv6Host = endpointStr;
}
endpoints = endpoints.getNext();
......@@ -203,7 +202,17 @@ public class Device implements Comparable<Device> {
int res;
if (this.getDeviceType() == device.getDeviceType()) { // Same types
int nameComparision = this.getDeviceInfo().getName().compareTo(device.getDeviceInfo().getName());
int nameComparision;
if (this.getDeviceInfo().getName() == null && device.getDeviceInfo().getName() == null) {
nameComparision = 0;
} else if (this.getDeviceInfo().getName() == null) {
nameComparision = -1;
} else if (device.getDeviceInfo().getName() == null) {
nameComparision = 1;
} else {
nameComparision = this.getDeviceInfo().getName().compareTo(device.getDeviceInfo().getName());
}
int uuidComparision = this.getDeviceId().compareTo(device.getDeviceId());
// order by name or order by UUID if the names are equals
......
......@@ -99,8 +99,8 @@ public class LinkDevicesUseCase {
String rootCert = certRepository.x509CertificateToPemString(rootCa).blockingGet();
// Generate the identity certificate in PEM format
X509Certificate idCert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
//X509Certificate idCert = certRepository.generateIdentityCertificate(device.getDeviceId(), publicKey, caPrivateKey).blockingGet();
//X509Certificate idCert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
X509Certificate idCert = certRepository.generateIdentityCertificate(client.getDeviceId(), publicKey, caPrivateKey).blockingGet();
String identityCert = certRepository.x509CertificateToPemString(idCert).blockingGet();
return cmsRepository.provisionIdentityCertificate(endpoint, client.getDeviceId(), rootCert, identityCert);
......@@ -126,8 +126,8 @@ public class LinkDevicesUseCase {
String rootCert = certRepository.x509CertificateToPemString(rootCa).blockingGet();
// Generate the certificate in PEM format
X509Certificate cert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
//X509Certificate cert = certRepository.generateIdentityCertificate(device.getDeviceId(), publicKey, caPrivateKey).blockingGet();
//X509Certificate cert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
X509Certificate cert = certRepository.generateIdentityCertificate(server.getDeviceId(), publicKey, caPrivateKey).blockingGet();
String identityCert = certRepository.x509CertificateToPemString(cert).blockingGet();
return cmsRepository.provisionIdentityCertificate(endpoint, server.getDeviceId(), rootCert, identityCert);
......
......@@ -73,8 +73,8 @@ public class LinkRoleForClientUseCase {
String rootCert = certRepository.x509CertificateToPemString(rootCa).blockingGet();
// Generate the identity certificate in PEM format
X509Certificate idCert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
//X509Certificate idCert = certRepository.generateIdentityCertificate(device.getDeviceId(), publicKey, caPrivateKey).blockingGet();
//X509Certificate idCert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
X509Certificate idCert = certRepository.generateIdentityCertificate(device.getDeviceId(), publicKey, caPrivateKey).blockingGet();
String identityCert = certRepository.x509CertificateToPemString(idCert).blockingGet();
// Generate the role certificate in PEM format
......
......@@ -78,14 +78,15 @@ public class LinkRoleForServerUseCase {
String rootCert = certRepository.x509CertificateToPemString(rootCa).blockingGet();
// Generate the certificate in PEM format
X509Certificate cert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
//X509Certificate cert = certRepository.generateIdentityCertificate(device.getDeviceId(), publicKey, caPrivateKey).blockingGet();
//X509Certificate cert = certRepository.generateIdentityCertificate("*", publicKey, caPrivateKey).blockingGet();
X509Certificate cert = certRepository.generateIdentityCertificate(device.getDeviceId(), publicKey, caPrivateKey).blockingGet();
String identityCert = certRepository.x509CertificateToPemString(cert).blockingGet();
return cmsRepository.provisionIdentityCertificate(endpoint, device.getDeviceId(), rootCert, identityCert);
})
.andThen(amsRepository.provisionRoleAcl(endpoint, device.getDeviceId(), roleId, roleAuthority, new ArrayList<>(Arrays.asList("*")), 31))
.andThen(pstatRepository.changeDeviceStatus(endpoint, device.getDeviceId(), OcfDosType.OC_DOSTYPE_RFNOP)));
.andThen(amsRepository.provisionRoleAcl(endpoint, device.getDeviceId(), roleId, roleAuthority, new ArrayList<>(Arrays.asList("*")), 31))
.andThen(amsRepository.provisionConntypeAcl(endpoint, device.getDeviceId(), true, Arrays.asList("/oic/sec/roles"), 31))
.andThen(pstatRepository.changeDeviceStatus(endpoint, device.getDeviceId(), OcfDosType.OC_DOSTYPE_RFNOP)));
}
}
......@@ -29,13 +29,12 @@ import javafx.scene.control.ListView;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.encoders.Base64;
import org.openconnectivity.otgc.domain.model.resource.secure.cred.OcCredential;
import org.openconnectivity.otgc.viewmodel.TrustAnchorViewModel;
import javax.inject.Inject;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.io.*;
import java.net.URL;
import java.security.Security;
import java.security.cert.CertificateFactory;
......@@ -77,7 +76,19 @@ public class TrustAnchorView implements FxmlView<TrustAnchorViewModel>, Initiali
alert.setResizable(true);
alert.setTitle("Trust Anchor - Information");
alert.setHeaderText(null);
alert.setContentText(showX509CertificateInformation(listView.getSelectionModel().getSelectedItem().getPublicData().getDerData()));
if (listView.getSelectionModel().getSelectedItem().getPublicData().getDerData() != null) {
alert.setContentText(showX509CertificateInformation(listView.getSelectionModel().getSelectedItem().getPublicData().getDerData()));
} else if (listView.getSelectionModel().getSelectedItem().getPublicData().getPemData() != null) {
String pem = listView.getSelectionModel().getSelectedItem().getPublicData().getPemData();
String base64 = pem.replaceAll("\\s", "")
.replaceAll("\\r\\n", "")
.replace("-----BEGINCERTIFICATE-----", "")
.replace("-----ENDCERTIFICATE-----", "");
byte[] der = Base64.decode(base64.getBytes());
alert.setContentText(showX509CertificateInformation(der));
}
alert.getDialogPane().setMinWidth(600.0);
alert.showAndWait();
......
......@@ -26,6 +26,8 @@
~
-->
<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXRadioButton?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="400.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.openconnectivity.otgc.view.setting.SettingsView">
......@@ -44,8 +46,13 @@
<ColumnConstraints percentWidth="5.0" hgrow="NEVER" />
<ColumnConstraints percentWidth="35.0" hgrow="ALWAYS" />
</columnConstraints>
<!-- <rowConstraints>
<RowConstraints />
<RowConstraints />
</rowConstraints> -->
<children>
<AnchorPane GridPane.rowIndex="0" GridPane.columnIndex="0">
<!-- Row 0 : Discovery timeout-->
<!-- <AnchorPane GridPane.rowIndex="0" GridPane.columnIndex="0">
<children>
<Label text="%settings.label.discovery_timeout" alignment="CENTER"
AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="0.0"
......@@ -58,7 +65,29 @@
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="0.0" />
</children>
</AnchorPane>-->
<!-- Row 1 : Discovery scope -->
<!-- <AnchorPane GridPane.rowIndex="1" GridPane.columnIndex="0">
<children>
<Label text="%settings.label.discovery_scope" alignment="CENTER"
AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.leftAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane GridPane.rowIndex="1" GridPane.columnIndex="2">
<children>
<JFXRadioButton fx:id="linkRadioButton" selected="true" text="%settings.iotivity.radiobutton.link"
onAction="#handleDiscoveryScopeGroup">
<toggleGroup>
<ToggleGroup fx:id="toggleDiscoveryScopeGroup"/>
</toggleGroup>
</JFXRadioButton>
<JFXRadioButton fx:id="siteRadioButton" selected="false" onAction="#handleDiscoveryScopeGroup"
text="%settings.iotivity.radiobutton.site" toggleGroup="$toggleDiscoveryScopeGroup" />
<JFXRadioButton fx:id="realmRadioButton" selected="false" onAction="#handleDiscoveryScopeGroup"
text="%settings.iotivity.radiobutton.realm" toggleGroup="$toggleDiscoveryScopeGroup" />
</children>
</AnchorPane> -->
</children>
</GridPane>
</children>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment