-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: P4ADEV-791-P4PA-AUTH-API-censimento-client-id (#80)
- Loading branch information
Showing
22 changed files
with
751 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/it/gov/pagopa/payhub/auth/mapper/ClientMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package it.gov.pagopa.payhub.auth.mapper; | ||
|
||
import it.gov.pagopa.payhub.auth.model.Client; | ||
import it.gov.pagopa.payhub.auth.service.DataCipherService; | ||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ClientMapper { | ||
|
||
private final DataCipherService dataCipherService; | ||
|
||
public ClientMapper(DataCipherService dataCipherService) { | ||
this.dataCipherService = dataCipherService; | ||
} | ||
|
||
public ClientDTO mapToDTO(Client client) { | ||
return ClientDTO.builder() | ||
.clientId(client.getClientId()) | ||
.clientName(client.getClientName()) | ||
.organizationIpaCode(client.getOrganizationIpaCode()) | ||
.clientSecret(dataCipherService.decrypt(client.getClientSecret())) | ||
.build(); | ||
} | ||
|
||
public Client mapToModel(ClientDTO clientDTO) { | ||
return Client.builder() | ||
.clientId(clientDTO.getClientId()) | ||
.clientName(clientDTO.getClientName()) | ||
.organizationIpaCode(clientDTO.getOrganizationIpaCode()) | ||
.clientSecret(dataCipherService.encrypt(clientDTO.getClientSecret())) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package it.gov.pagopa.payhub.auth.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.FieldNameConstants; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
@Data | ||
@Document("clients") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@FieldNameConstants | ||
public class Client { | ||
|
||
@Id | ||
private String clientId; | ||
private String clientName; | ||
private String organizationIpaCode; | ||
private byte[] clientSecret; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/it/gov/pagopa/payhub/auth/repository/ClientRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package it.gov.pagopa.payhub.auth.repository; | ||
|
||
import it.gov.pagopa.payhub.auth.model.Client; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
public interface ClientRepository extends MongoRepository<Client, String> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/it/gov/pagopa/payhub/auth/service/a2a/ClientService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a; | ||
|
||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
|
||
public interface ClientService { | ||
|
||
ClientDTO registerClient(String clientName, String organizationIpaCode); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/it/gov/pagopa/payhub/auth/service/a2a/ClientServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a; | ||
|
||
import it.gov.pagopa.payhub.auth.model.Client; | ||
import it.gov.pagopa.payhub.auth.service.a2a.registration.ClientRegistrationService; | ||
import it.gov.pagopa.payhub.auth.mapper.ClientMapper; | ||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class ClientServiceImpl implements ClientService { | ||
|
||
private final ClientRegistrationService clientRegistrationService; | ||
|
||
private final ClientMapper clientMapper; | ||
|
||
public ClientServiceImpl(ClientRegistrationService clientRegistrationService, ClientMapper clientMapper) { | ||
this.clientRegistrationService = clientRegistrationService; | ||
this.clientMapper = clientMapper; | ||
} | ||
|
||
@Override | ||
public ClientDTO registerClient(String clientName, String organizationIpaCode) { | ||
Client client = clientRegistrationService.registerClient(clientName, organizationIpaCode); | ||
return clientMapper.mapToDTO(client); | ||
} | ||
} |
Oops, something went wrong.