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

Fix setting content of metadata of issued certificate #78

Merged
merged 1 commit into from
Apr 18, 2024
Merged
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 @@ -89,9 +89,9 @@ public CertificateDataResponseDto issueCertificate(String uuid, CertificateSignR

certificate.setMeta(getIssueMetadata(
username,
AttributeDefinitionUtils.getSingleItemAttributeContentValue(CertificateControllerImpl.ATTRIBUTE_EMAIL, request.getRaProfileAttributes(), StringAttributeContent.class).getData(),
AttributeDefinitionUtils.getSingleItemAttributeContentValue(CertificateControllerImpl.ATTRIBUTE_SAN, request.getRaProfileAttributes(), StringAttributeContent.class).getData(),
AttributeDefinitionUtils.getSingleItemAttributeContentValue(CertificateControllerImpl.ATTRIBUTE_EXTENSION, request.getRaProfileAttributes(), StringAttributeContent.class).getData()
AttributeDefinitionUtils.getSingleItemAttributeContentValue(CertificateControllerImpl.ATTRIBUTE_EMAIL, request.getAttributes(), StringAttributeContent.class).getData(),
AttributeDefinitionUtils.getSingleItemAttributeContentValue(CertificateControllerImpl.ATTRIBUTE_SAN, request.getAttributes(), StringAttributeContent.class).getData(),
AttributeDefinitionUtils.getSingleItemAttributeContentValue(CertificateControllerImpl.ATTRIBUTE_EXTENSION, request.getAttributes(), StringAttributeContent.class).getData()
));

return certificate;
Expand Down Expand Up @@ -182,52 +182,58 @@ private List<MetadataAttribute> getIssueMetadata(String username, String email,
attributes.addAll(getUsernameMetadata(username));

// EMAIL
MetadataAttribute emailAttribute = new MetadataAttribute();
emailAttribute.setUuid("b42ab942-60fd-11ed-9b6a-0242ac120002");
emailAttribute.setName(META_EMAIL);
emailAttribute.setDescription("Email");
emailAttribute.setType(AttributeType.META);
emailAttribute.setContentType(AttributeContentType.STRING);
emailAttribute.setContent(List.of(new StringAttributeContent(email)));

MetadataAttributeProperties emailAttributeProperties = new MetadataAttributeProperties();
emailAttributeProperties.setVisible(true);
emailAttributeProperties.setLabel("Email");
emailAttribute.setProperties(emailAttributeProperties);

attributes.add(emailAttribute);
if (StringUtils.isNotBlank(email)) {
MetadataAttribute emailAttribute = new MetadataAttribute();
emailAttribute.setUuid("b42ab942-60fd-11ed-9b6a-0242ac120002");
emailAttribute.setName(META_EMAIL);
emailAttribute.setDescription("Email");
emailAttribute.setType(AttributeType.META);
emailAttribute.setContentType(AttributeContentType.STRING);
emailAttribute.setContent(List.of(new StringAttributeContent(email)));

MetadataAttributeProperties emailAttributeProperties = new MetadataAttributeProperties();
emailAttributeProperties.setVisible(true);
emailAttributeProperties.setLabel("Email");
emailAttribute.setProperties(emailAttributeProperties);

attributes.add(emailAttribute);
}

// SAN Attribute
MetadataAttribute sanAttribute = new MetadataAttribute();
sanAttribute.setUuid("b42abc58-60fd-11ed-9b6a-0242ac120002");
sanAttribute.setName(META_SAN);
sanAttribute.setDescription("SAN");
sanAttribute.setType(AttributeType.META);
sanAttribute.setContentType(AttributeContentType.STRING);
sanAttribute.setContent(List.of(new StringAttributeContent(san)));

MetadataAttributeProperties sanAttributeProperties = new MetadataAttributeProperties();
sanAttributeProperties.setVisible(true);
sanAttributeProperties.setLabel("SAN");
sanAttribute.setProperties(sanAttributeProperties);

attributes.add(sanAttribute);
if (StringUtils.isNotBlank(san)) {
MetadataAttribute sanAttribute = new MetadataAttribute();
sanAttribute.setUuid("b42abc58-60fd-11ed-9b6a-0242ac120002");
sanAttribute.setName(META_SAN);
sanAttribute.setDescription("SAN");
sanAttribute.setType(AttributeType.META);
sanAttribute.setContentType(AttributeContentType.STRING);
sanAttribute.setContent(List.of(new StringAttributeContent(san)));

MetadataAttributeProperties sanAttributeProperties = new MetadataAttributeProperties();
sanAttributeProperties.setVisible(true);
sanAttributeProperties.setLabel("SAN");
sanAttribute.setProperties(sanAttributeProperties);

attributes.add(sanAttribute);
}

//Extension
MetadataAttribute extensionAttribute = new MetadataAttribute();
extensionAttribute.setUuid("b42abe38-60fd-11ed-9b6a-0242ac120002");
extensionAttribute.setName(META_EXTENSION);
extensionAttribute.setDescription("Extension");
extensionAttribute.setType(AttributeType.META);
extensionAttribute.setContentType(AttributeContentType.STRING);
extensionAttribute.setContent(List.of(new StringAttributeContent(extensions)));

MetadataAttributeProperties extensionAttributeProperties = new MetadataAttributeProperties();
extensionAttributeProperties.setVisible(true);
extensionAttributeProperties.setLabel("Extension");
extensionAttribute.setProperties(extensionAttributeProperties);

attributes.add(extensionAttribute);
if (StringUtils.isNotBlank(extensions)) {
MetadataAttribute extensionAttribute = new MetadataAttribute();
extensionAttribute.setUuid("b42abe38-60fd-11ed-9b6a-0242ac120002");
extensionAttribute.setName(META_EXTENSION);
extensionAttribute.setDescription("Extension");
extensionAttribute.setType(AttributeType.META);
extensionAttribute.setContentType(AttributeContentType.STRING);
extensionAttribute.setContent(List.of(new StringAttributeContent(extensions)));

MetadataAttributeProperties extensionAttributeProperties = new MetadataAttributeProperties();
extensionAttributeProperties.setVisible(true);
extensionAttributeProperties.setLabel("Extension");
extensionAttribute.setProperties(extensionAttributeProperties);

attributes.add(extensionAttribute);
}

return attributes;
}
Expand Down Expand Up @@ -339,7 +345,7 @@ public CertificateIdentificationResponseDto identifyCertificate(String uuid, Cer
} else { // check the properties of the certificate
CertificateRestResponseV2 certificate = response.getCertificates().get(0);
if (certificate.getEndEntityProfileId() == endEntityProfile.getId() &&
certificate.getCertificateProfileId() == certificateProfile.getId()
certificate.getCertificateProfileId() == certificateProfile.getId()
// we do not need to check the CA, as it should be already checked by the RA Profile
// TODO: check the end entity profile for all attributes that are not present in CertificateRestResponseV2
// certificate.getSendNotifications() == sendNotifications &&
Expand Down