-
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.
[TEST] Added stuff to retrieve certificates from Azure Key Vault.
- Loading branch information
1 parent
38ff17e
commit e58140e
Showing
3 changed files
with
88 additions
and
0 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
62 changes: 62 additions & 0 deletions
62
src/main/java/it/pagopa/swclient/mil/auth/resource/CertificateResource.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,62 @@ | ||
/* | ||
* CertificateResource.java | ||
* | ||
* 21 mar 2023 | ||
*/ | ||
package it.pagopa.swclient.mil.auth.resource; | ||
|
||
import java.util.UUID; | ||
|
||
import org.jboss.logging.MDC; | ||
|
||
import io.quarkus.logging.Log; | ||
import io.smallrye.mutiny.Uni; | ||
import it.pagopa.swclient.mil.auth.azure.auth.service.AzureAuthService; | ||
import it.pagopa.swclient.mil.auth.azure.keyvault.service.AzureKeyVaultService; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
/** | ||
* @author Antonio Tarricone | ||
*/ | ||
@Path("/certificates") | ||
public class CertificateResource { | ||
/* | ||
* | ||
*/ | ||
AzureAuthService authService; | ||
|
||
/* | ||
* | ||
*/ | ||
AzureKeyVaultService keyVaultService; | ||
|
||
/** | ||
* | ||
* @param authService | ||
* @param keyVaultService | ||
*/ | ||
@Inject | ||
CertificateResource(AzureAuthService authService, AzureKeyVaultService keyVaultService) { | ||
this.authService=authService; | ||
this.keyVaultService=keyVaultService; | ||
} | ||
|
||
/** | ||
* @return | ||
*/ | ||
@Path("/{certificateName}") | ||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Uni<Response> get(@PathParam("certificateName") String certificateName) { | ||
String correlationId = UUID.randomUUID().toString(); | ||
MDC.put("requestId", correlationId); | ||
Log.debug("get - Input parameters: n/a"); | ||
return authService.getAccessToken().chain(x -> keyVaultService.getCertificate(x.getToken(), certificateName)); | ||
} | ||
} |