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

feat: Introduce globalconf V3 as extensible, i.e. capability to add new optional elements without breaking backwards compatibility #1894

Merged
merged 1 commit into from
Dec 12, 2023
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
2 changes: 1 addition & 1 deletion src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ ij_java_imports_layout = ee.ria.xroad.**,|,*,|,javax.**,|,java.**,|,$*
ij_java_class_count_to_use_import_on_demand = 999
ij_java_names_count_to_use_import_on_demand = 999

[{*.xml, *.xsd, *.gradle}]
[*.{xml,xsd,gradle}]
indent_size = 4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ConfigurationAnchorType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ConfigurationSourceType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ObjectFactory;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersTypeV3;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
Expand All @@ -43,7 +43,8 @@ interface PrivateParametersV3Converter {
PrivateParametersV3Converter INSTANCE = Mappers.getMapper(PrivateParametersV3Converter.class);

@Mapping(source = "configurationAnchors", target = "configurationAnchor")
PrivateParametersType convert(PrivateParameters parameters);
@Mapping(target = "any", ignore = true)
PrivateParametersTypeV3 convert(PrivateParameters parameters);

@Mapping(source = "sources", target = "source")
ConfigurationAnchorType convertAnchor(PrivateParameters.ConfigurationAnchor configurationAnchor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ SharedParametersTypeV3 convert(SharedParameters sharedParameters) {
@Mapping(source = "securityServers", target = "securityServer")
@Mapping(source = "globalGroups", target = "globalGroup")
@Mapping(target = "centralService", ignore = true)
@Mapping(target = "any", ignore = true)
abstract SharedParametersTypeV3 convert(SharedParameters sharedParameters,
@Context Map<ClientId, Object> clientMap);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ConfigurationAnchorType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ConfigurationSourceType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ManagementServiceType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersTypeV3;
import ee.ria.xroad.common.identifier.ClientId;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -73,7 +73,7 @@ private static PrivateParameters getPrivateParameters() {
return privateParameters;
}

private static void assertPrivateParameters(PrivateParametersType privateParameters) {
private static void assertPrivateParameters(PrivateParametersTypeV3 privateParameters) {
assertAll(
() -> assertThat(privateParameters).isNotNull(),
() -> assertThat(privateParameters.getInstanceIdentifier()).isEqualTo(INSTANCE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ void shouldConvertAllFields() throws IOException, OperatorCreationException {
"members.subsystems.id",
"centralService"
)
.withEqualsForFields((a, b) ->
new BigInteger(a.toString()).compareTo(new BigInteger(b.toString())) == 0,
.withEqualsForFields((a, b) -> new BigInteger(a.toString()).compareTo(new BigInteger(b.toString())) == 0,
"globalSettings.ocspFreshnessSeconds")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ void shouldConvertAllFields() throws IOException, OperatorCreationException {
"members.id",
"members.subsystems.id",
"centralService",
"sources.internalVerificationCerts",
"sources.externalVerificationCerts"
"any"
)
.withEqualsForFields((a, b) ->
new BigInteger(a.toString()).compareTo(new BigInteger(b.toString())) == 0,
.withEqualsForFields((a, b) -> new BigInteger(a.toString()).compareTo(new BigInteger(b.toString())) == 0,
"globalSettings.ocspFreshnessSeconds")
.build();

Expand Down
30 changes: 15 additions & 15 deletions src/common/common-util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ task xjc() {
binding: 'src/main/resources/identifiers-bindings.xml'
)

// Generate classes for federateable global external conf v3
ant.xjc(
destdir: project.ext.schemaTargetDir,
package: 'ee.ria.xroad.common.conf.globalconf.sharedparameters.v3',
schema: 'src/main/resources/globalconf/v3/shared-parameters.xsd',
binding: 'src/main/resources/identifiers-bindings.xml'
)

// Generate classes for federateable global internal conf v3
ant.xjc(
destdir: project.ext.schemaTargetDir,
package: 'ee.ria.xroad.common.conf.globalconf.privateparameters.v3',
schema: 'src/main/resources/globalconf/v2/private-parameters.xsd',
binding: 'src/main/resources/identifiers-bindings.xml'
)
// Generate classes for federateable global external conf v3
ant.xjc(
destdir: project.ext.schemaTargetDir,
package: 'ee.ria.xroad.common.conf.globalconf.sharedparameters.v3',
schema: 'src/main/resources/globalconf/v3/shared-parameters.xsd',
binding: 'src/main/resources/identifiers-bindings.xml'
)

// Generate classes for federateable global internal conf v3
ant.xjc(
destdir: project.ext.schemaTargetDir,
package: 'ee.ria.xroad.common.conf.globalconf.privateparameters.v3',
schema: 'src/main/resources/globalconf/v3/private-parameters.xsd',
binding: 'src/main/resources/identifiers-bindings.xml'
)

// Generate classes for request, using identifier classes
ant.xjc(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import ee.ria.xroad.common.conf.AbstractXmlConf;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ObjectFactory;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersTypeV3;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
Expand All @@ -40,7 +40,7 @@
/**
* Contains private parameters of a configuration instance.
*/
public class PrivateParametersV3 extends AbstractXmlConf<PrivateParametersType> implements PrivateParametersProvider {
public class PrivateParametersV3 extends AbstractXmlConf<PrivateParametersTypeV3> implements PrivateParametersProvider {
private static final JAXBContext JAXB_CONTEXT = createJAXBContext();

private final PrivateParametersV3Converter converter = new PrivateParametersV3Converter();
Expand All @@ -57,14 +57,14 @@ public class PrivateParametersV3 extends AbstractXmlConf<PrivateParametersType>


PrivateParametersV3(byte[] content) {
super(content, PrivateParametersSchemaValidatorV2.class);
super(content, PrivateParametersSchemaValidatorV3.class);
expiresOn = OffsetDateTime.MAX;
privateParameters = converter.convert(confType);
initCompleted = true;
}

PrivateParametersV3(Path privateParametersPath, OffsetDateTime expiresOn) {
super(privateParametersPath.toString(), PrivateParametersSchemaValidatorV2.class);
super(privateParametersPath.toString(), PrivateParametersSchemaValidatorV3.class);
this.expiresOn = expiresOn;
privateParameters = converter.convert(confType);
initCompleted = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ConfigurationAnchorType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.ConfigurationSourceType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersType;
import ee.ria.xroad.common.conf.globalconf.privateparameters.v3.PrivateParametersTypeV3;

import static java.util.stream.Collectors.toList;

public class PrivateParametersV3Converter {

PrivateParameters convert(PrivateParametersType source) {
PrivateParameters convert(PrivateParametersTypeV3 source) {
var target = new PrivateParameters();
target.setInstanceIdentifier(source.getInstanceIdentifier());
target.setTimeStampingIntervalSeconds(source.getTimeStampingIntervalSeconds());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,78 @@
xmlns:id="http://x-road.eu/xsd/identifiers"
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://x-road.eu/xsd/xroad.xsd">
<import namespace="http://x-road.eu/xsd/identifiers" schemaLocation="../../identifiers.xsd" id="id"/>

<complexType name="ManagementServiceType">
<sequence>
<element name="authCertRegServiceAddress" type="string">
<annotation>
<documentation>
Address of the authentication certificate registration service that can be called by the
security servers.
</documentation>
</annotation>
</element>
<element name="authCertRegServiceCert" type="base64Binary"
minOccurs="0">
<annotation>
<documentation>
Server certificate that is used to authenticate TLS connection to the authentication
certificate registration service.
</documentation>
</annotation>
</element>
<element name="managementRequestServiceProviderId"
type="id:XRoadClientIdentifierType">
<annotation>
<documentation>
Identifier of the X-Road member or subsystem providing the management request services.
</documentation>
</annotation>
</element>
</sequence>
</complexType>
<import namespace="http://x-road.eu/xsd/identifiers" schemaLocation="../../identifiers.xsd" id="id"/>

<complexType name="ConfigurationAnchorType">
<sequence>
<element name="generatedAt" minOccurs="0" type="dateTime">
<annotation>
<documentation>Date when this anchor was produced
</documentation>
</annotation>
</element>
<element name="instanceIdentifier" type="string">
<annotation>
<documentation>
Code of the X-Road instance that provides configuration to this configuration source.
</documentation>
</annotation>
</element>
<element name="source" type="tns:ConfigurationSourceType"
maxOccurs="unbounded">
<annotation>
<documentation>
Describes one configuration source.
</documentation>
</annotation>
</element>
</sequence>
</complexType>
<complexType name="ManagementServiceType">
<sequence>
<element name="authCertRegServiceAddress" type="string">
<annotation>
<documentation>
Address of the authentication certificate registration service that can be called by the
security servers.
</documentation>
</annotation>
</element>
<element name="authCertRegServiceCert" type="base64Binary" minOccurs="0">
<annotation>
<documentation>
Server certificate that is used to authenticate TLS connection to the authentication
certificate registration service.
</documentation>
</annotation>
</element>
<element name="managementRequestServiceProviderId" type="id:XRoadClientIdentifierType">
<annotation>
<documentation>
Identifier of the X-Road member or subsystem providing the management request services.
</documentation>
</annotation>
</element>
</sequence>
</complexType>

<complexType name="ConfigurationSourceType">
<sequence>
<element name="downloadURL" type="string">
<annotation>
<documentation>
HTTP URL that can be used to download signed configuration.
</documentation>
</annotation>
</element>
<element name="verificationCert" type="base64Binary"
maxOccurs="unbounded">
<annotation>
<documentation>
Public key that can be used to verify the signed configuration, presented as X.509 certificate.
</documentation>
</annotation>
</element>
</sequence>
</complexType>
<complexType name="ConfigurationAnchorType">
<sequence>
<element name="generatedAt" minOccurs="0" type="dateTime">
<annotation>
<documentation>Date when this anchor was produced
</documentation>
</annotation>
</element>
<element name="instanceIdentifier" type="string">
<annotation>
<documentation>
Code of the X-Road instance that provides configuration to this configuration source.
</documentation>
</annotation>
</element>
<element name="source" type="tns:ConfigurationSourceType" maxOccurs="unbounded">
<annotation>
<documentation>
Describes one configuration source.
</documentation>
</annotation>
</element>
</sequence>
</complexType>

<complexType name="ConfigurationSourceType">
<sequence>
<element name="downloadURL" type="string">
<annotation>
<documentation>
HTTP URL that can be used to download signed configuration.
</documentation>
</annotation>
</element>
<element name="verificationCert" type="base64Binary" maxOccurs="unbounded">
<annotation>
<documentation>
Public key that can be used to verify the signed configuration, presented as X.509 certificate.
</documentation>
</annotation>
</element>
</sequence>
</complexType>
</schema>
Loading
Loading