-
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.
- Loading branch information
Showing
8 changed files
with
73 additions
and
6 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
5 changes: 5 additions & 0 deletions
5
src/main/java/it/gov/pagopa/payhub/auth/repository/ClientRepositoryExt.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,5 @@ | ||
package it.gov.pagopa.payhub.auth.repository; | ||
|
||
public interface ClientRepositoryExt { | ||
void deleteClient(String organizationIpaCode, String clientId); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/it/gov/pagopa/payhub/auth/repository/ClientRepositoryExtImpl.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,27 @@ | ||
package it.gov.pagopa.payhub.auth.repository; | ||
|
||
import it.gov.pagopa.payhub.auth.model.Client; | ||
import org.springframework.data.mongodb.core.MongoTemplate; | ||
import org.springframework.data.mongodb.core.query.Criteria; | ||
import org.springframework.data.mongodb.core.query.Query; | ||
|
||
public class ClientRepositoryExtImpl implements ClientRepositoryExt { | ||
private final MongoTemplate mongoTemplate; | ||
|
||
public ClientRepositoryExtImpl(MongoTemplate mongoTemplate) { | ||
this.mongoTemplate = mongoTemplate; | ||
} | ||
|
||
@Override | ||
public void deleteClient(String organizationIpaCode, String clientId) { | ||
//find User with clientId | ||
Client client = mongoTemplate.findOne(Query.query(Criteria.where(Client.Fields.clientId).is(clientId)), Client.class); | ||
//If exists delete Client | ||
if(client != null) | ||
mongoTemplate.remove( | ||
Query.query(Criteria | ||
.where(Client.Fields.organizationIpaCode).is(organizationIpaCode) | ||
.and(Client.Fields.clientId).is(client.getClientId())), Client.class); | ||
} | ||
|
||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/it/gov/pagopa/payhub/auth/service/a2a/revoke/ClientRemovalService.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,22 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a.revoke; | ||
|
||
import it.gov.pagopa.payhub.auth.repository.ClientRepository; | ||
import jakarta.transaction.Transactional; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class ClientRemovalService { | ||
|
||
private final ClientRepository clientRepository; | ||
|
||
public ClientRemovalService(ClientRepository clientRepository) { | ||
this.clientRepository = clientRepository; | ||
} | ||
|
||
@Transactional | ||
public void revokeClient(String organizationIpaCode, String clientId) { | ||
clientRepository.deleteClient(organizationIpaCode, clientId); | ||
} | ||
} |
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