-
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.
Merge pull request #27 from pagopa/SLS-26
[SLS-26] Implemented provider for idp certifications
- Loading branch information
Showing
17 changed files
with
512 additions
and
91 deletions.
There are no files selected for viewing
8 changes: 7 additions & 1 deletion
8
core/src/main/java/it/pagopa/tech/lollipop/consumer/idp/IdpCertProvider.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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
/* (C)2023 */ | ||
package it.pagopa.tech.lollipop.consumer.idp; | ||
|
||
import it.pagopa.tech.lollipop.consumer.exception.CertDataNotFoundException; | ||
import it.pagopa.tech.lollipop.consumer.exception.CertDataTagListNotFoundException; | ||
import it.pagopa.tech.lollipop.consumer.model.IdpCertData; | ||
import java.util.List; | ||
|
||
public interface IdpCertProvider { | ||
|
||
boolean getIdpCertData(String assertionInstant, String entityId); | ||
List<IdpCertData> getIdpCertData(String assertionInstant, String entityId) | ||
throws CertDataTagListNotFoundException, CertDataNotFoundException; | ||
} |
31 changes: 31 additions & 0 deletions
31
core/src/main/java/it/pagopa/tech/lollipop/consumer/idp/impl/IdpCertProviderFactoryImpl.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,31 @@ | ||
/* (C)2023 */ | ||
package it.pagopa.tech.lollipop.consumer.idp.impl; | ||
|
||
import it.pagopa.tech.lollipop.consumer.idp.IdpCertProvider; | ||
import it.pagopa.tech.lollipop.consumer.idp.IdpCertProviderFactory; | ||
import it.pagopa.tech.lollipop.consumer.idp.client.IdpCertClientProvider; | ||
import javax.inject.Inject; | ||
|
||
/** | ||
* Implementation of {@link IdpCertProviderFactory}, used to create instances of {@link | ||
* IdpCertProviderImpl} | ||
*/ | ||
public class IdpCertProviderFactoryImpl implements IdpCertProviderFactory { | ||
|
||
private final IdpCertClientProvider idpCertClientProvider; | ||
|
||
@Inject | ||
public IdpCertProviderFactoryImpl(IdpCertClientProvider idpCertClientProvider) { | ||
this.idpCertClientProvider = idpCertClientProvider; | ||
} | ||
|
||
/** | ||
* Factory for creating an instance of {@link IdpCertProvider} | ||
* | ||
* @return an instance of {@link IdpCertProviderImpl} | ||
*/ | ||
@Override | ||
public IdpCertProvider create() { | ||
return new IdpCertProviderImpl(idpCertClientProvider.provideClient()); | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
...c/main/java/it/pagopa/tech/lollipop/consumer/idp/impl/IdpCertProviderFactoryImplStub.java
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
core/src/main/java/it/pagopa/tech/lollipop/consumer/idp/impl/IdpCertProviderImpl.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,56 @@ | ||
/* (C)2023 */ | ||
package it.pagopa.tech.lollipop.consumer.idp.impl; | ||
|
||
import it.pagopa.tech.lollipop.consumer.exception.CertDataNotFoundException; | ||
import it.pagopa.tech.lollipop.consumer.exception.CertDataTagListNotFoundException; | ||
import it.pagopa.tech.lollipop.consumer.idp.IdpCertProvider; | ||
import it.pagopa.tech.lollipop.consumer.idp.client.IdpCertClient; | ||
import it.pagopa.tech.lollipop.consumer.idp.storage.IdpCertStorageConfig; | ||
import it.pagopa.tech.lollipop.consumer.model.IdpCertData; | ||
import java.util.List; | ||
import javax.inject.Inject; | ||
|
||
public class IdpCertProviderImpl implements IdpCertProvider { | ||
|
||
private IdpCertClient idpCertClient; | ||
|
||
@Inject | ||
public IdpCertProviderImpl(IdpCertClient idpCertClient) { | ||
this.idpCertClient = idpCertClient; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* <p>Retrieve the certification data of the given entityId issued in the same timeframe as the | ||
* issue instant of the SAML assertion, first looking in the storage if enabled ({@link | ||
* IdpCertStorageConfig}) and then, if not found, through the client {@link IdpCertClient}. If | ||
* the storage is enabled ({@link IdpCertStorageConfig}) the IdpCertData will be stored, after | ||
* being retrieved by the client. | ||
* | ||
* @param entityId Identity Provider ID | ||
* @param assertionInstant Assertion Issue Instant | ||
* @return the certifications issued before and after the timestamp instant | ||
* @throws CertDataTagListNotFoundException if an error occurred retrieving the list of tags or | ||
* filtering the tags with the instant | ||
* @throws CertDataNotFoundException if an error occurred retrieving the certification XML or if | ||
* data for the given entityId were not found | ||
*/ | ||
@Override | ||
public List<IdpCertData> getIdpCertData(String assertionInstant, String entityId) | ||
throws CertDataTagListNotFoundException, CertDataNotFoundException { | ||
if (assertionInstant == null | ||
|| assertionInstant.isBlank() | ||
|| entityId == null | ||
|| entityId.isBlank()) { | ||
String errMsg = | ||
String.format( | ||
"Cannot retrieve the identity provider cert data, assertion instant" | ||
+ " [%s] or entity id [%s] missing", | ||
assertionInstant, entityId); | ||
throw new IllegalArgumentException(errMsg); | ||
} | ||
|
||
return idpCertClient.getCertData(assertionInstant, entityId); | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
core/src/main/java/it/pagopa/tech/lollipop/consumer/idp/impl/IdpCertProviderImplStub.java
This file was deleted.
Oops, something went wrong.
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
14 changes: 14 additions & 0 deletions
14
core/src/main/java/it/pagopa/tech/lollipop/consumer/idp/storage/IdpCertStorageConfig.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,14 @@ | ||
/* (C)2023 */ | ||
package it.pagopa.tech.lollipop.consumer.idp.storage; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import lombok.Data; | ||
|
||
/** Configuration class for the idpCertData storage */ | ||
@Data | ||
public class IdpCertStorageConfig { | ||
|
||
private boolean idpCertDataStorageEnabled = true; | ||
private long storageEvictionDelay = 1L; | ||
private TimeUnit storageEvictionDelayTimeUnit = TimeUnit.MINUTES; | ||
} |
6 changes: 5 additions & 1 deletion
6
core/src/main/java/it/pagopa/tech/lollipop/consumer/idp/storage/IdpCertStorageProvider.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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
/* (C)2023 */ | ||
package it.pagopa.tech.lollipop.consumer.idp.storage; | ||
|
||
/** Interface for the provider used to create instances of {@link IdpCertStorage} */ | ||
public interface IdpCertStorageProvider { | ||
|
||
IdpCertStorage provideStorage(); | ||
/** | ||
* @return instance of {@link IdpCertStorage} | ||
*/ | ||
IdpCertStorage provideStorage(IdpCertStorageConfig storageConfig); | ||
} |
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
Oops, something went wrong.