Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 4d5b0773 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Merge branch 'development' of...

Merge branch 'development' of https://ec.europa.eu/cefdigital/code/scm/edelivery/smp into bugfix/EDELIVERY-4070-user-is-allowed-to-add-two

# Conflicts:
#	smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIUserService.java
#	smp-webapp/src/test/java/eu/europa/ec/edelivery/smp/controllers/ServiceGroupControllerTest.java
parent a6de5e67
No related branches found
No related tags found
No related merge requests found
Showing
with 678 additions and 41 deletions
......@@ -155,6 +155,10 @@ public class ServiceGroupDao extends BaseDao<DBServiceGroup> {
return cq;
}
public void updateServiceGroupDomain(DBServiceGroupDomain serviceGroupDomain) {
memEManager.merge(serviceGroupDomain);
}
}
......@@ -19,6 +19,7 @@ package eu.europa.ec.edelivery.smp.data.model;
public class CommonColumnsLengths {
public static final int MAX_DOMAIN_CODE_LENGTH = 256;
public static final int MAX_FREE_TEXT_LENGTH = 4000;
public static final int MAX_MEDIUM_TEXT_LENGTH = 1024;
public static final int MAX_PARTICIPANT_IDENTIFIER_SCHEME_LENGTH = 256;
public static final int MAX_PARTICIPANT_IDENTIFIER_VALUE_LENGTH = 256;
public static final int MAX_DOCUMENT_TYPE_IDENTIFIER_VALUE_LENGTH = 500;
......
......@@ -33,18 +33,18 @@ public class DBCertificate extends BaseEntity {
@Id
@Column(name = "ID")
Long id;
@Column(name = "CERTIFICATE_ID", length = CommonColumnsLengths.MAX_FREE_TEXT_LENGTH, unique = true)
@Column(name = "CERTIFICATE_ID", length = CommonColumnsLengths.MAX_MEDIUM_TEXT_LENGTH, unique = true)
private String certificateId;
@Column(name = "VALID_FROM")
private LocalDateTime validFrom;
@Column(name = "VALID_TO")
private LocalDateTime validTo;
@Column(name = "subject", length = CommonColumnsLengths.MAX_TEXT_LENGTH_512)
@Column(name = "SUBJECT", length = CommonColumnsLengths.MAX_MEDIUM_TEXT_LENGTH)
private String subject;
@Column(name = "issuer", length = CommonColumnsLengths.MAX_TEXT_LENGTH_512)
@Column(name = "ISSUER", length = CommonColumnsLengths.MAX_MEDIUM_TEXT_LENGTH)
private String issuer;
@Column(name = "serialNumber", length = CommonColumnsLengths.MAX_TEXT_LENGTH_128)
@Column(name = "SERIALNUMBER", length = CommonColumnsLengths.MAX_TEXT_LENGTH_128)
private String serialNumber;
......
......@@ -31,8 +31,8 @@ public enum ErrorCode {
// service group error
ILLEGAL_STATE_SG_MULTIPLE_ENTRY (500,"SMP:130",ErrorBusinessCode.TECHNICAL,"More than one service group ( part. id: %s, part. sch.: '%s') is defined in database!"),
SG_NOT_EXISTS(404,"SMP:131",ErrorBusinessCode.NOT_FOUND,"ServiceGroup not found (dpart. id: '%s', part. sch.: '%s')!"),
SG_NOT_REGISTRED_FOR_DOMAIN(400,"SMP:131",ErrorBusinessCode.NOT_FOUND,"Service group not registered for domain (domain: %s, part. id:~ '%s', part. sch.: '%s')!"),
SG_NOT_EXISTS(404,"SMP:131",ErrorBusinessCode.NOT_FOUND,"ServiceGroup not found (part. id: '%s', part. sch.: '%s')!"),
SG_NOT_REGISTRED_FOR_DOMAIN(400,"SMP:131",ErrorBusinessCode.NOT_FOUND,"Service group not registered for domain (domain: %s, part. id: '%s', part. sch.: '%s')!"),
INVALID_EXTENSION_FOR_SG (400,"SMP:132",ErrorBusinessCode.XSD_INVALID,"Invalid extension for service group (part. id: '%s', part. sch.: '%s'). Error: %s!"),
DUPLICATE_DOMAIN_FOR_SG (400,"SMP:133",ErrorBusinessCode.INVALID_INPUT_DATA,"Repeated domain for Service group (part. id: '%s', part. sch.: '%s', domainCode %s, smlDomain %s).!"),
MISSING_SG_ID (400,"SMP:134",ErrorBusinessCode.INVALID_INPUT_DATA,"Missing service group(part. id: '%s', part. sch.: '%s'!"),
......@@ -59,6 +59,7 @@ public enum ErrorCode {
INVALID_REQEUST (500,"SMP:513",ErrorBusinessCode.TECHNICAL, "Invalid request %s. Error: %s!"),
INTERNAL_ERROR (500,"SMP:514",ErrorBusinessCode.TECHNICAL, "Internal error %s. Error: %s!"),
CERTIFICATE_ERROR (500,"SMP:515",ErrorBusinessCode.TECHNICAL, "Certificate error %s. Error: %s!"),
CONFIGURATION_ERROR (500,"SMP:516",ErrorBusinessCode.TECHNICAL, "Configuration error: %s!"),
//
;
......
......@@ -30,6 +30,16 @@ public enum SMPMessageCode implements MessageCode {
BUS_SAVE_SERVICE_GROUP ("BUS-014", "Start inserting/updating ServiceGroup for domain {}, part. Id: {} part. scheme {}."),
BUS_SAVE_SERVICE_GROUP_FAILED ("BUS-015", "Inserting/updating ServiceGroup for domain {}, part. Id: {} part. scheme {} failed! Error: [{}]"),
BUS_SML_REGISTER_SERVICE_GROUP("BUS-016", "Start registering participant: part. Id: {} part. scheme {} to domain {}"),
BUS_SML_REGISTER_END_SERVICE_GROUP("BUS-017", "End registering participant: part. Id: {} part. scheme {} to domain {}"),
BUS_SML_REGISTER_SERVICE_GROUP_ALREADY_REGISTERED("BUS-018", "Participant: part. Id: {} part. scheme {} to domain {} marked as already registered to SML"),
BUS_SML_REGISTER_SERVICE_GROUP_FAILED("BUS-019", "Participant registration: part. Id: {} part. scheme {} to domain {} failed due to error: {}"),
BUS_SML_UNREGISTER_SERVICE_GROUP("BUS-020", "Start unregistering participant: part. Id: {} part. scheme {} to domain {}"),
BUS_SML_UNREGISTER_END_SERVICE_GROUP("BUS-021", "End unregistering participant: part. Id: {} part. scheme {} to domain {}"),
BUS_SML_UNREGISTER_SERVICE_GROUP_ALREADY_REGISTERED("BUS-022", "Participant: part. Id: {} part. scheme {} to domain {} marked as already unregistered to SML"),
BUS_SML_UNREGISTER_SERVICE_GROUP_FAILED("BUS-023", "Participant unregistration: part. Id: {} part. scheme {} to domain {} failed due to error: {}"),
BUS_INVALID_XML("BUS-030", "Invalid XML for {}. Error: [{}]"),
......
package eu.europa.ec.edelivery.smp.services;
import eu.europa.ec.edelivery.smp.conversion.CaseSensitivityNormalizer;
import eu.europa.ec.edelivery.smp.data.dao.DomainDao;
import eu.europa.ec.edelivery.smp.data.dao.ServiceGroupDao;
import eu.europa.ec.edelivery.smp.data.model.DBDomain;
import eu.europa.ec.edelivery.smp.data.model.DBServiceGroup;
import eu.europa.ec.edelivery.smp.data.model.DBServiceGroupDomain;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.edelivery.smp.logging.SMPMessageCode;
import eu.europa.ec.edelivery.smp.sml.SmlConnector;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ParticipantIdentifierType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.CONFIGURATION_ERROR;
import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.SG_NOT_EXISTS;
import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.SG_NOT_REGISTRED_FOR_DOMAIN;
import static eu.europa.ec.edelivery.smp.logging.SMPMessageCode.*;
/**
* Service for domain
* @author Joze Rihtarsic
* @since 4.1
*/
@Service
public class SMLIntegrationService {
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SMLIntegrationService.class);
@Autowired
private SmlConnector smlConnector;
@Autowired
private ServiceGroupDao serviceGroupDao;
@Autowired
private DomainDao domainDao;
@Autowired
private CaseSensitivityNormalizer caseSensitivityNormalizer;
/**
* Method in transaction update domain status and registers domain to SML.
* If registration fails - transaction is rolled back
* @param domain
*/
@Transactional
public void registerDomain(DBDomain domain){
if (!smlConnector.isSmlIntegrationEnabled()) {
throw new SMPRuntimeException(CONFIGURATION_ERROR, "SML integration is not enabled!");
}
if( !domain.isSmlRegistered()) {
domain.setSmlRegistered(true);
domainDao.update(domain);
smlConnector.registerDomain(domain);
}
}
/**
* Method in transaction update domain status and registers domain to SML.
* If registration fails - transaction is rolled back
* @param domain
*/
@Transactional
public void unRegisterDomain(DBDomain domain){
if (!smlConnector.isSmlIntegrationEnabled()) {
throw new SMPRuntimeException(CONFIGURATION_ERROR, "SML integration is not enabled!");
}
if( domain.isSmlRegistered()) {
domain.setSmlRegistered(false);
domainDao.update(domain);
smlConnector.unregisterDomain(domain);
}
}
/**
* Method in transaction update servicegroupDomain status and registers participant to SML.
* If registration fails - transaction is rolled back
*
* @param participantId - Participant schema
* @param participantSchema - Participant schema
* @param domainCode - register to domain
*/
@Transactional
public void registerParticipant(String participantId, String participantSchema, String domainCode){
LOG.businessDebug(BUS_SML_REGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode);
if (!smlConnector.isSmlIntegrationEnabled()) {
String msg = "SML integration is not enabled!";
LOG.businessError(BUS_SML_REGISTER_SERVICE_GROUP_FAILED, participantId, participantSchema, domainCode, msg);
throw new SMPRuntimeException(CONFIGURATION_ERROR, msg);
}
DBServiceGroupDomain serviceGroupDomain = getAndValidateServiceGroupDomain(participantId,
participantSchema, domainCode, BUS_SML_REGISTER_SERVICE_GROUP_FAILED);
ParticipantIdentifierType normalizedParticipantId = caseSensitivityNormalizer
.normalizeParticipantIdentifier(participantSchema,
participantId);
// register only not registered services
if (!serviceGroupDomain.isSmlRegistered()) {
// update value
serviceGroupDomain.setSmlRegistered(true);
serviceGroupDao.updateServiceGroupDomain(serviceGroupDomain);
smlConnector.registerInDns(normalizedParticipantId, serviceGroupDomain.getDomain());
LOG.businessDebug(BUS_SML_REGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode);
} else {
LOG.businessWarn(BUS_SML_REGISTER_SERVICE_GROUP_ALREADY_REGISTERED, participantId, participantSchema, domainCode );
}
}
/**
* Method in transaction update servicegroupDomain status and registers participant to SML.
* If registration fails - transaction is rolled back
*
* @param participantId - Participant schema
* @param participantSchema - Participant schema
* @param domainCode - register to domain
*/
@Transactional
public void unregisterParticipant(String participantId, String participantSchema, String domainCode){
LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode);
if (!smlConnector.isSmlIntegrationEnabled()) {
String msg = "SML integration is not enabled!";
LOG.businessError(BUS_SML_UNREGISTER_SERVICE_GROUP_FAILED, participantId, participantSchema, domainCode, msg);
throw new SMPRuntimeException(CONFIGURATION_ERROR, msg);
}
DBServiceGroupDomain serviceGroupDomain = getAndValidateServiceGroupDomain(participantId, participantSchema, domainCode, BUS_SML_UNREGISTER_SERVICE_GROUP_FAILED);
ParticipantIdentifierType normalizedParticipantId = caseSensitivityNormalizer
.normalizeParticipantIdentifier(participantSchema,
participantId);
// unregister only registered participants
if (serviceGroupDomain.isSmlRegistered()) {
// update value
serviceGroupDomain.setSmlRegistered(false);
serviceGroupDao.updateServiceGroupDomain(serviceGroupDomain);
smlConnector.unregisterFromDns(normalizedParticipantId, serviceGroupDomain.getDomain());
LOG.businessDebug(BUS_SML_UNREGISTER_SERVICE_GROUP, participantId, participantSchema, domainCode);
} else {
LOG.businessWarn(BUS_SML_UNREGISTER_SERVICE_GROUP_ALREADY_REGISTERED, participantId, participantSchema, domainCode );
}
}
private DBServiceGroupDomain getAndValidateServiceGroupDomain(String participantId, String participantSchema, String domainCode, SMPMessageCode messageCode) {
// retrieve participant (session must be on - lazy loading... )
Optional<DBServiceGroup> optionalServiceGroup = serviceGroupDao.findServiceGroup(participantId, participantSchema);
if (!optionalServiceGroup.isPresent()){
String msg = "Service group not exists!";
LOG.businessError(messageCode, participantId, participantId, domainCode, msg);
throw new SMPRuntimeException(SG_NOT_EXISTS, participantId, participantSchema);
}
DBServiceGroup serviceGroup = optionalServiceGroup.get();
Optional<DBServiceGroupDomain> optionalServiceGroupDomain = serviceGroup.getServiceGroupForDomain(domainCode);
if (!optionalServiceGroupDomain.isPresent()){
String msg = "Service group is not registered for domain on this SMP - register participant on domain first!";
LOG.businessError(messageCode, participantId, participantId, domainCode, msg);
throw new SMPRuntimeException(SG_NOT_REGISTRED_FOR_DOMAIN, domainCode,participantId, participantSchema );
}
return optionalServiceGroupDomain.get();
}
}
......@@ -72,7 +72,7 @@ public class SmlConnector implements ApplicationContextAware {
if (!smlIntegrationEnabled) {
return false;
}
log.info("Registering new Domain o BDMSL: (smpCode {} smp-smp-id {}) ", domain.getDomainCode(), domain.getSmlSmpId());
log.info("Registering new Domain toSML: (smpCode {} smp-smp-id {}) ", domain.getDomainCode(), domain.getSmlSmpId());
try {
ServiceMetadataPublisherServiceType smlSmpRequest = new ServiceMetadataPublisherServiceType();
smlSmpRequest.setPublisherEndpoint(new PublisherEndpointType());
......@@ -87,10 +87,10 @@ public class SmlConnector implements ApplicationContextAware {
public void unregisterFromDns(ParticipantIdentifierType normalizedParticipantId, DBDomain domain) {
if (!smlIntegrationEnabled) {
if (!smlIntegrationEnabled) {
return;
}
log.info("Removing Participant from BDMSL: " + asString(normalizedParticipantId));
log.info("Removing Participant from BDMSL: {} ", asString(normalizedParticipantId));
try {
ServiceMetadataPublisherServiceForParticipantType smlRequest = toBusdoxParticipantId(normalizedParticipantId, domain.getSmlSmpId());
getClient(domain).delete(smlRequest);
......@@ -99,6 +99,18 @@ public class SmlConnector implements ApplicationContextAware {
}
}
public void unregisterDomain(DBDomain domain) {
if (!smlIntegrationEnabled) {
return;
}
log.info("Removing SMP id (Domain) from BDMSL: {} ", domain.getDomainCode());
try {
getSMPManagerClient(domain).delete(domain.getSmlSmpId());
} catch (Exception e) {
throw new SMPRuntimeException(ErrorCode.SML_INTEGRATION_EXCEPTION,e, ExceptionUtils.getRootCauseMessage(e));
}
}
private IManageParticipantIdentifierWS getClient(DBDomain domain) {
String clientCertHttpHeader =domain.isSmlBlueCoatAuth()? domain.getSmlClientCertHeader():null;
......@@ -117,4 +129,8 @@ public class SmlConnector implements ApplicationContextAware {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ctx = applicationContext;
}
public boolean isSmlIntegrationEnabled() {
return smlIntegrationEnabled;
}
}
package eu.europa.ec.edelivery.smp.config;
public class AuthenticationTestDataHolder {
String alias;
String blueCoatHeader;
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getBlueCoatHeader() {
return blueCoatHeader;
}
public void setBlueCoatHeader(String blueCoatHeader) {
this.blueCoatHeader = blueCoatHeader;
}
}
\ No newline at end of file
package eu.europa.ec.edelivery.smp.config;
import eu.europa.ec.bdmsl.ws.soap.IManageParticipantIdentifierWS;
import eu.europa.ec.bdmsl.ws.soap.IManageServiceMetadataWS;
import eu.europa.ec.edelivery.smp.data.model.DBDomain;
import org.mockito.Mockito;
import org.oasis_open.docs.bdxr.ns.smp._2016._05.ParticipantIdentifierType;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.xml.ws.http.HTTPException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE;
@Component
public class SmlIntegrationConfiguration {
protected final ParticipantIdentifierType PARTICIPANT_ID = new ParticipantIdentifierType("sample:value", "sample:scheme");
protected DBDomain defaultDomain;
protected List<IManageServiceMetadataWS> smpManagerClientMocks = new ArrayList<>();
protected Map<IManageServiceMetadataWS, AuthenticationTestDataHolder> smpManagerClientMocksData = new HashMap<>();
protected List<IManageParticipantIdentifierWS> smlClientMocks = new ArrayList<>();
protected Map<IManageParticipantIdentifierWS, AuthenticationTestDataHolder> smlClientMocksData = new HashMap<>();
protected int throwExceptionAfterParticipantCallCount = -1;
public void reset() {
smpManagerClientMocks.clear();
smpManagerClientMocksData.clear();
smlClientMocks.clear();
smlClientMocksData.clear();
defaultDomain = new DBDomain();
defaultDomain.setDomainCode("default_domain_id");
defaultDomain.setSmlSmpId("SAMPLE-SMP-ID");
defaultDomain.setSmlRegistered(false);
defaultDomain.setSmlBlueCoatAuth(false);
defaultDomain.setSmlClientKeyAlias("clientAlias");
defaultDomain.setSmlClientCertHeader("blueCoatClientHeader");
setThrowExceptionAfterParticipantCallCount(-1);
}
@Bean
@Scope(SCOPE_PROTOTYPE)
public IManageServiceMetadataWS smpManagerClient(String clientKeyAlias, String clientCertHttpHeader) {
IManageServiceMetadataWS clientMock = Mockito.mock(IManageServiceMetadataWS.class);
AuthenticationTestDataHolder dh = new AuthenticationTestDataHolder();
dh.setAlias(clientKeyAlias);
dh.setBlueCoatHeader(clientCertHttpHeader);
smpManagerClientMocks.add(clientMock);
smpManagerClientMocksData.put(clientMock, dh);
return clientMock;
}
@Bean
@Scope(SCOPE_PROTOTYPE)
public IManageParticipantIdentifierWS smpParticipantClient(String clientKeyAlias, String clientCertHttpHeader) {
if (throwExceptionAfterParticipantCallCount >0 && throwExceptionAfterParticipantCallCount <= smlClientMocks.size()){
throw new HTTPException(400);
}
IManageParticipantIdentifierWS clientMock = Mockito.mock(IManageParticipantIdentifierWS.class);
AuthenticationTestDataHolder dh = new AuthenticationTestDataHolder();
dh.setAlias(clientKeyAlias);
dh.setBlueCoatHeader(clientCertHttpHeader);
smlClientMocks.add(clientMock);
smlClientMocksData.put(clientMock, dh);
return clientMock;
}
public ParticipantIdentifierType getParticipantId() {
return PARTICIPANT_ID;
}
public DBDomain getDefaultDomain() {
return defaultDomain;
}
public List<IManageServiceMetadataWS> getSmpManagerClientMocks() {
return smpManagerClientMocks;
}
public Map<IManageServiceMetadataWS, AuthenticationTestDataHolder> getSmpManagerClientMocksData() {
return smpManagerClientMocksData;
}
public List<IManageParticipantIdentifierWS> getParticipantManagmentClientMocks() {
return smlClientMocks;
}
public Map<IManageParticipantIdentifierWS, AuthenticationTestDataHolder> getParticipantManagmentClientMocksData() {
return smlClientMocksData;
}
public int getThrowExceptionAfterParticipantCallCount() {
return throwExceptionAfterParticipantCallCount;
}
public void setThrowExceptionAfterParticipantCallCount(int throwExceptionAfterParticipantCallCount) {
this.throwExceptionAfterParticipantCallCount = throwExceptionAfterParticipantCallCount;
}
}
......@@ -104,6 +104,6 @@ public class SMPSchemaGeneratorTest {
// given when
List<Class> result = testInstance.getAllEntityClasses(ENTITY_PACKAGE);
assertEquals(13, result.size());
assertEquals(14, result.size());
}
}
\ No newline at end of file
......@@ -71,7 +71,7 @@ public abstract class AbstractServiceIntegrationTest {
* - TEST_DOC_ID_1, TEST_DOC_SCHEMA_1
*
*
* ServiceGroup2: TEST_SG_ID_1, TEST_SG_SCHEMA_2
* ServiceGroup2: TEST_SG_ID_2, TEST_SG_SCHEMA_2
* - Domain: TEST_DOMAIN_CODE_1
* - Owners: USERNAME_1
* - Metadata: /
......
/*
* Copyright 2018 European Commission | CEF eDelivery
*
* Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
package eu.europa.ec.edelivery.smp.services;
import eu.europa.ec.bdmsl.ws.soap.BadRequestFault;
import eu.europa.ec.bdmsl.ws.soap.InternalErrorFault;
import eu.europa.ec.bdmsl.ws.soap.NotFoundFault;
import eu.europa.ec.bdmsl.ws.soap.UnauthorizedFault;
import eu.europa.ec.edelivery.smp.config.H2JPATestConfig;
import eu.europa.ec.edelivery.smp.config.SmlIntegrationConfiguration;
import eu.europa.ec.edelivery.smp.data.model.DBDomain;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
import eu.europa.ec.edelivery.smp.sml.SmlConnector;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static eu.europa.ec.edelivery.smp.testutil.TestConstants.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
/**
* Purpose of class is to test ServiceGroupService base methods
*
* @author Joze Rihtarsic
* @since 4.1
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes= {SmlIntegrationConfiguration.class,
SmlConnector.class,SMLIntegrationService.class,
H2JPATestConfig.class} )
@TestPropertySource(properties = {"bdmsl.integration.enabled=true"})
public class SMLIntegrationServiceIntegrationTest extends AbstractServiceIntegrationTest {
@Rule
public ExpectedException expectedExeption = ExpectedException.none();
@Autowired
SmlIntegrationConfiguration integrationMock;
@Autowired
protected SMLIntegrationService testInstance;
@Before
@Transactional
public void prepareDatabase() {
integrationMock.reset();
prepareDatabaseForSignleDomainEnv();
}
@Test
public void registerDomainToSml() throws UnauthorizedFault, InternalErrorFault, BadRequestFault {
// given
DBDomain testDomain01 = domainDao.getDomainByCode(TEST_DOMAIN_CODE_1).get();
assertFalse(testDomain01.isSmlRegistered());
// when
testInstance.registerDomain(testDomain01);
assertTrue(testDomain01.isSmlRegistered());
assertEquals(1, integrationMock.getSmpManagerClientMocks().size());
verify(integrationMock.getSmpManagerClientMocks().get(0)).create(any());
Mockito.verifyNoMoreInteractions(integrationMock.getSmpManagerClientMocks().toArray());
}
@Test
public void unregisterDomainToSml() throws UnauthorizedFault, InternalErrorFault, BadRequestFault, NotFoundFault {
// given
DBDomain testDomain01 = domainDao.getDomainByCode(TEST_DOMAIN_CODE_1).get();
testDomain01.setSmlRegistered(true);
// when
testInstance.unRegisterDomain(testDomain01);
assertTrue(!testDomain01.isSmlRegistered());
assertEquals(1, integrationMock.getSmpManagerClientMocks().size());
verify(integrationMock.getSmpManagerClientMocks().get(0)).delete(testDomain01.getSmlSmpId());
Mockito.verifyNoMoreInteractions(integrationMock.getSmpManagerClientMocks().toArray());
}
@Test
public void registerParticipantToSML() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault {
/* given (init database - check setup)
* Domain: TEST_DOMAIN_CODE_1
* Users: USERNAME_1, USER_CERT_2
* ServiceGroup1: TEST_SG_ID_1, TEST_SG_SCHEMA_1
* - Domain: TEST_DOMAIN_CODE_1
*/
// when
testInstance.registerParticipant(TEST_SG_ID_1,TEST_SG_SCHEMA_1,TEST_DOMAIN_CODE_1 );
//then -- expect on call
assertEquals(1, integrationMock.getParticipantManagmentClientMocks().size());
verify(integrationMock.getParticipantManagmentClientMocks().get(0)).create(any());
Mockito.verifyNoMoreInteractions(integrationMock.getParticipantManagmentClientMocks().toArray());
}
@Test
public void unRegisterParticipantFromSML() throws NotFoundFault, UnauthorizedFault, InternalErrorFault, BadRequestFault {
/* given (init database - check setup)
* Domain: TEST_DOMAIN_CODE_1
* Users: USERNAME_1, USER_CERT_2
* ServiceGroup1: TEST_SG_ID_1, TEST_SG_SCHEMA_1
* - Domain: TEST_DOMAIN_CODE_1
*/
// when
testInstance.registerParticipant(TEST_SG_ID_1,TEST_SG_SCHEMA_1,TEST_DOMAIN_CODE_1 );
//then -- expect on call
assertEquals(1, integrationMock.getParticipantManagmentClientMocks().size());
verify(integrationMock.getParticipantManagmentClientMocks().get(0)).create(any());
Mockito.verifyNoMoreInteractions(integrationMock.getParticipantManagmentClientMocks().toArray());
}
@Test
public void registerParticipantToSML_NotExists(){
expectedExeption.expect(SMPRuntimeException.class);
String notExistsId = TEST_SG_ID_1+"NotExists";
expectedExeption.expectMessage("ServiceGroup not found (part. id: '"+TEST_SG_ID_1+"NotExists', part. sch.: '"+TEST_SG_SCHEMA_1+"')!");
// when
testInstance.registerParticipant(notExistsId,TEST_SG_SCHEMA_1,TEST_DOMAIN_CODE_1 );
}
@Test
public void registerParticipantToSML_NotOnDomain(){
expectedExeption.expect(SMPRuntimeException.class);
expectedExeption.expectMessage("Service group not registered for domain (domain: "+TEST_DOMAIN_CODE_2+", part. id: '"+TEST_SG_ID_1+"', part. sch.: '"+TEST_SG_SCHEMA_1+"')!");
// when
testInstance.registerParticipant(TEST_SG_ID_1,TEST_SG_SCHEMA_1,TEST_DOMAIN_CODE_2 );
}
}
/*
* Copyright 2018 European Commission | CEF eDelivery
*
* Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence attached in file: LICENCE-EUPL-v1.2.pdf
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and limitations under the Licence.
*/
package eu.europa.ec.edelivery.smp.services;
import eu.europa.ec.edelivery.smp.data.model.DBDomain;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional;
import static eu.europa.ec.edelivery.smp.testutil.TestConstants.*;
import static org.junit.Assert.assertFalse;
/**
* Purpose of class is to test ServiceGroupService base methods
*
* @author Joze Rihtarsic
* @since 4.1
*/
@TestPropertySource(properties = {
"bdmsl.integration.enabled=false"})
@ContextConfiguration(classes = {SMLIntegrationService.class})
public class SMLIntegrationServiceNoSMLIntegrationTest extends AbstractServiceIntegrationTest {
@Rule
public ExpectedException expectedExeption = ExpectedException.none();
@Autowired
protected SMLIntegrationService testInstance;
@Before
@Transactional
public void prepareDatabase() {
prepareDatabaseForSignleDomainEnv();
}
@Test
public void registerOnlyDomainToSml() {
expectedExeption.expect(SMPRuntimeException.class);
expectedExeption.expectMessage("Configuration error: SML integration is not enabled!");
// given
DBDomain testDomain01 = domainDao.getDomainByCode(TEST_DOMAIN_CODE_1).get();
assertFalse(testDomain01.isSmlRegistered());
// when
testInstance.registerDomain(testDomain01);
}
@Test
public void unregisterOnlyDomainToSml() {
expectedExeption.expect(SMPRuntimeException.class);
expectedExeption.expectMessage("Configuration error: SML integration is not enabled!");
// given
DBDomain testDomain01 = domainDao.getDomainByCode(TEST_DOMAIN_CODE_1).get();
testDomain01.setSmlRegistered(true);
// when
testInstance.unRegisterDomain(testDomain01);
}
@Test
public void registerOnlyParticipantDomainToSml() {
expectedExeption.expect(SMPRuntimeException.class);
expectedExeption.expectMessage("Configuration error: SML integration is not enabled!");
// when
testInstance.registerParticipant(TEST_SG_ID_1, TEST_SG_SCHEMA_1, TEST_DOMAIN_CODE_1);
}
}
......@@ -17,6 +17,7 @@ public class TestDBUtils {
domain.setSmlClientCertHeader(UUID.randomUUID().toString());
domain.setSmlClientKeyAlias(UUID.randomUUID().toString());
domain.setSmlSubdomain(UUID.randomUUID().toString());
domain.setSmlSmpId(UUID.randomUUID().toString());
domain.setSmlParticipantIdentifierRegExp(UUID.randomUUID().toString());
return domain;
}
......
......@@ -43,18 +43,18 @@ update SMP_USER_SEQ set next_val=100 where next_val=1;
-- insert domain
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (1, 'domain','subdomain','sig-key', NOW(), NOW());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (2, 'domainB','subdomain002', 'CEF-SMP-002','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (3, 'domainC$$','subdomain003$$', 'CEF$$SMP-003','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (4, 'domainD','subdomain004', 'CEF-SMP-004','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (5, 'domainE','subdomain005', 'CEF-SMP-005','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (6, 'domainF','subdomain006', 'CEF-SMP-006','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (7, 'domainG','subdomain007', 'CEF-SMP-007','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (8, 'domainH','subdomain008', 'CEF-SMP-008','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (9, 'domainI','subdomain009', 'CEF-SMP-009','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (10, 'domainJ','subdomain009', 'CEF-SMP-009','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (11, 'domainJ','subdomain010', 'CEF-SMP-010','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (12, 'domainK','subdomain011', 'CEF-SMP-011','sig-key',CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (1, 'domain','','CEF-SMP-002', 'sig-key', 1,0, NOW(), NOW());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (2, 'domainB','subdomain002', 'CEF-SMP-002','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (3, 'domainC','subdomain003', 'CEF-SMP-003','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (4, 'domainD','subdomain004', 'CEF-SMP-004','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (5, 'domainE','subdomain005', 'CEF-SMP-005','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (6, 'domainF','subdomain006', 'CEF-SMP-006','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (7, 'domainG','subdomain007', 'CEF-SMP-007','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (8, 'domainH','subdomain008', 'CEF-SMP-008','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (9, 'domainI','subdomain009', 'CEF-SMP-009','sig-key',1,0, CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (10, 'domainJ','subdomain010', 'CEF-SMP-010','sig-key',1,0,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (11, 'domainK','subdomain011', 'CEF-SMP-011','sig-key',1,0,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SML_SMP_ID, SIGNATURE_KEY_ALIAS, SML_BLUE_COAT_AUTH,SML_REGISTERED, CREATED_ON, LAST_UPDATED_ON) values (12, 'domainL','subdomain012', 'CEF-SMP-012','sig-key',1,0,CURRENT_TIMESTAMP(),CURRENT_TIMESTAMP());
update SMP_DOMAIN_SEQ set next_val=100 where next_val=1;
......@@ -66,4 +66,4 @@ insert into SMP_USER (ID, USERNAME, PASSWORD, ROLE, ACTIVE, CREATED_ON, LAST_UPD
insert into SMP_CERTIFICATE (ID, CERTIFICATE_ID, VALID_FROM, VALID_TO, CREATED_ON, LAST_UPDATED_ON) values (SMP_USER_SEQ.CURRVAL, 'CN=SMP_1000000181,O=DIGIT,C=DK:123456789', null,null, sysdate, sysdate);
-- insert domain
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SIGNATURE_KEY_ALIAS, CREATED_ON, LAST_UPDATED_ON) values (SMP_DOMAIN_SEQ.nextval, 'domain','subdomain','sig-key', sysdate, sysdate);
insert into SMP_DOMAIN (ID, DOMAIN_CODE, SML_SUBDOMAIN, SIGNATURE_KEY_ALIAS,SML_BLUE_COAT_AUTH, CREATED_ON, LAST_UPDATED_ON) values (SMP_DOMAIN_SEQ.nextval, 'domain','subdomain','sig-key',1, sysdate, sysdate);
......@@ -14,12 +14,12 @@ alter table smp_user rename to SMP_USER_BCK;
create table SMP_CERTIFICATE (
ID bigint not null,
CERTIFICATE_ID varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin,
CERTIFICATE_ID varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin,
CREATED_ON datetime not null,
issuer varchar(512) CHARACTER SET utf8 COLLATE utf8_bin,
ISSUER varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin,
LAST_UPDATED_ON datetime not null,
serialNumber varchar(128) CHARACTER SET utf8 COLLATE utf8_bin,
subject varchar(512) CHARACTER SET utf8 COLLATE utf8_bin,
SERIALNUMBER varchar(128) CHARACTER SET utf8 COLLATE utf8_bin,
SUBJECT varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin,
VALID_FROM datetime,
VALID_TO datetime,
primary key (ID)
......@@ -29,12 +29,12 @@ alter table smp_user rename to SMP_USER_BCK;
ID bigint not null,
REV bigint not null,
REVTYPE tinyint,
CERTIFICATE_ID varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin,
CERTIFICATE_ID varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin,
CREATED_ON datetime,
issuer varchar(512) CHARACTER SET utf8 COLLATE utf8_bin,
ISSUER varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin,
LAST_UPDATED_ON datetime,
serialNumber varchar(128) CHARACTER SET utf8 COLLATE utf8_bin,
subject varchar(512) CHARACTER SET utf8 COLLATE utf8_bin,
SERIALNUMBER varchar(128) CHARACTER SET utf8 COLLATE utf8_bin,
SUBJECT varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin,
VALID_FROM datetime,
VALID_TO datetime,
primary key (ID, REV)
......@@ -51,6 +51,8 @@ alter table smp_user rename to SMP_USER_BCK;
SML_PARTC_IDENT_REGEXP varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin,
SML_SMP_ID varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
SML_SUBDOMAIN varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
SML_REGISTERED bit,
SML_BLUE_COAT_AUTH bit;
primary key (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
......@@ -67,6 +69,8 @@ alter table smp_user rename to SMP_USER_BCK;
SML_PARTC_IDENT_REGEXP varchar(4000) CHARACTER SET utf8 COLLATE utf8_bin,
SML_SMP_ID varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
SML_SUBDOMAIN varchar(256) CHARACTER SET utf8 COLLATE utf8_bin,
SML_REGISTERED bit,
SML_BLUE_COAT_AUTH bit;
primary key (ID, REV)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
......@@ -127,7 +131,7 @@ alter table smp_user rename to SMP_USER_BCK;
ID bigint not null auto_increment,
CREATED_ON datetime not null,
LAST_UPDATED_ON datetime not null,
SML_REGISTRED bit not null,
SML_REGISTERED bit not null,
FK_DOMAIN_ID bigint,
FK_SG_ID bigint,
primary key (ID)
......@@ -139,7 +143,7 @@ alter table smp_user rename to SMP_USER_BCK;
REVTYPE tinyint,
CREATED_ON datetime,
LAST_UPDATED_ON datetime,
SML_REGISTRED bit,
SML_REGISTERED bit,
FK_DOMAIN_ID bigint,
FK_SG_ID bigint,
primary key (ID, REV)
......@@ -277,7 +281,7 @@ INSERT INTO SMP_SG_EXTENSION (ID, CREATED_ON, LAST_UPDATED_ON, EXTENSION)
and sg.PARTICIPANT_SCHEME= sgb.businessidentifierscheme WHERE sgb.xmlcontent != '';
-- insert service group domains
INSERT INTO SMP_SERVICE_GROUP_DOMAIN ( CREATED_ON, LAST_UPDATED_ON, SML_REGISTRED, FK_DOMAIN_ID, FK_SG_ID )
INSERT INTO SMP_SERVICE_GROUP_DOMAIN ( CREATED_ON, LAST_UPDATED_ON, SML_REGISTERED, FK_DOMAIN_ID, FK_SG_ID )
select NOW(), NOW(), 0, D.ID, SG.ID from SMP_SERVICE_GROUP_BCK SGB INNER JOIN SMP_SERVICE_GROUP SG ON
SGB.businessidentifier = SG.PARTICIPANT_IDENTIFIER
and SGB.businessidentifierscheme = SG.PARTICIPANT_SCHEME
......@@ -313,6 +317,10 @@ INSERT INTO SMP_OWNERSHIP (FK_SG_ID, FK_USER_ID)
-- we do not need certificate DN in USERNAME so remove it from username columns
UPDATE SMP_USER set USERNAME=null where PASSWORD ='';
UPDATE SMP_DOMAIN set SML_REGISTERED=0 where SML_REGISTERED IS NULL;
UPDATE SMP_DOMAIN set SML_BLUE_COAT_AUTH=0 where SML_BLUE_COAT_AUTH IS NULL;
-- --------------------------------------------------------------------------------------------------------
-- update sequences and remove auto_increment
-- --------------------------------------------------------------------------------------------------------
......
......@@ -5,7 +5,7 @@ ALTER TABLE SMP_DOMAIN_AUD ADD SML_REGISTERED bit;
ALTER TABLE SMP_DOMAIN ADD SML_BLUE_COAT_AUTH bit;
ALTER TABLE SMP_DOMAIN_AUD ADD SML_BLUE_COAT_AUTH bit;
UPDATE SMP_DOMAIN set SML_REGISTRED=0 where SML_REGISTERED IS NULL;
UPDATE SMP_DOMAIN set SML_REGISTERED=0 where SML_REGISTERED IS NULL;
UPDATE SMP_DOMAIN set SML_BLUE_COAT_AUTH=0 where SML_BLUE_COAT_AUTH IS NULL;
......@@ -13,6 +13,18 @@ UPDATE SMP_DOMAIN set SML_BLUE_COAT_AUTH=0 where SML_BLUE_COAT_AUTH IS NULL;
ALTER TABLE SMP_SERVICE_GROUP_DOMAIN CHANGE COLUMN SML_REGISTRED SML_REGISTERED bit;
ALTER TABLE SMP_SERVICE_GROUP_DOMAIN_AUD CHANGE COLUMN SML_REGISTRED SML_REGISTERED bit;
ALTER TABLE SMP_CERTIFICATE CHANGE COLUMN CERTIFICATE_ID CERTIFICATE_ID varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE_AUD COLUMN CERTIFICATE_ID CERTIFICATE_ID varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE COLUMN subject SUBJECT varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE_AUD COLUMN subject SUBJECT varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE COLUMN issuer ISSUER varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE_AUD COLUMN issuer ISSUER varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE COLUMN serialNumber SERIALNUMBER varchar(128) CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE SMP_CERTIFICATE CHANGE_AUD COLUMN serialNumber SERIALNUMBER varchar(128) CHARACTER SET utf8 COLLATE utf8_bin;
-- generate configuration table
create table SMP_CONFIGURATION (
PROPERTY varchar(512) CHARACTER SET utf8 COLLATE utf8_bin not null,
......
......@@ -57,6 +57,8 @@ create sequence SMP_USER_SEQ start with 1 increment by 50;
SML_PARTC_IDENT_REGEXP varchar2(4000 char),
SML_SMP_ID varchar2(256 char),
SML_SUBDOMAIN varchar2(256 char),
SML_REGISTERED number(1,0),
SML_BLUE_COAT_AUTH number(1,0),
primary key (ID)
);
......@@ -73,9 +75,20 @@ create sequence SMP_USER_SEQ start with 1 increment by 50;
SML_PARTC_IDENT_REGEXP varchar2(4000 char),
SML_SMP_ID varchar2(256 char),
SML_SUBDOMAIN varchar2(256 char),
SML_REGISTERED number(1,0),
SML_BLUE_COAT_AUTH number(1,0),
primary key (ID, REV)
);
create table SMP_CONFIGURATION (
PROPERTY varchar2(512 char) not null,
CREATED_ON timestamp not null,
DESCRIPTION varchar2(4000 char),
LAST_UPDATED_ON timestamp not null,
VALUE varchar2(4000 char),
primary key (PROPERTY)
);
create table SMP_OWNERSHIP (
FK_SG_ID number(19,0) not null,
FK_USER_ID number(19,0) not null,
......@@ -122,7 +135,7 @@ create sequence SMP_USER_SEQ start with 1 increment by 50;
ID number(19,0) not null,
CREATED_ON timestamp not null,
LAST_UPDATED_ON timestamp not null,
SML_REGISTRED number(1,0) not null,
SML_REGISTERED number(1,0) not null,
FK_DOMAIN_ID number(19,0),
FK_SG_ID number(19,0),
primary key (ID)
......@@ -134,7 +147,7 @@ create sequence SMP_USER_SEQ start with 1 increment by 50;
REVTYPE number(3,0),
CREATED_ON timestamp,
LAST_UPDATED_ON timestamp,
SML_REGISTRED number(1,0),
SML_REGISTERED number(1,0),
FK_DOMAIN_ID number(19,0),
FK_SG_ID number(19,0),
primary key (ID, REV)
......@@ -340,8 +353,8 @@ create index SMP_SMD_DOC_SCH_IDX on SMP_SERVICE_METADATA (DOCUMENT_SCHEME);
-- migrate domains
INSERT INTO SMP_DOMAIN (ID, DOMAIN_CODE, SIGNATURE_KEY_ALIAS,SML_CLIENT_CERT_HEADER, SML_PARTC_IDENT_REGEXP, SML_SMP_ID, SML_SUBDOMAIN, LAST_UPDATED_ON, CREATED_ON )
SELECT SMP_DOMAIN_SEQ.nextval, DOMAINID, SIGNATURECERTALIAS, BDMSLCLIENTCERTHEADER, '', BDMSLSMPID,'', sysdate, sysdate
INSERT INTO SMP_DOMAIN (ID,SML_BLUE_COAT_AUTH,SML_REGISTERED, DOMAIN_CODE, SIGNATURE_KEY_ALIAS,SML_CLIENT_CERT_HEADER, SML_PARTC_IDENT_REGEXP, SML_SMP_ID, SML_SUBDOMAIN, LAST_UPDATED_ON, CREATED_ON )
SELECT SMP_DOMAIN_SEQ.nextval,0,0, DOMAINID, SIGNATURECERTALIAS, BDMSLCLIENTCERTHEADER, '', BDMSLSMPID,'', sysdate, sysdate
FROM SMP_DOMAIN_BCK;
-- migrate users
......@@ -362,7 +375,7 @@ INSERT INTO SMP_SG_EXTENSION (ID, CREATED_ON, LAST_UPDATED_ON, EXTENSION)
and sg.PARTICIPANT_SCHEME= sgb.BUSINESSIDENTIFIERSCHEME and sgb.extension is not null;
-- insert service group domains
INSERT INTO SMP_SERVICE_GROUP_DOMAIN (ID, CREATED_ON, LAST_UPDATED_ON, SML_REGISTRED, FK_DOMAIN_ID, FK_SG_ID )
INSERT INTO SMP_SERVICE_GROUP_DOMAIN (ID, CREATED_ON, LAST_UPDATED_ON, SML_REGISTERED, FK_DOMAIN_ID, FK_SG_ID )
select SMP_SERVICE_GROUP_DOMAIN_SEQ.nextval, sysdate, sysdate, 0, D.ID, SG.ID from SMP_SERVICE_GROUP_BCK SGB, SMP_SERVICE_GROUP SG, SMP_DOMAIN D WHERE
SGB.BUSINESSIDENTIFIER = SG.PARTICIPANT_IDENTIFIER
and SGB.BUSINESSIDENTIFIERSCHEME = SG.PARTICIPANT_SCHEME
......
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