diff --git a/ledgers-account-access/ledgers-acount-access-repository/pom.xml b/ledgers-account-access/ledgers-acount-access-repository/pom.xml new file mode 100644 index 000000000..b8275d7d4 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/pom.xml @@ -0,0 +1,52 @@ + + + + + 4.0.0 + + de.adorsys.ledgers + ledgers-account-access + 6.1-SNAPSHOT + ../pom.xml + + + ledgers-acount-access-repository + jar + + + 17 + 17 + UTF-8 + ../.. + + + + com.fasterxml.jackson.core + jackson-annotations + + + jakarta.persistence + jakarta.persistence-api + + + org.projectlombok + lombok + provided + + + org.springframework.data + spring-data-jpa + + + org.springframework.boot + spring-boot-autoconfigure + test + + + + \ No newline at end of file diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/AccountAccessBasePackage.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/AccountAccessBasePackage.java new file mode 100644 index 000000000..83bd6b918 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/AccountAccessBasePackage.java @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db; +//Purpose Package used to document this module. We user this +//to reference the package to be scanned for repositories. + +public class AccountAccessBasePackage { +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/AccountAccessRepositoryConfiguration.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/AccountAccessRepositoryConfiguration.java new file mode 100644 index 000000000..abc8d7e4d --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/AccountAccessRepositoryConfiguration.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db; + +import org.springframework.context.annotation.*; +import org.springframework.data.jpa.repository.config.*; +@Configuration +@ComponentScan(basePackageClasses = {AccountAccessBasePackage.class}) +@EnableJpaRepositories +//@EntityScan(basePackages = "de.adorsys.ledgers.aa.db.domain") + +public class AccountAccessRepositoryConfiguration { +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/EnableAccountAccessRepository.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/EnableAccountAccessRepository.java new file mode 100644 index 000000000..2709babc7 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/EnableAccountAccessRepository.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db; +import org.springframework.context.annotation.Import; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +@Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME) +@Target(value = {java.lang.annotation.ElementType.TYPE}) +@Documented +@Import({ + AccountAccessRepositoryConfiguration.class +}) +public @interface EnableAccountAccessRepository { +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AccountAccessEntity.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AccountAccessEntity.java new file mode 100644 index 000000000..42beef038 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AccountAccessEntity.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.domain; +import java.util.UUID; +import jakarta.persistence.Id; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Entity; +import lombok.Data; +@Entity +@Data +public class AccountAccessEntity { + @Id + @GeneratedValue + private UUID id; + + private UUID entityId; + private UUID accountId; + private String name; + private UUID template; // Reference to AccountAccessTemplateEntity + + // Constructors, getters and setters + public AccountAccessEntity() { + } + + public AccountAccessEntity(UUID entityId, UUID accountId, String name, UUID template) { + this.entityId = entityId; + this.accountId = accountId; + this.name = name; + this.template = template; + } + +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AccountAccessTemplateEntity.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AccountAccessTemplateEntity.java new file mode 100644 index 000000000..14b49c5f8 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AccountAccessTemplateEntity.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.domain; + +import java.util.List; +import java.util.UUID; +import lombok.Data; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.ElementCollection; + +@Entity +@Data +public class AccountAccessTemplateEntity { + + @Id + @GeneratedValue + private UUID id; + + private String templateName; + @ElementCollection + private List permissions; + @ElementCollection + private List parameters; + + // Constructors, getters and setters + public AccountAccessTemplateEntity() { + } + + public AccountAccessTemplateEntity(String templateName, List permissions, List parameters) { + this.templateName = templateName; + this.permissions = permissions; + this.parameters = parameters; + } +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AgentAccessEntity.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AgentAccessEntity.java new file mode 100644 index 000000000..a29702de0 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/domain/AgentAccessEntity.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.domain; + +import java.util.UUID; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.Data; + + +@Entity +@Data +public class AgentAccessEntity { + + @Id + @GeneratedValue + private UUID id; + + private UUID agentId; + private UUID accountAccessId; + private UUID subTemplate; // Reference to AccountAccessTemplateEntity + + // Constructors, getters and setters + public AgentAccessEntity() { + } + + public AgentAccessEntity(UUID agentId, UUID accountAccessId, UUID subTemplate) { + this.agentId = agentId; + this.accountAccessId = accountAccessId; + this.subTemplate = subTemplate; + } +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AccountAccessRepository.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AccountAccessRepository.java new file mode 100644 index 000000000..d4e484b0c --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AccountAccessRepository.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.repository; +import org.springframework.data.jpa.repository.JpaRepository; +import de.adorsys.ledgers.aa.db.domain.AccountAccessEntity; +import java.util.UUID; + +public interface AccountAccessRepository extends JpaRepository { +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AccountAccessTemplateRepository.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AccountAccessTemplateRepository.java new file mode 100644 index 000000000..0c983ce9d --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AccountAccessTemplateRepository.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.repository; +import de.adorsys.ledgers.aa.db.domain.AccountAccessTemplateEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.UUID; + +public interface AccountAccessTemplateRepository extends JpaRepository { +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AgentAccessRepository.java b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AgentAccessRepository.java new file mode 100644 index 000000000..c25530447 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/main/java/de/adorsys/ledgers/aa/db/repository/AgentAccessRepository.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.repository; +import de.adorsys.ledgers.aa.db.domain.AgentAccessEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.UUID; +import org.springframework.stereotype.Repository; +@Repository +public interface AgentAccessRepository extends JpaRepository { +} diff --git a/ledgers-account-access/ledgers-acount-access-repository/src/test/java/de/adorsys/ledgers/aa/db/test/AaRepositoryApplication.java b/ledgers-account-access/ledgers-acount-access-repository/src/test/java/de/adorsys/ledgers/aa/db/test/AaRepositoryApplication.java new file mode 100644 index 000000000..260766184 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-repository/src/test/java/de/adorsys/ledgers/aa/db/test/AaRepositoryApplication.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.db.test; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.SpringApplication; +@SpringBootApplication +public class AaRepositoryApplication { + public static void main(String[] args){SpringApplication.run(AaRepositoryApplication.class, args);} + +} diff --git a/ledgers-account-access/ledgers-acount-access-rest-api/pom.xml b/ledgers-account-access/ledgers-acount-access-rest-api/pom.xml new file mode 100644 index 000000000..6e9e9cde9 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-api/pom.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + de.adorsys.ledgers + ledgers-account-access + 6.1-SNAPSHOT + ../pom.xml + + + ledgers-acount-access-rest-api + jar + + + 17 + 17 + UTF-8 + ../.. + + + + org.springframework + spring-web + + + de.adorsys.ledgers + ledgers-acount-access-repository + 6.1-SNAPSHOT + compile + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + + + + + \ No newline at end of file diff --git a/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AccountAccessRestAPI.java b/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AccountAccessRestAPI.java new file mode 100644 index 000000000..7b33f2c57 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AccountAccessRestAPI.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.rest.api.resource; + +import de.adorsys.ledgers.aa.db.domain.*; +import io.swagger.v3.oas.annotations.*; +import io.swagger.v3.oas.annotations.tags.*; +import org.springframework.http.*; +import org.springframework.web.bind.annotation.*; +import java.util.*; +@Tag(name = "Account Access", description = "Provide endpoint for managing account access.") +@RequestMapping(AccountAccessRestAPI.BASE_PATH) +public interface AccountAccessRestAPI { + + String BASE_PATH = "/api/accesses"; + + @Operation(summary = "Create an Account Access", description = "Create a new account access entity") + @PostMapping + ResponseEntity createAccess(@RequestBody AccountAccessEntity access); + + @Operation(summary = "Get Account Access by ID", description = "Retrieve an account access entity by its unique ID") + @GetMapping("/{id}") + ResponseEntity getAccessById(@PathVariable UUID id); + + @Operation(summary = "Get All Account Accesses", description = "Retrieve a list of all account access entities") + @GetMapping + ResponseEntity> getAllAccesses(); + + @Operation(summary = "Update an Account Access", description = "Update an existing account access entity by its ID") + @PutMapping("/{id}") + ResponseEntity updateAccess(@PathVariable UUID id, @RequestBody AccountAccessEntity access); + + @Operation(summary = "Delete an Account Access", description = "Delete an account access entity by its unique ID") + @DeleteMapping("/{id}") + ResponseEntity deleteAccess(@PathVariable UUID id); +} diff --git a/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AccountAccessTemplateRestAPI.java b/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AccountAccessTemplateRestAPI.java new file mode 100644 index 000000000..5b26d777f --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AccountAccessTemplateRestAPI.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.rest.api.resource; + +import java.util.List; +import java.util.UUID; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import de.adorsys.ledgers.aa.db.domain.AccountAccessTemplateEntity; +import org.springframework.web.bind.annotation.RequestMapping; + +@RequestMapping("/api/templates") +public interface AccountAccessTemplateRestAPI { + + @PostMapping + ResponseEntity createTemplate(@RequestBody AccountAccessTemplateEntity template); + + @GetMapping("/{id}") + ResponseEntity getTemplateById(@PathVariable UUID id); + + @GetMapping + ResponseEntity> getAllTemplates(); + + @PutMapping("/{id}") + ResponseEntity updateTemplate(@PathVariable UUID id, @RequestBody AccountAccessTemplateEntity template); + + @DeleteMapping("/{id}") + ResponseEntity deleteTemplate(@PathVariable UUID id); +} diff --git a/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AgentAccessRestAPI.java b/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AgentAccessRestAPI.java new file mode 100644 index 000000000..0cc8a9f6d --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-api/src/main/java/de/adorsys/ledgers/aa/rest/api/resource/AgentAccessRestAPI.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.rest.api.resource; + +import java.util.List; +import java.util.UUID; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import de.adorsys.ledgers.aa.db.domain.AgentAccessEntity; + +@RequestMapping("/api/agent-accesses") +public interface AgentAccessRestAPI { + + @PostMapping + ResponseEntity createAccess(@RequestBody AgentAccessEntity access); + + @GetMapping("/{id}") + ResponseEntity getAccessById(@PathVariable UUID id); + + @GetMapping + ResponseEntity> getAllAccesses(); + + @PutMapping("/{id}") + ResponseEntity updateAccess(@PathVariable UUID id, @RequestBody AgentAccessEntity access); + + @DeleteMapping("/{id}") + ResponseEntity deleteAccess(@PathVariable UUID id); +} diff --git a/ledgers-account-access/ledgers-acount-access-rest-server/pom.xml b/ledgers-account-access/ledgers-acount-access-rest-server/pom.xml new file mode 100644 index 000000000..e36c096c4 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-server/pom.xml @@ -0,0 +1,43 @@ + + + + + 4.0.0 + + de.adorsys.ledgers + ledgers-account-access + 6.1-SNAPSHOT + ../pom.xml + + + ledgers-acount-access-rest-server + jar + + + + 17 + 17 + UTF-8 + ../.. + + + + de.adorsys.ledgers + ledgers-acount-access-rest-api + 6.1-SNAPSHOT + compile + + + de.adorsys.ledgers + ledgers-acount-access-service-api + 6.1-SNAPSHOT + compile + + + + \ No newline at end of file diff --git a/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AccountAccessRestServer.java b/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AccountAccessRestServer.java new file mode 100644 index 000000000..f636aa98b --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AccountAccessRestServer.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.rest.server.resource; + +import java.util.List; +import java.util.UUID; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; +import de.adorsys.ledgers.aa.rest.api.resource.AccountAccessRestAPI; +import de.adorsys.ledgers.aa.db.domain.AccountAccessEntity; +import de.adorsys.ledgers.aa.service.api.service.AccountAccessServiceAPI; + +@RestController +public class AccountAccessRestServer implements AccountAccessRestAPI { + + @Autowired + private AccountAccessServiceAPI service; + + @Override + public ResponseEntity createAccess(AccountAccessEntity access) { + return new ResponseEntity<>(service.createAccess(access), HttpStatus.CREATED); + } + + @Override + public ResponseEntity getAccessById(UUID id) { + return new ResponseEntity<>(service.getAccessById(id), HttpStatus.OK); + } + + @Override + public ResponseEntity> getAllAccesses() { + return new ResponseEntity<>(service.getAllAccesses(), HttpStatus.OK); + } + + @Override + public ResponseEntity updateAccess(UUID id, AccountAccessEntity access) { + return new ResponseEntity<>(service.updateAccess(id, access), HttpStatus.OK); + } + + @Override + public ResponseEntity deleteAccess(UUID id) { + service.deleteAccess(id); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } +} diff --git a/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AccountAccessTemplateRestServer.java b/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AccountAccessTemplateRestServer.java new file mode 100644 index 000000000..87f09996e --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AccountAccessTemplateRestServer.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.rest.server.resource; + +import java.util.List; +import java.util.UUID; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; +import de.adorsys.ledgers.aa.rest.api.resource.AccountAccessTemplateRestAPI; +import de.adorsys.ledgers.aa.db.domain.AccountAccessTemplateEntity; +import de.adorsys.ledgers.aa.service.api.service.AccountAccessTemplateServiceAPI; + +@RestController +public class AccountAccessTemplateRestServer implements AccountAccessTemplateRestAPI { + + @Autowired + private AccountAccessTemplateServiceAPI service; + + @Override + public ResponseEntity createTemplate(AccountAccessTemplateEntity template) { + return new ResponseEntity<>(service.createTemplate(template), HttpStatus.CREATED); + } + + @Override + public ResponseEntity getTemplateById(UUID id) { + return new ResponseEntity<>(service.getTemplateById(id), HttpStatus.OK); + } + + @Override + public ResponseEntity> getAllTemplates() { + return new ResponseEntity<>(service.getAllTemplates(), HttpStatus.OK); + } + + @Override + public ResponseEntity updateTemplate(UUID id, AccountAccessTemplateEntity template) { + return new ResponseEntity<>(service.updateTemplate(id, template), HttpStatus.OK); + } + + @Override + public ResponseEntity deleteTemplate(UUID id) { + service.deleteTemplate(id); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } +} diff --git a/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AgentAccessRestServer.java b/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AgentAccessRestServer.java new file mode 100644 index 000000000..b5fcc75cd --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-rest-server/src/main/java/de/adorsys/ledgers/aa/rest/server/resource/AgentAccessRestServer.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.rest.server.resource; + +import java.util.List; +import java.util.UUID; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RestController; +import de.adorsys.ledgers.aa.rest.api.resource.AgentAccessRestAPI; +import de.adorsys.ledgers.aa.db.domain.AgentAccessEntity; +import de.adorsys.ledgers.aa.service.api.service.AgentAccessServiceAPI; + +@RestController +public class AgentAccessRestServer implements AgentAccessRestAPI { + + @Autowired + private AgentAccessServiceAPI service; + + @Override + public ResponseEntity createAccess(AgentAccessEntity access) { + return new ResponseEntity<>(service.createAccess(access), HttpStatus.CREATED); + } + + @Override + public ResponseEntity getAccessById(UUID id) { + return new ResponseEntity<>(service.getAccessById(id), HttpStatus.OK); + } + + @Override + public ResponseEntity> getAllAccesses() { + return new ResponseEntity<>(service.getAllAccesses(), HttpStatus.OK); + } + + @Override + public ResponseEntity updateAccess(UUID id, AgentAccessEntity access) { + return new ResponseEntity<>(service.updateAccess(id, access), HttpStatus.OK); + } + + @Override + public ResponseEntity deleteAccess(UUID id) { + service.deleteAccess(id); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } +} diff --git a/ledgers-account-access/ledgers-acount-access-service-api/pom.xml b/ledgers-account-access/ledgers-acount-access-service-api/pom.xml new file mode 100644 index 000000000..0b442f2f5 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-api/pom.xml @@ -0,0 +1,37 @@ + + + + + 4.0.0 + + de.adorsys.ledgers + ledgers-account-access + 6.1-SNAPSHOT + ../pom.xml + + + ledgers-acount-access-service-api + jar + + + + 17 + 17 + UTF-8 + ../.. + + + + de.adorsys.ledgers + ledgers-acount-access-repository + 6.1-SNAPSHOT + compile + + + + \ No newline at end of file diff --git a/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AccountAccessServiceAPI.java b/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AccountAccessServiceAPI.java new file mode 100644 index 000000000..abe9d8543 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AccountAccessServiceAPI.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.service.api.service; + +import java.util.List; +import java.util.UUID; +import de.adorsys.ledgers.aa.db.domain.AccountAccessEntity; + +public interface AccountAccessServiceAPI { + + AccountAccessEntity createAccess(AccountAccessEntity access); + AccountAccessEntity getAccessById(UUID id); + List getAllAccesses(); + AccountAccessEntity updateAccess(UUID id, AccountAccessEntity access); + void deleteAccess(UUID id); +} diff --git a/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AccountAccessTemplateServiceAPI.java b/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AccountAccessTemplateServiceAPI.java new file mode 100644 index 000000000..96f1edb30 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AccountAccessTemplateServiceAPI.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.service.api.service; + +import java.util.List; +import java.util.UUID; +import de.adorsys.ledgers.aa.db.domain.AccountAccessTemplateEntity; + +public interface AccountAccessTemplateServiceAPI { + + AccountAccessTemplateEntity createTemplate(AccountAccessTemplateEntity template); + AccountAccessTemplateEntity getTemplateById(UUID id); + List getAllTemplates(); + AccountAccessTemplateEntity updateTemplate(UUID id, AccountAccessTemplateEntity template); + void deleteTemplate(UUID id); +} diff --git a/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AgentAccessServiceAPI.java b/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AgentAccessServiceAPI.java new file mode 100644 index 000000000..d38eec5cc --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-api/src/main/java/de/adorsys/ledgers/aa/service/api/service/AgentAccessServiceAPI.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.service.api.service; + +import java.util.List; +import java.util.UUID; +import de.adorsys.ledgers.aa.db.domain.AgentAccessEntity; +public interface AgentAccessServiceAPI { + + AgentAccessEntity createAccess(AgentAccessEntity access); + AgentAccessEntity getAccessById(UUID id); + List getAllAccesses(); + AgentAccessEntity updateAccess(UUID id, AgentAccessEntity access); + void deleteAccess(UUID id); +} diff --git a/ledgers-account-access/ledgers-acount-access-service-impl/pom.xml b/ledgers-account-access/ledgers-acount-access-service-impl/pom.xml new file mode 100644 index 000000000..0918306c6 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-impl/pom.xml @@ -0,0 +1,53 @@ + + + + + 4.0.0 + + de.adorsys.ledgers + ledgers-account-access + 6.1-SNAPSHOT + ../pom.xml + + + ledgers-acount-access-service-impl + jar + + + + 17 + 17 + UTF-8 + ../.. + + + + de.adorsys.ledgers + ledgers-acount-access-service-api + 6.1-SNAPSHOT + compile + + + org.springframework + spring-context + + + de.adorsys.ledgers + ledgers-user-management-repository + 6.1-SNAPSHOT + compile + + + de.adorsys.ledgers + ledgers-bank-account-access-repository + 6.1-SNAPSHOT + compile + + + + \ No newline at end of file diff --git a/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AccountAccessServiceImpl.java b/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AccountAccessServiceImpl.java new file mode 100644 index 000000000..c957020a6 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AccountAccessServiceImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.service.impl.service; + +import java.util.List; +import java.util.UUID; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import de.adorsys.ledgers.aa.service.api.service.AccountAccessServiceAPI; +import de.adorsys.ledgers.aa.db.domain.AccountAccessEntity; +import de.adorsys.ledgers.aa.db.repository.AccountAccessRepository; +@Service +public class AccountAccessServiceImpl implements AccountAccessServiceAPI { + + @Autowired + private AccountAccessRepository repository; + + @Override + public AccountAccessEntity createAccess(AccountAccessEntity access) { + return repository.save(access); + } + + @Override + public AccountAccessEntity getAccessById(UUID id) { + return repository.findById(id).orElse(null); + } + + @Override + public List getAllAccesses() { + return repository.findAll(); + } + + @Override + public AccountAccessEntity updateAccess(UUID id, AccountAccessEntity access) { + if (repository.existsById(id)) { + access.setId(id); + return repository.save(access); + } + return null; + } + + @Override + public void deleteAccess(UUID id) { + repository.deleteById(id); + } +} diff --git a/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AccountAccessTemplateServiceImpl.java b/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AccountAccessTemplateServiceImpl.java new file mode 100644 index 000000000..4aeeee874 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AccountAccessTemplateServiceImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.service.impl.service; + +import java.util.List; +import java.util.UUID; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import de.adorsys.ledgers.aa.service.api.service.AccountAccessTemplateServiceAPI; +import de.adorsys.ledgers.aa.db.domain.AccountAccessTemplateEntity; +import de.adorsys.ledgers.aa.db.repository.AccountAccessTemplateRepository; + +@Service +public class AccountAccessTemplateServiceImpl implements AccountAccessTemplateServiceAPI { + + @Autowired + private AccountAccessTemplateRepository repository; + + @Override + public AccountAccessTemplateEntity createTemplate(AccountAccessTemplateEntity template) { + return repository.save(template); + } + + @Override + public AccountAccessTemplateEntity getTemplateById(UUID id) { + return repository.findById(id).orElse(null); + } + + @Override + public List getAllTemplates() { + return repository.findAll(); + } + + @Override + public AccountAccessTemplateEntity updateTemplate(UUID id, AccountAccessTemplateEntity template) { + if (repository.existsById(id)) { + template.setId(id); + return repository.save(template); + } + return null; + } + + @Override + public void deleteTemplate(UUID id) { + repository.deleteById(id); + } +} \ No newline at end of file diff --git a/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AgentAccessServiceImpl.java b/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AgentAccessServiceImpl.java new file mode 100644 index 000000000..b2071ddf5 --- /dev/null +++ b/ledgers-account-access/ledgers-acount-access-service-impl/src/main/java/de/adorsys/ledgers/aa/service/impl/service/AgentAccessServiceImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2023 adorsys GmbH and Co. KG + * All rights are reserved. + */ + +package de.adorsys.ledgers.aa.service.impl.service; + +import java.util.List; +import java.util.UUID; +import de.adorsys.ledgers.aa.service.api.service.AgentAccessServiceAPI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import de.adorsys.ledgers.aa.db.domain.AgentAccessEntity; +import de.adorsys.ledgers.aa.db.repository.AgentAccessRepository; + +@Service +public class AgentAccessServiceImpl implements AgentAccessServiceAPI { + + @Autowired + private AgentAccessRepository repository; + + @Override + public AgentAccessEntity createAccess(AgentAccessEntity access) { + return repository.save(access); + } + + @Override + public AgentAccessEntity getAccessById(UUID id) { + return repository.findById(id).orElse(null); + } + + @Override + public List getAllAccesses() { + return repository.findAll(); + } + + @Override + public AgentAccessEntity updateAccess(UUID id, AgentAccessEntity access) { + if (repository.existsById(id)) { + access.setId(id); + return repository.save(access); + } + return null; + } + + @Override + public void deleteAccess(UUID id) { + repository.deleteById(id); + } +} diff --git a/ledgers-account-access/pom.xml b/ledgers-account-access/pom.xml new file mode 100644 index 000000000..c02c33409 --- /dev/null +++ b/ledgers-account-access/pom.xml @@ -0,0 +1,33 @@ + + + + + 4.0.0 + + de.adorsys.ledgers + ledgers + 6.1-SNAPSHOT + + + ledgers-account-access + pom + + ledgers-acount-access-repository + ledgers-acount-access-rest-api + ledgers-acount-access-rest-server + ledgers-acount-access-service-api + ledgers-acount-access-service-impl + + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/AgentAccessRepositoryIT.java b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/AgentAccessRepositoryIT.java index 416ca6e34..844655cbf 100644 --- a/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/AgentAccessRepositoryIT.java +++ b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/AgentAccessRepositoryIT.java @@ -1,18 +1,22 @@ package de.adorsys.ledgers.baam.db.repository; -import com.github.springtestdbunit.DbUnitTestExecutionListener; -import de.adorsys.ledgers.baam.db.domain.*; -import de.adorsys.ledgers.baam.db.test.BaamRepositoryApplication; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; -import org.springframework.test.context.transaction.TransactionalTestExecutionListener; - -import static org.junit.jupiter.api.Assertions.assertNotNull; +import com.github.springtestdbunit.*; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.*; +import de.adorsys.ledgers.baam.db.domain.AgentAccess; +import org.springframework.beans.factory.annotation.*; +import org.springframework.boot.test.context.*; +import org.springframework.test.context.*; +import org.springframework.test.context.junit.jupiter.*; +import org.springframework.test.context.support.*; +import org.springframework.test.context.transaction.*; +import de.adorsys.ledgers.baam.db.domain.AccessCondition; +import de.adorsys.ledgers.baam.db.domain.AccessScope; +import de.adorsys.ledgers.baam.db.domain.AccessStatus; +import de.adorsys.ledgers.baam.db.test.BaamRepositoryApplication; + + +import static org.junit.jupiter.api.Assertions.*; @SpringBootTest(classes = BaamRepositoryApplication.class) @ExtendWith(SpringExtension.class) diff --git a/pom.xml b/pom.xml index d3eb6c8b3..989be2669 100755 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,7 @@ keycloak ledgers-cleanup-service ledgers-bank-account-access-management + ledgers-account-access pom