diff --git a/README.md b/README.md index 95fd60362144b3306b6d953580f174122a08f5a4..70263b2550f704d4fee99d637c9f3647161d2825 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,67 @@ # Service Metadata Publishing -## Continuous Integration +[](https://ec.europa.eu/digital-building-blocks/wikis/download/attachments/52601883/eupl_v1.2_en%20.pdf?version=1&modificationDate=1507206778126&api=v2) +[](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/SMP) +[](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/Support+eDelivery) -[https://webgate.ec.europa.eu/CITnet/bamboo/browse/EDELIVERY-SMPDEV] + +## Introduction -## Building SMP -SMP requires Maven 3.6+ and Java 1.8. +This is the code repository for eDelivery SMP, the sample implementation, open source project of the European Commission [eDelivery SMP profile](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/SMP+specifications) implementation. - -## Source code history -This is a continuation of CIPA SMP Joinup repository, which was migrated here to GIT on 07.12.2016: -[https://joinup.ec.europa.eu/svn/cipaedelivery/trunk] +Any feedback on the application or the following documentation is highly welcome, including bugs, typos +or things you think should be included but aren't. You can use [JIRA](https://ec.europa.eu/digital-building-blocks/tracker/projects/EDELIVERY/issues) to provide feedback. -## Build SMP -Step 1: +Following documents are available on the [Domibus release page](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/SMP): +* Administration Guide +* Software Architecture Document +* Interface Control Documents -mvn clean install +[Top](#top) +## Overall description -## Execute integartion tests -By default integrations tests are executes on H2 database. -Any remote DB with preconfigured schema might be used as well. Sample build command: +To successfully send a business document in a (4-corner) network, an entity must be able to discover critical metadata about +the recipient (Access Point) of the business document, such as types of documents the Access Point is capable of receiving +and methods of transport supported. The recipient makes this metadata available to other entities in the network through +a Service Metadata Publisher service. The eDelivery SMP profile describes the request/response exchanges between a +Service Metadata Publisher and a client wishing to discover Access Point metadata. The profile is based on the +OASIS Service Metadata Publishing (SMP) Version 1.0 standard. - mvn clean install \ - -Djdbc.driver=oracle.jdbc.OracleDriver \ - -Djdbc.url=jdbc:oracle:thin:<HOST_AND_PORT_AND_SERVICENAME> \ - -Djdbc.user=<USERNAME> \ - -Djdbc.password=<PASSWORD> \ - -Dtarget-database=Oracle \ - -Djdbc.read-connections.max=10 \ No newline at end of file +The eDelivery SMP application is an implementation of the eDelivery SMP profile. The application also has a feature to +configure the integration to SML using [PEPPOL Transport Infrastructure SML specifications](https://docs.peppol.eu/edelivery/sml/ICT-Transport-SML_Service_Specification-101.pdf). + +eDelivery SMP is the Open Source project of the AS4 Access Point maintained by the European Commission. + +If this is your first contact with the eDelivery SMP, it is highly recommended to check the [SMP Software](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/SMP+software) page. + +[Top](#top) + +## Build + +In order to build eDelivery SMP : + + mvn clean install + + +[Top](#top) + +## Install and run + +How to install and run eDelivery SMP can be read in the Admin Guide available on the [eDelivery SMP Release Page](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/SMP+software). + +[Top](#top) + +## License + +eDelivery SMP is licensed under European Union Public Licence (EUPL) version 1.2. + +[Top](#top) + +## Support + +Have questions? Consult our [Q&A section](https://ec.europa.eu/digital-building-blocks/wikis/display/DIGITAL/SMP+FAQs). +Still have questions? Contact [eDelivery support](https://ec.europa.eu/digital-building-blocks/tracker/plugins/servlet/desk/portal/6). + + +[Top](#top) \ No newline at end of file diff --git a/smp-angular/src/app/common/dialogs/password-change-dialog/password-change-dialog.component.ts b/smp-angular/src/app/common/dialogs/password-change-dialog/password-change-dialog.component.ts index 5c3bc59c4f3f441de9caec8fe82098ec24201c05..3794e363ffca4b49ec98761623c86801807a4ed8 100644 --- a/smp-angular/src/app/common/dialogs/password-change-dialog/password-change-dialog.component.ts +++ b/smp-angular/src/app/common/dialogs/password-change-dialog/password-change-dialog.component.ts @@ -135,7 +135,6 @@ export class PasswordChangeDialogComponent { // logout if changed for itself this.securityService.finalizeLogout(result); } - close(); }) } diff --git a/smp-angular/src/app/user/user-details-dialog/user-details.service.ts b/smp-angular/src/app/user/user-details-dialog/user-details.service.ts index a65074ec6f4a2ae801d9c1bd400a89d442d889d2..344b7e1c9eaf4d5ffc1e63852c7d5582f2885df9 100644 --- a/smp-angular/src/app/user/user-details-dialog/user-details.service.ts +++ b/smp-angular/src/app/user/user-details-dialog/user-details.service.ts @@ -39,7 +39,6 @@ export class UserDetailsService { }); } - REST_INTERNAL_USER_CHANGE_PASSWORD /** * Submit request to regenerated request token! diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyEnum.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyEnum.java index b08f0334009e99085576ed6cbbbea29884bb78fe..6d6b2e2e9cad3a53ead56a344941d213b5edb65d 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyEnum.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyEnum.java @@ -5,6 +5,7 @@ import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.regex.Pattern; import java.util.stream.Collectors; import static eu.europa.ec.edelivery.smp.data.ui.enums.SMPPropertyTypeEnum.*; @@ -131,18 +132,23 @@ public enum SMPPropertyEnum { ALERT_USER_LOGIN_FAILURE_ENABLED("smp.alert.user.login_failure.enabled", "false", "Enable/disable the login failure alert of the authentication module.", false, false,false, BOOLEAN), ALERT_USER_LOGIN_FAILURE_LEVEL("smp.alert.user.login_failure.level", - "LOW", "Alert level for login failure.", false, false,false, STRING), + "LOW", "Alert level for login failure. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_USER_LOGIN_FAILURE_MAIL_SUBJECT("smp.alert.user.login_failure.mail.subject", - "Login failure", "Login failure mail subject. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "Login failure", "Login failure mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_USER_SUSPENDED_ENABLED("smp.alert.user.suspended.enabled", "true", "Enable/disable the login suspended alert of the authentication module.", false, false,false, BOOLEAN), ALERT_USER_SUSPENDED_LEVEL("smp.alert.user.suspended.level", - "HIGH", "Alert level for login suspended. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "HIGH", "Alert level for login suspended. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_USER_SUSPENDED_MAIL_SUBJECT("smp.alert.user.suspended.mail.subject", - "Login credentials suspended", "Login suspended mail subject.", false, false,false, STRING), + "Login credentials suspended", "Login suspended mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character"), ALERT_USER_SUSPENDED_MOMENT("smp.alert.user.suspended.mail.moment", - "WHEN_BLOCKED", "#When should the account disabled alert be triggered. Values: AT_LOGON: An alert will be triggered each time a user tries to login to a disabled account. WHEN_BLOCKED: An alert will be triggered once when the account got suspended.", false, false,false, STRING), + "WHEN_BLOCKED", "When should the account disabled alert be triggered. Values: AT_LOGON: An alert will be triggered each time a user tries to login and fail to account. WHEN_BLOCKED: An alert will be triggered once when the account got suspended.", + false, false,false, STRING, "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_PASSWORD_BEFORE_EXPIRATION_ENABLED("smp.alert.password.imminent_expiration.enabled", "true", "Enable/disable the imminent password expiration alert", false, false,false, BOOLEAN), @@ -151,9 +157,11 @@ public enum SMPPropertyEnum { ALERT_PASSWORD_BEFORE_EXPIRATION_INTERVAL("smp.alert.password.imminent_expiration.frequency_days", "5", "Interval between alerts.", false, false,false, INTEGER), ALERT_PASSWORD_BEFORE_EXPIRATION_LEVEL("smp.alert.password.imminent_expiration.level", - "LOW", "Password imminent expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "LOW", "Password imminent expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_PASSWORD_BEFORE_EXPIRATION_MAIL_SUBJECT("smp.alert.password.imminent_expiration.mail.subject", - "Password imminent expiration", "Password imminent expiration mail subject.", false, false,false, STRING), + "Password imminent expiration", "Password imminent expiration mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_PASSWORD_EXPIRED_ENABLED("smp.alert.password.expired.enabled", "true", "Enable/disable the password expiration alert", false, false,false, BOOLEAN), @@ -162,9 +170,11 @@ public enum SMPPropertyEnum { ALERT_PASSWORD_EXPIRED_INTERVAL("smp.alert.password.expired.frequency_days", "5", "Frequency in days between alerts.", false, false,false, INTEGER), ALERT_PASSWORD_EXPIRED_LEVEL("smp.alert.password.expired.level", - "LOW", "Password expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "LOW", "Password expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_PASSWORD_EXPIRED_MAIL_SUBJECT("smp.alert.password.expired.mail.subject", - "Password expired", "Password expiration mail subject.", false, false,false, STRING), + "Password expired", "Password expiration mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_ACCESS_TOKEN_BEFORE_EXPIRATION_ENABLED("smp.alert.accessToken.imminent_expiration.enabled", "true", "Enable/disable the imminent accessToken expiration alert", false, false,false, BOOLEAN), @@ -173,9 +183,11 @@ public enum SMPPropertyEnum { ALERT_ACCESS_TOKEN_BEFORE_EXPIRATION_INTERVAL("smp.alert.accessToken.imminent_expiration.frequency_days", "5", "Frequency in days between alerts.", false, false,false, INTEGER), ALERT_ACCESS_TOKEN_BEFORE_EXPIRATION_LEVEL("smp.alert.accessToken.imminent_expiration.level", - "LOW", "AccessToken imminent expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "LOW", "AccessToken imminent expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_ACCESS_TOKEN_BEFORE_EXPIRATION_MAIL_SUBJECT("smp.alert.accessToken.imminent_expiration.mail.subject", - "Access token imminent expiration", "accessToken imminent expiration mail subject.", false, false,false, STRING), + "Access token imminent expiration", "accessToken imminent expiration mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_ACCESS_TOKEN_EXPIRED_ENABLED("smp.alert.accessToken.expired.enabled", "true", "Enable/disable the accessToken expiration alert", false, false,false, BOOLEAN), @@ -184,9 +196,11 @@ public enum SMPPropertyEnum { ALERT_ACCESS_TOKEN_EXPIRED_INTERVAL("smp.alert.accessToken.expired.frequency_days", "5", "Frequency in days between alerts.", false, false,false, INTEGER), ALERT_ACCESS_TOKEN_EXPIRED_LEVEL("smp.alert.accessToken.expired.level", - "LOW", "Access Token expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "LOW", "Access Token expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_ACCESS_TOKEN_EXPIRED_MAIL_SUBJECT("smp.alert.accessToken.expired.mail.subject", - "Access token expired", "Password expiration mail subject.", false, false,false, STRING), + "Access token expired", "Password expiration mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_CERTIFICATE_BEFORE_EXPIRATION_ENABLED("smp.alert.certificate.imminent_expiration.enabled", "true", "Enable/disable the imminent certificate expiration alert", false, false,false, BOOLEAN), @@ -195,9 +209,11 @@ public enum SMPPropertyEnum { ALERT_CERTIFICATE_BEFORE_EXPIRATION_INTERVAL("smp.alert.certificate.imminent_expiration.frequency_days", "5", "Frequency in days between alerts.", false, false,false, INTEGER), ALERT_CERTIFICATE_BEFORE_EXPIRATION_LEVEL("smp.alert.certificate.imminent_expiration.level", - "LOW", "certificate imminent expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "LOW", "certificate imminent expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_CERTIFICATE_BEFORE_EXPIRATION_MAIL_SUBJECT("smp.alert.certificate.imminent_expiration.mail.subject", - "Certificate imminent expiration", "Certificate imminent expiration mail subject.", false, false,false, STRING), + "Certificate imminent expiration", "Certificate imminent expiration mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), ALERT_CERTIFICATE_EXPIRED_ENABLED("smp.alert.certificate.expired.enabled", "true", "Enable/disable the certificate expiration alert", false, false,false, BOOLEAN), @@ -206,9 +222,11 @@ public enum SMPPropertyEnum { ALERT_CERTIFICATE_EXPIRED_INTERVAL("smp.alert.certificate.expired.frequency_days", "5", "Frequency in days between alerts.", false, false,false, INTEGER), ALERT_CERTIFICATE_EXPIRED_LEVEL("smp.alert.certificate.expired.level", - "LOW", "Certificate expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING), + "LOW", "Certificate expiration alert level. Values: {LOW, MEDIUM, HIGH}", false, false,false, STRING, + "^(LOW|MEDIUM|HIGH)$", "Allowed values are: LOW, MEDIUM, HIGH"), ALERT_CERTIFICATE_EXPIRED_MAIL_SUBJECT("smp.alert.certificate.expired.mail.subject", - "Certificate expired", "Password expiration mail subject.", false, false,false, STRING), + "Certificate expired", "Certificate expiration mail subject.", false, false,false, STRING, + "^(.{0,255})$", "Subject must have less than 256 character" ), SMP_ALERT_CREDENTIALS_CRON("smp.alert.credentials.cronJobExpression", "0 52 4 */1 * *", "Property cron expression for triggering alert messages !", false, false, false, CRON_EXPRESSION), SMP_ALERT_CREDENTIALS_SERVER("smp.alert.credentials.serverInstance", "localhost", "If smp.cluster.enabled is set to true then then instance (hostname) to generate report.", false, false, false, STRING), @@ -221,14 +239,16 @@ public enum SMPPropertyEnum { String property; String defValue; String desc; - String valuePattern; + Pattern valuePattern; + String errorValueMessage; boolean isEncrypted; boolean isMandatory; boolean restartNeeded; SMPPropertyTypeEnum propertyType; - SMPPropertyEnum(String property, String defValue, String desc, boolean isMandatory, boolean isEncrypted, boolean restartNeeded, SMPPropertyTypeEnum propertyType,String valuePattern) { + SMPPropertyEnum(String property, String defValue, String desc, boolean isMandatory, boolean isEncrypted, boolean restartNeeded, + SMPPropertyTypeEnum propertyType,String valuePattern,String errorValueMessage ) { this.property = property; this.defValue = defValue; this.desc = desc; @@ -236,11 +256,12 @@ public enum SMPPropertyEnum { this.isMandatory = isMandatory; this.restartNeeded = restartNeeded; this.propertyType = propertyType; - this.valuePattern = valuePattern; + this.valuePattern = Pattern.compile(valuePattern); + this.errorValueMessage = errorValueMessage; } SMPPropertyEnum(String property, String defValue, String desc, boolean isMandatory, boolean isEncrypted, boolean restartNeeded, SMPPropertyTypeEnum propertyType) { - this(property, defValue, desc, isMandatory, isEncrypted, restartNeeded, propertyType, propertyType.errorTemplate); + this(property, defValue, desc, isMandatory, isEncrypted, restartNeeded, propertyType, propertyType.defValidationRegExp, propertyType.getErrorMessage(property)); } @@ -284,9 +305,13 @@ public enum SMPPropertyEnum { return Arrays.asList(values()).stream().filter(val -> val.isRestartNeeded()).collect(Collectors.toList()); } - public String getValuePattern() { + public Pattern getValuePattern() { return valuePattern; } + + public String getErrorValueMessage() { + return this.errorValueMessage; + } } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyTypeEnum.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyTypeEnum.java index 37daae439b6a6b132b990ba961aca619582fa076..c05c65c324040ee79862a9480049cc405bfaf064 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyTypeEnum.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/enums/SMPPropertyTypeEnum.java @@ -1,7 +1,7 @@ package eu.europa.ec.edelivery.smp.data.ui.enums; public enum SMPPropertyTypeEnum { - STRING (".{0,2000}","Property [%s] is not valid String type!"), + STRING (".{0,2000}","Property value [%s] must be less than 2000 characters!"), LIST_STRING(".{0,2000}","Property [%s] is not valid LIST_STRING type!"), MAP_STRING(".{0,2000}","Property [%s] is not valid MAP_STRING type!"), INTEGER("\\d{0,12}","Property [%s] is not valid Integer!"), diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/utils/PropertyUtils.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/utils/PropertyUtils.java index c4633cee29897b335cab699878832ee8aa207b38..0415740cacfdf6506215d582f19436520a0f63a2 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/utils/PropertyUtils.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/utils/PropertyUtils.java @@ -42,6 +42,10 @@ public class PropertyUtils { } return null; } + if (!prop.getValuePattern().matcher(value).find()) { + LOG.debug("Value [{}] for property [{}] does not match [{}]", value, prop.getProperty(), prop.getValuePattern().pattern()); + throw new SMPRuntimeException(ErrorCode.CONFIGURATION_ERROR, prop.getErrorValueMessage()); + } SMPPropertyTypeEnum type = prop.getPropertyType(); return parsePropertyType(type, value, rootFolder); @@ -52,6 +56,13 @@ public class PropertyUtils { // empty/ null value is invalid return !prop.isMandatory(); } + if (value == null) { + return true; + } + if (!prop.getValuePattern().matcher(value).matches()) { + LOG.debug("Value [{}] for property [{}] does not match [{}]", value, prop.getProperty(), prop.getValuePattern().pattern()); + throw new SMPRuntimeException(ErrorCode.CONFIGURATION_ERROR, prop.getErrorValueMessage()); + } SMPPropertyTypeEnum type = prop.getPropertyType(); return isValidPropertyType(type, value, confFolder); } @@ -64,7 +75,7 @@ public class PropertyUtils { parsePropertyType(type, value, confFolder); return true; } catch (SMPRuntimeException ex) { - LOG.debug("Invalid property value [{}] for type [{}]. Error: " , value, type, ExceptionUtils.getRootCauseMessage(ex)); + LOG.debug("Invalid property value [{}] for type [{}]. Error: ", value, type, ExceptionUtils.getRootCauseMessage(ex)); return false; } } @@ -75,12 +86,12 @@ public class PropertyUtils { } if (StringUtils.length(value) > 2000) { - throw new SMPRuntimeException(ErrorCode.CONFIGURATION_ERROR, "Invalid property value! Error: Value to long. Max. allowed size 200O characters!"); + throw new SMPRuntimeException(ErrorCode.CONFIGURATION_ERROR, "Invalid property value! Error: Value to long. Max. allowed size 2000 characters!"); } switch (type) { case BOOLEAN: - if(StringUtils.equalsAnyIgnoreCase(trim(value),"true","false")) { + if (StringUtils.equalsAnyIgnoreCase(trim(value), "true", "false")) { return Boolean.valueOf(value.trim()); } throw new SMPRuntimeException(ErrorCode.CONFIGURATION_ERROR, "Invalid boolean value: [" @@ -125,7 +136,7 @@ public class PropertyUtils { case FILENAME: File file = new File(rootFolder, value); if (!file.exists()) { - LOG.warn("File: [{}] does not exist. Full path: [{}].",value, file.getAbsolutePath()); + LOG.warn("File: [{}] does not exist. Full path: [{}].", value, file.getAbsolutePath()); } return file; case EMAIL: diff --git a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/utils/PropertyUtilsTest.java b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/utils/PropertyUtilsTest.java index 71d0246229078ec2673e97dbb09d6306e6d68c03..8e800808121683a9a8fb73bffcdf00610a748e69 100644 --- a/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/utils/PropertyUtilsTest.java +++ b/smp-server-library/src/test/java/eu/europa/ec/edelivery/smp/utils/PropertyUtilsTest.java @@ -123,6 +123,25 @@ public class PropertyUtilsTest { } } + @Test + public void testSubjectRegExpLength() { + SMPRuntimeException result = assertThrows(SMPRuntimeException.class, () -> + PropertyUtils.isValidProperty(ALERT_USER_LOGIN_FAILURE_MAIL_SUBJECT, + "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ROOT_FOLDER)); + + assertEquals("Configuration error: Subject must have less than 256 character!", result.getMessage()); + } + + + @Test + public void testSubjectRegExpValue() { + SMPRuntimeException result = assertThrows(SMPRuntimeException.class, () -> + PropertyUtils.isValidProperty(ALERT_USER_SUSPENDED_LEVEL, + "value", ROOT_FOLDER)); + + assertEquals("Configuration error: Allowed values are: LOW, MEDIUM, HIGH!", result.getMessage()); + } + @Test @Parameters(method = "testTypeValues") diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProvider.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProvider.java index 85f162d383133f8c38616540b79eb0e7a642edb8..10ec21b497c5653a8ca9d3b61809dfe5a0c0870f 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProvider.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProvider.java @@ -348,6 +348,7 @@ public class SMPAuthenticationProvider implements AuthenticationProvider { mUserDao.update(user); } catch (java.lang.IllegalArgumentException ex) { // password is not hashed + loginAttemptForAccessTokenFailed(user, startTime); LOG.securityWarn(SMPMessageCode.SEC_INVALID_PASSWORD, ex, authenticationTokenId); throw new BadCredentialsException(LOGIN_FAILED_MESSAGE); } diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProviderForUI.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProviderForUI.java index 052722e1936b1472b8a7cbc5434d84b2f357a340..516f3a0bf47ee54e2d4a53f05a5fe912eb73d295 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProviderForUI.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/auth/SMPAuthenticationProviderForUI.java @@ -126,6 +126,7 @@ public class SMPAuthenticationProviderForUI implements AuthenticationProvider { mUserDao.update(user); } catch (IllegalArgumentException ex) { // password is not hashed; + loginAttemptForUserFailed(user, startTime); LOG.securityWarn(SMPMessageCode.SEC_INVALID_PASSWORD, ex, username); throw new BadCredentialsException("Login failed; Invalid userID or password"); } @@ -184,7 +185,7 @@ public class SMPAuthenticationProviderForUI implements AuthenticationProvider { } // check if the last failed attempt is already expired. If yes just clear the attempts if (configurationService.getLoginSuspensionTimeInSeconds() != null && configurationService.getLoginSuspensionTimeInSeconds() > 0 - && ChronoUnit.SECONDS.between( user.getLastFailedLoginAttempt(),OffsetDateTime.now()) > configurationService.getLoginSuspensionTimeInSeconds()) { + && ChronoUnit.SECONDS.between(user.getLastFailedLoginAttempt(), OffsetDateTime.now()) > configurationService.getLoginSuspensionTimeInSeconds()) { LOG.warn("User [{}] suspension is expired! Clear failed login attempts and last failed login attempt", user.getUsername()); user.setLastFailedLoginAttempt(null); user.setSequentialLoginFailureCount(0);