generated from pagopa/template-payments-java-repository
-
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
41 changed files
with
1,459 additions
and
25 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
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
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
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
28 changes: 28 additions & 0 deletions
28
src/main/java/it/gov/pagopa/payhub/pdnd/config/RestTemplateConfig.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.pdnd.config; | ||
|
||
import java.time.Duration; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.web.client.RestTemplateBuilderConfigurer; | ||
import org.springframework.boot.web.client.RestTemplateBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class RestTemplateConfig { | ||
private final int connectTimeoutMillis; | ||
private final int readTimeoutHandlerMillis; | ||
|
||
public RestTemplateConfig( | ||
@Value("${app.rest-client.connect.timeout.millis}") int connectTimeoutMillis, | ||
@Value("${app.rest-client.read.timeout.millis}") int readTimeoutHandlerMillis) { | ||
this.connectTimeoutMillis = connectTimeoutMillis; | ||
this.readTimeoutHandlerMillis = readTimeoutHandlerMillis; | ||
} | ||
|
||
@Bean | ||
public RestTemplateBuilder restTemplateBuilder(RestTemplateBuilderConfigurer configurer) { | ||
return configurer.configure(new RestTemplateBuilder()) | ||
.setConnectTimeout(Duration.ofMillis(connectTimeoutMillis)) | ||
.setReadTimeout(Duration.ofMillis(readTimeoutHandlerMillis)); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/it/gov/pagopa/payhub/pdnd/config/pdnd/PdndConfig.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,12 @@ | ||
package it.gov.pagopa.payhub.pdnd.config.pdnd; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "app.pdnd.config") | ||
@Data | ||
public class PdndConfig { | ||
private String audience; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/it/gov/pagopa/payhub/pdnd/config/pdnd/PdndServiceIntegratedConfig.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,17 @@ | ||
package it.gov.pagopa.payhub.pdnd.config.pdnd; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public abstract class PdndServiceIntegratedConfig { | ||
private String clientId; | ||
private String kid; | ||
private String purposeId; | ||
private String privateKey; | ||
private String publicKey; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/it/gov/pagopa/payhub/pdnd/config/pdnd/anpr/AnprC003ServiceConfig.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,11 @@ | ||
package it.gov.pagopa.payhub.pdnd.config.pdnd.anpr; | ||
|
||
import it.gov.pagopa.payhub.pdnd.config.pdnd.PdndServiceIntegratedConfig; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "app.pdnd.anpr.services.c003") | ||
public class AnprC003ServiceConfig extends PdndServiceIntegratedConfig { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/it/gov/pagopa/payhub/pdnd/config/pdnd/anpr/AnprC030ServiceConfig.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,11 @@ | ||
package it.gov.pagopa.payhub.pdnd.config.pdnd.anpr; | ||
|
||
import it.gov.pagopa.payhub.pdnd.config.pdnd.PdndServiceIntegratedConfig; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ConfigurationProperties(prefix = "app.pdnd.anpr.services.c030") | ||
public class AnprC030ServiceConfig extends PdndServiceIntegratedConfig { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/it/gov/pagopa/payhub/pdnd/connector/pdnd/client/PdndClient.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,7 @@ | ||
package it.gov.pagopa.payhub.pdnd.connector.pdnd.client; | ||
|
||
import it.gov.pagopa.payhub.pdnd.connector.pdnd.generated.dto.ClientCredentialsResponseDTO; | ||
|
||
public interface PdndClient { | ||
ClientCredentialsResponseDTO getAccessToken(String clientId, String clientAssertions); | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/it/gov/pagopa/payhub/pdnd/connector/pdnd/client/PdndClientImpl.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,30 @@ | ||
package it.gov.pagopa.payhub.pdnd.connector.pdnd.client; | ||
|
||
import it.gov.pagopa.payhub.pdnd.connector.pdnd.generated.ApiClient; | ||
import it.gov.pagopa.payhub.pdnd.connector.pdnd.generated.api.AuthApi; | ||
import it.gov.pagopa.payhub.pdnd.connector.pdnd.generated.dto.ClientCredentialsResponseDTO; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.web.client.RestTemplateBuilder; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Service | ||
public class PdndClientImpl implements PdndClient { | ||
|
||
private static final String CLIENT_ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"; | ||
private static final String GRANT_TYPE = "client_credentials"; | ||
private final AuthApi authApi; | ||
|
||
public PdndClientImpl(RestTemplateBuilder restTemplateBuilder, | ||
@Value("${app.pdnd.base-url}") String pdndBaseUrl) { | ||
RestTemplate restTemplate = restTemplateBuilder.build(); | ||
ApiClient apiClient = new ApiClient(restTemplate); | ||
apiClient.setBasePath(pdndBaseUrl); | ||
authApi = new AuthApi(apiClient); | ||
} | ||
|
||
@Override | ||
public ClientCredentialsResponseDTO getAccessToken(String clientId, String clientAssertions) { | ||
return authApi.createToken(clientAssertions, CLIENT_ASSERTION_TYPE, GRANT_TYPE, clientId); | ||
} | ||
} |
Oops, something went wrong.