Skip to content
Snippets Groups Projects
Commit e7974294 authored by Felix Sidokhine's avatar Felix Sidokhine
Browse files

improved device Id detection

parent 116727a0
No related branches found
No related tags found
No related merge requests found
......@@ -31,11 +31,14 @@ public class DeviceBuilder {
device.getCertificationRequest().getSubjectPublicKeyInfo()
);
device.setCertificate(CertificateSigner.signCertificate(user.getPrivateKey(),builder, ExtensionLibrary.deviceExtensions));
boolean deviceIdDetected = false;
for(int i=0; i < device.getCertificationRequest().getSubject().getRDNs().length;i++) {
if(device.getCertificationRequest().getSubject().getRDNs()[i].getFirst().getType().equals(DEVICE_ID_FIELD)){
device.setDeviceId(device.getCertificationRequest().getSubject().getRDNs()[i].getFirst().getValue().toString());
deviceIdDetected = true;
}
}
if(!deviceIdDetected) return null;
//kill off the certification request it's useless.
device.setCertificationRequest(null);
return device;
......
......@@ -30,6 +30,10 @@ public class RegisterDeviceFlow {
device.setOwner(username);
device.setDisplayName(registrationRequest.getDeviceName());
device = certificateAuthority.getSignedCertificate(user, device);
if(device == null){
log.error("Could not succesfully create a device certificate!");
return null;
}
dataStore.getDeviceDao().storeObject(device);
//Now we build this response out.
DeviceRegistrationResponse response = new DeviceRegistrationResponse();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment