|
@@ -6,37 +6,19 @@ const logger = require('../logger');
|
|
|
const nantum = require('../modules/nantum');
|
|
const nantum = require('../modules/nantum');
|
|
|
|
|
|
|
|
async function registerParty(
|
|
async function registerParty(
|
|
|
- obj,
|
|
|
|
|
|
|
+ oadrCreatePartyRegistration,
|
|
|
clientCertificateCn,
|
|
clientCertificateCn,
|
|
|
clientCertificateFingerprint,
|
|
clientCertificateFingerprint,
|
|
|
) {
|
|
) {
|
|
|
logger.info(
|
|
logger.info(
|
|
|
'registerParty',
|
|
'registerParty',
|
|
|
- obj,
|
|
|
|
|
|
|
+ oadrCreatePartyRegistration,
|
|
|
clientCertificateCn,
|
|
clientCertificateCn,
|
|
|
clientCertificateFingerprint,
|
|
clientCertificateFingerprint,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- const requestVenId = obj.venId;
|
|
|
|
|
-
|
|
|
|
|
- if (!requestVenId) {
|
|
|
|
|
- const error = new Error('No VenID in request');
|
|
|
|
|
- error.responseCode = 452;
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (requestVenId !== clientCertificateFingerprint) {
|
|
|
|
|
- // as per certification item #512, venId MUST be case-sensitive
|
|
|
|
|
- const error = new Error('VenID does not match certificate');
|
|
|
|
|
- error.responseCode = 452;
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!clientCertificateCn) {
|
|
|
|
|
- const error = new Error('Could not determine CN from client certificate');
|
|
|
|
|
- error.responseCode = 452;
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const requestVenId = oadrCreatePartyRegistration.venId;
|
|
|
|
|
+ validateVenId(requestVenId, clientCertificateFingerprint, true);
|
|
|
|
|
|
|
|
let nantumRegistration = await nantum.fetchRegistration(requestVenId);
|
|
let nantumRegistration = await nantum.fetchRegistration(requestVenId);
|
|
|
|
|
|
|
@@ -62,13 +44,13 @@ async function registerParty(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return nantumRegistrationToOadrRegistrationCreated(
|
|
return nantumRegistrationToOadrRegistrationCreated(
|
|
|
- obj.requestId,
|
|
|
|
|
|
|
+ oadrCreatePartyRegistration.requestId,
|
|
|
nantumRegistration,
|
|
nantumRegistration,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function query(obj, clientCertificateCn, clientCertificateFingerprint) {
|
|
|
|
|
- logger.info('query', obj, clientCertificateCn, clientCertificateFingerprint);
|
|
|
|
|
|
|
+async function query(oadrQueryRegistration, clientCertificateCn, clientCertificateFingerprint) {
|
|
|
|
|
+ logger.info('query', oadrQueryRegistration, clientCertificateCn, clientCertificateFingerprint);
|
|
|
|
|
|
|
|
const requestVenId = clientCertificateFingerprint;
|
|
const requestVenId = clientCertificateFingerprint;
|
|
|
|
|
|
|
@@ -86,47 +68,27 @@ async function query(obj, clientCertificateCn, clientCertificateFingerprint) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return nantumRegistrationToOadrRegistrationCreated(
|
|
return nantumRegistrationToOadrRegistrationCreated(
|
|
|
- obj.requestId,
|
|
|
|
|
|
|
+ oadrQueryRegistration.requestId,
|
|
|
nantumRegistration,
|
|
nantumRegistration,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function cancelParty(
|
|
async function cancelParty(
|
|
|
- obj,
|
|
|
|
|
|
|
+ oadrCancelPartyRegistration,
|
|
|
clientCertificateCn,
|
|
clientCertificateCn,
|
|
|
clientCertificateFingerprint,
|
|
clientCertificateFingerprint,
|
|
|
) {
|
|
) {
|
|
|
logger.info(
|
|
logger.info(
|
|
|
'cancelParty',
|
|
'cancelParty',
|
|
|
- obj,
|
|
|
|
|
|
|
+ oadrCancelPartyRegistration,
|
|
|
clientCertificateCn,
|
|
clientCertificateCn,
|
|
|
clientCertificateFingerprint,
|
|
clientCertificateFingerprint,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- const registrationId = obj.registrationId;
|
|
|
|
|
- if (!registrationId) {
|
|
|
|
|
- const error = new Error('No registrationID in request');
|
|
|
|
|
- error.responseCode = 452;
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const requestVenId = obj.venId;
|
|
|
|
|
-
|
|
|
|
|
- if (requestVenId && requestVenId !== clientCertificateFingerprint) {
|
|
|
|
|
- // as per certification item #512, venId MUST be case-sensitive
|
|
|
|
|
- const error = new Error('VenID does not match certificate');
|
|
|
|
|
- error.responseCode = 452;
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const requestVenId = oadrCancelPartyRegistration.venId;
|
|
|
|
|
+ validateVenId(requestVenId, clientCertificateFingerprint, false);
|
|
|
const venId = clientCertificateFingerprint;
|
|
const venId = clientCertificateFingerprint;
|
|
|
|
|
|
|
|
- if (!clientCertificateCn) {
|
|
|
|
|
- const error = new Error('Could not determine CN from client certificate');
|
|
|
|
|
- error.responseCode = 452;
|
|
|
|
|
- throw error;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
let nantumRegistration = await nantum.fetchRegistration(requestVenId);
|
|
let nantumRegistration = await nantum.fetchRegistration(requestVenId);
|
|
|
let cancelledRegistrationId;
|
|
let cancelledRegistrationId;
|
|
|
|
|
|
|
@@ -154,7 +116,7 @@ async function cancelParty(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
- responseRequestId: obj.requestId || '',
|
|
|
|
|
|
|
+ responseRequestId: oadrCancelPartyRegistration.requestId || '',
|
|
|
responseCode: '200',
|
|
responseCode: '200',
|
|
|
responseDescription: 'OK',
|
|
responseDescription: 'OK',
|
|
|
venId: venId,
|
|
venId: venId,
|
|
@@ -177,6 +139,23 @@ function nantumRegistrationToOadrRegistrationCreated(
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function validateVenId(requestVenId, clientCertificateFingerprint, required) {
|
|
|
|
|
+ if (requestVenId === clientCertificateFingerprint) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!required && requestVenId == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (required && requestVenId == null) {
|
|
|
|
|
+ const error = new Error('VenID is missing');
|
|
|
|
|
+ error.responseCode = 452;
|
|
|
|
|
+ throw error;
|
|
|
|
|
+ }
|
|
|
|
|
+ const error = new Error('VenID is invalid');
|
|
|
|
|
+ error.responseCode = 452;
|
|
|
|
|
+ throw error;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
cancelParty,
|
|
cancelParty,
|
|
|
query,
|
|
query,
|