+ * Note: Although it is represented as a class with static final String fields, it serves + * the purpose of an enum type for specific use cases that require constant String values. + *
+ * + * @author Jan Dusil + */ +public class SignatureMetadataType { + + /** + * Represents PowerAuth signature metadata. + * This value is used for identifying the type of metadata in JSON serialization/deserialization. + */ + public static final String POWERAUTH = "POWERAUTH"; +} + diff --git a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/AuditingServiceBehavior.java b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/AuditingServiceBehavior.java index e0c8f29b9..515f493bc 100644 --- a/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/AuditingServiceBehavior.java +++ b/powerauth-java-server/src/main/java/io/getlime/security/powerauth/app/server/service/behavior/tasks/AuditingServiceBehavior.java @@ -26,6 +26,8 @@ import io.getlime.security.powerauth.app.server.converter.ActivationStatusConverter; import io.getlime.security.powerauth.app.server.converter.KeyValueMapConverter; import io.getlime.security.powerauth.app.server.converter.SignatureTypeConverter; +import io.getlime.security.powerauth.app.server.database.model.PowerAuthSignatureMetadata; +import io.getlime.security.powerauth.app.server.database.model.converter.SignatureMetadataConverter; import io.getlime.security.powerauth.app.server.database.model.entity.ActivationRecordEntity; import io.getlime.security.powerauth.app.server.database.model.entity.SignatureEntity; import io.getlime.security.powerauth.app.server.database.model.enumeration.ActivationStatus; @@ -57,6 +59,8 @@ public class AuditingServiceBehavior { // Prepare converters private final ActivationStatusConverter activationStatusConverter = new ActivationStatusConverter(); private final SignatureTypeConverter signatureTypeConverter = new SignatureTypeConverter(); + + private final SignatureMetadataConverter signatureMetadataConverter = new SignatureMetadataConverter(); private final KeyValueMapConverter keyValueMapConverter; // Generic auditing capability @@ -157,6 +161,7 @@ public void logSignatureAuditRecord(ActivationRecordDto activation, SignatureDat // Audit the signature final SignatureEntity signatureAuditRecord = new SignatureEntity(); + final PowerAuthSignatureMetadata signatureMetadata = new PowerAuthSignatureMetadata(signatureData.getRequestMethod(), signatureData.getRequestUriId()); signatureAuditRecord.setActivation(activationRepository.getReferenceById(activation.getActivationId())); signatureAuditRecord.setActivationCounter(activation.getCounter()); signatureAuditRecord.setActivationCtrDataBase64(activation.getCtrDataBase64()); @@ -164,8 +169,7 @@ public void logSignatureAuditRecord(ActivationRecordDto activation, SignatureDat signatureAuditRecord.setAdditionalInfo(additionalInfo); signatureAuditRecord.setDataBase64(data); signatureAuditRecord.setSignature(signatureData.getSignature()); - signatureAuditRecord.setSignatureDataMethod(signatureData.getRequestMethod()); - signatureAuditRecord.setSignatureDataUriId(signatureData.getRequestUriId()); + signatureAuditRecord.setSignatureMetadata(signatureMetadata); signatureAuditRecord.setSignatureDataBody(signatureData.getRequestBody()); signatureAuditRecord.setSignatureType(signatureType.name()); signatureAuditRecord.setSignatureVersion(signatureData.getSignatureVersion()); @@ -187,8 +191,7 @@ public void logSignatureAuditRecord(ActivationRecordDto activation, SignatureDat .param("additionalInfo", additionalInfo) .param("data", data) .param("signature", signatureData.getSignature()) - .param("signatureDataMethod", signatureData.getRequestMethod()) - .param("signatureDataUriId", signatureData.getRequestUriId()) + .param("signatureMetadata", signatureMetadataConverter.convertToDatabaseColumn(signatureMetadata)) .param("signatureDataBody", signatureData.getRequestBody()) .param("signatureType", signatureType.name()) .param("signatureVersion", signatureData.getSignatureVersion()) diff --git a/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/model/signature/SignatureMetadataConverterTest.java b/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/model/signature/SignatureMetadataConverterTest.java new file mode 100644 index 000000000..0b72eec44 --- /dev/null +++ b/powerauth-java-server/src/test/java/io/getlime/security/powerauth/app/server/service/model/signature/SignatureMetadataConverterTest.java @@ -0,0 +1,99 @@ +/* + * PowerAuth Server and related software components + * Copyright (C) 2023 Wultra s.r.o. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see