digestItems = new ArrayList<>();
switch (operationName) {
- case "login":
- case "login_sca":
- digestItems.add("login");
- break;
-
- case "authorize_payment":
- case "authorize_payment_sca":
+ case "login", "login_sca" -> digestItems.add("login");
+ case "authorize_payment", "authorize_payment_sca" -> {
switch (authMethod) {
- case LOGIN_SCA:
- digestItems.add("login");
- break;
-
- case APPROVAL_SCA:
- case SMS_KEY:
- case POWERAUTH_TOKEN:
+ case LOGIN_SCA -> digestItems.add("login");
+ case APPROVAL_SCA, SMS_KEY, POWERAUTH_TOKEN -> {
AmountAttribute amountAttribute = operationValueExtractionService.getAmount(operationContext);
String account = operationValueExtractionService.getAccount(operationContext);
BigDecimal amount = amountAttribute.getAmount();
@@ -87,16 +75,13 @@ public AuthorizationCode generateAuthorizationCode(String userId, String organiz
digestItems.add(amount.toPlainString());
digestItems.add(currency);
digestItems.add(account);
- break;
-
- default:
- throw new InvalidOperationContextException("Unsupported authentication method: " + authMethod);
+ }
+ default -> throw new InvalidOperationContextException("Unsupported authentication method: " + authMethod);
}
- break;
+ }
// Add new operations here.
- default:
- throw new InvalidOperationContextException("Unsupported operation: " + operationName);
+ default -> throw new InvalidOperationContextException("Unsupported operation: " + operationName);
}
final DataDigest.Result digestResult = new DataDigest().generateDigest(digestItems);
@@ -115,46 +100,36 @@ public AuthorizationCode generateAuthorizationCode(String userId, String organiz
* @param lang Language for localization.
* @return Generated SMS text with authorization code.
* @throws InvalidOperationContextException Thrown when operation context is invalid.
- * @throws DataAdapterRemoteException Thrown when remote communication fails.
*/
- public String generateSmsText(String userId, String organizationId, AuthMethod authMethod, OperationContext operationContext, AuthorizationCode authorizationCode, String lang) throws InvalidOperationContextException, DataAdapterRemoteException {
+ public String generateSmsText(String userId, String organizationId, AuthMethod authMethod, OperationContext operationContext, AuthorizationCode authorizationCode, String lang) throws InvalidOperationContextException {
String operationName = operationContext.getName();
String[] messageArgs;
String messageResourcePrefix;
switch (operationName) {
- case "login":
- case "login_sca":
+ case "login", "login_sca" -> {
messageResourcePrefix = "login";
- messageArgs = new String[]{authorizationCode.getCode()};
- break;
-
- case "authorize_payment":
- case "authorize_payment_sca":
+ messageArgs = new String[]{authorizationCode.code()};
+ }
+ case "authorize_payment", "authorize_payment_sca" -> {
switch (authMethod) {
- case LOGIN_SCA:
+ case LOGIN_SCA -> {
messageResourcePrefix = "login";
- messageArgs = new String[]{authorizationCode.getCode()};
- break;
-
- case APPROVAL_SCA:
- case SMS_KEY:
- case POWERAUTH_TOKEN:
+ messageArgs = new String[]{authorizationCode.code()};
+ }
+ case APPROVAL_SCA, SMS_KEY, POWERAUTH_TOKEN -> {
messageResourcePrefix = "authorize_payment";
AmountAttribute amountAttribute = operationValueExtractionService.getAmount(operationContext);
String account = operationValueExtractionService.getAccount(operationContext);
BigDecimal amount = amountAttribute.getAmount();
String currency = amountAttribute.getCurrency();
- messageArgs = new String[]{amount.toPlainString(), currency, account, authorizationCode.getCode()};
- break;
-
- default:
- throw new InvalidOperationContextException("Unsupported authentication method: " + authMethod);
+ messageArgs = new String[]{amount.toPlainString(), currency, account, authorizationCode.code()};
+ }
+ default -> throw new InvalidOperationContextException("Unsupported authentication method: " + authMethod);
}
- break;
+ }
// Add new operations here.
- default:
- throw new InvalidOperationContextException("Unsupported operation: " + operationName);
+ default -> throw new InvalidOperationContextException("Unsupported operation: " + operationName);
}
return dataAdapterI18NService.messageSource().getMessage(messageResourcePrefix + ".smsText", messageArgs, new Locale(lang));
@@ -167,10 +142,8 @@ public String generateSmsText(String userId, String organizationId, AuthMethod a
* @param messageId Message ID.
* @param messageText Text of SMS message.
* @param operationContext Operation context.
- * @throws InvalidOperationContextException Thrown when operation context is invalid.
- * @throws DataAdapterRemoteException Thrown when remote communication fails or SMS message could not be delivered.
*/
- public SmsDeliveryResult sendAuthorizationSms(String userId, String organizationId, String messageId, String messageText, OperationContext operationContext) throws InvalidOperationContextException, DataAdapterRemoteException {
+ public SmsDeliveryResult sendAuthorizationSms(String userId, String organizationId, String messageId, String messageText, OperationContext operationContext) {
// Add here code to send the SMS OTP message to user identified by userId with messageText.
// The message entity can be extracted using message ID from table da_sms_authorization.
// In case message delivery fails, throw a DataAdapterRemoteException.
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthMethodRequestValidator.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthMethodRequestValidator.java
index 20774a46..067f94bc 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthMethodRequestValidator.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthMethodRequestValidator.java
@@ -28,7 +28,7 @@
/**
* Defines validations for input fields in authentication method requests.
- *
+ *
* Additional validation logic can be added if applicable.
*
* @author Roman Strobl, roman.strobl@wultra.com
@@ -62,7 +62,7 @@ public boolean supports(@NonNull Class> clazz) {
*/
@Override
public void validate(@Nullable Object o, @NonNull Errors errors) {
- ObjectRequest objectRequest = (ObjectRequest) o;
+ final ObjectRequest> objectRequest = (ObjectRequest>) o;
if (objectRequest == null) {
errors.rejectValue(OPERATION_CONTEXT_FIELD, MISSING_OPERATION_CONTEXT_ERROR_CODE);
return;
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthenticationRequestValidator.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthenticationRequestValidator.java
index f50c1ba8..ae3025b9 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthenticationRequestValidator.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthenticationRequestValidator.java
@@ -30,7 +30,7 @@
/**
* Defines validations for input fields in user lookup and authentication requests.
- *
+ *
* Additional validation logic can be added if applicable.
*
* @author Roman Strobl, roman.strobl@wultra.com
@@ -60,7 +60,7 @@ public boolean supports(@NonNull Class> clazz) {
*/
@Override
public void validate(@Nullable Object o, @NonNull Errors errors) {
- ObjectRequest objectRequest = (ObjectRequest) o;
+ final ObjectRequest> objectRequest = (ObjectRequest>) o;
if (objectRequest == null) {
errors.rejectValue(OPERATION_CONTEXT_FIELD, MISSING_OPERATION_CONTEXT_ERROR_CODE);
return;
@@ -72,7 +72,7 @@ public void validate(@Nullable Object o, @NonNull Errors errors) {
}
}
- private void validateUserLookupRequest(ObjectRequest objectRequest, Errors errors) {
+ private void validateUserLookupRequest(ObjectRequest> objectRequest, Errors errors) {
UserLookupRequest authRequest = (UserLookupRequest) objectRequest.getRequestObject();
// update validation logic based on the real Data Adapter requirements
@@ -98,7 +98,7 @@ private void validateUserLookupRequest(ObjectRequest objectRequest, Errors error
}
}
- private void validateUserAuthenticationRequest(ObjectRequest objectRequest, Errors errors) {
+ private void validateUserAuthenticationRequest(ObjectRequest> objectRequest, Errors errors) {
UserAuthenticationRequest authRequest = (UserAuthenticationRequest) objectRequest.getRequestObject();
// update validation logic based on the real Data Adapter requirements
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthorizationSmsRequestValidator.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthorizationSmsRequestValidator.java
index 3d79e220..f803ce7f 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthorizationSmsRequestValidator.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/AuthorizationSmsRequestValidator.java
@@ -34,7 +34,7 @@
/**
* Validator for SMS OTP authorization requests.
- *
+ *
* Additional validation logic can be added if applicable.
*
* @author Roman Strobl, roman.strobl@wultra.com
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/CertificateRequestValidator.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/CertificateRequestValidator.java
index 19e5d3e9..9200d0ba 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/CertificateRequestValidator.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/CertificateRequestValidator.java
@@ -26,7 +26,7 @@
/**
* Validator for certificate verification requests.
- *
+ *
* Additional validation logic can be added if applicable.
*
* @author Roman Strobl, roman.strobl@wultra.com
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/ConsentFormRequestValidator.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/ConsentFormRequestValidator.java
index fb736a5b..8d598cf1 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/ConsentFormRequestValidator.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/impl/validation/ConsentFormRequestValidator.java
@@ -33,7 +33,7 @@
/**
* Validator for request to create OAuth 2.0 consent form.
- *
+ *
* Additional validation logic can be added if applicable.
*
* @author Roman Strobl, roman.strobl@wultra.com
@@ -61,7 +61,7 @@ public boolean supports(@NonNull Class> clazz) {
@Override
@SuppressWarnings("unchecked")
public void validate(@Nullable Object o, @NonNull Errors errors) {
- ObjectRequest objectRequest = (ObjectRequest) o;
+ final ObjectRequest> objectRequest = (ObjectRequest>) o;
if (objectRequest == null) {
errors.rejectValue("requestObject.operationContext", "operationContext.missing");
return;
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/repository/model/entity/SmsAuthorizationEntity.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/repository/model/entity/SmsAuthorizationEntity.java
index c40dea6f..d813dfd2 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/repository/model/entity/SmsAuthorizationEntity.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/repository/model/entity/SmsAuthorizationEntity.java
@@ -15,10 +15,12 @@
*/
package io.getlime.security.powerauth.app.dataadapter.repository.model.entity;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+
+import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
@@ -31,6 +33,7 @@
@Table(name = "da_sms_authorization")
public class SmsAuthorizationEntity implements Serializable {
+ @Serial
private static final long serialVersionUID = 6432269422572862762L;
@Id
diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/service/SmsPersistenceService.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/service/SmsPersistenceService.java
index 27dd93c6..98e6295a 100644
--- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/service/SmsPersistenceService.java
+++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/service/SmsPersistenceService.java
@@ -70,8 +70,8 @@ public SmsAuthorizationEntity createAuthorizationSms(String userId, String organ
smsEntity.setUserId(userId);
smsEntity.setOrganizationId(organizationId);
smsEntity.setOperationName(operationContext.getName());
- smsEntity.setAuthorizationCode(authorizationCode.getCode());
- smsEntity.setSalt(authorizationCode.getSalt());
+ smsEntity.setAuthorizationCode(authorizationCode.code());
+ smsEntity.setSalt(authorizationCode.salt());
smsEntity.setMessageText(messageText);
smsEntity.setVerifyRequestCount(0);
smsEntity.setTimestampCreated(new Date());
@@ -96,7 +96,7 @@ public SmsAuthorizationEntity createAuthorizationSms(String userId, String organ
public VerifySmsAuthorizationResponse verifyAuthorizationSms(String messageId, String authorizationCode, boolean allowMultipleVerifications) {
Optional smsEntityOptional = smsAuthorizationRepository.findById(messageId);
VerifySmsAuthorizationResponse response = new VerifySmsAuthorizationResponse();
- if (!smsEntityOptional.isPresent()) {
+ if (smsEntityOptional.isEmpty()) {
response.setSmsAuthorizationResult(SmsAuthorizationResult.FAILED);
response.setErrorMessage("smsAuthorization.invalidMessage");
return response;
diff --git a/powerauth-data-adapter/src/main/resources/application-dev.properties b/powerauth-data-adapter/src/main/resources/application-dev.properties
new file mode 100644
index 00000000..524c75a0
--- /dev/null
+++ b/powerauth-data-adapter/src/main/resources/application-dev.properties
@@ -0,0 +1,3 @@
+# Liquibase
+spring.liquibase.enabled=true
+spring.liquibase.change-log=classpath:db/changelog/db.changelog-module.xml
diff --git a/powerauth-data-adapter/src/main/resources/application.properties b/powerauth-data-adapter/src/main/resources/application.properties
index 474b7905..4d00f3d4 100644
--- a/powerauth-data-adapter/src/main/resources/application.properties
+++ b/powerauth-data-adapter/src/main/resources/application.properties
@@ -2,11 +2,12 @@
spring.profiles.active=ext
# Database Configuration - PostgreSQL
-spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
+spring.datasource.url=jdbc:postgresql://localhost:5432/powerauth
spring.datasource.username=powerauth
spring.datasource.password=
+spring.datasource.hikari.auto-commit=false
spring.datasource.driver-class-name=org.postgresql.Driver
-spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
+spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.connection.characterEncoding=utf8
spring.jpa.properties.hibernate.connection.useUnicode=true
@@ -16,15 +17,6 @@ spring.jpa.properties.hibernate.connection.useUnicode=true
#spring.datasource.password=
#spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
# The following property speeds up Spring Boot startup
-#spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
-
-# Database Configuration - MySQL
-#spring.datasource.url=jdbc:mysql://localhost:3306/powerauth
-#spring.datasource.username=powerauth
-#spring.datasource.password=
-#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
-#spring.jpa.properties.hibernate.connection.characterEncoding=utf8
-#spring.jpa.properties.hibernate.connection.useUnicode=true
# SMS OTP expiration time in seconds
powerauth.authorization.sms-otp.expiration-time-in-seconds=300
@@ -43,4 +35,6 @@ powerauth.dataAdapter.service.applicationEnvironment=
spring.jpa.open-in-view=false
# Disable swagger-ui default petstore url
-springdoc.swagger-ui.disable-swagger-default-url=true
\ No newline at end of file
+springdoc.swagger-ui.disable-swagger-default-url=true
+
+logging.config=${POWERAUTH_DATA_ADAPTER_LOGGING:}
diff --git a/powerauth-data-adapter/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/powerauth-data-adapter/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
index 82d5a46a..0d258a38 100644
--- a/powerauth-data-adapter/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
+++ b/powerauth-data-adapter/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
@@ -12,7 +12,7 @@
-
+