Skip to content

Commit

Permalink
Merge pull request #18 from pagopa/SLS-19
Browse files Browse the repository at this point in the history
[SLS-19] Rest client implementation for Identity Service
  • Loading branch information
alessio-cialini authored Apr 12, 2023
2 parents c7823bc + b9183e4 commit a3fc725
Show file tree
Hide file tree
Showing 40 changed files with 2,611 additions and 708 deletions.
3 changes: 3 additions & 0 deletions assertion-rest-client-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
testImplementation 'org.assertj:assertj-core:3.24.2'

testImplementation 'org.mockito:mockito-core:5.2.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'
//Mockserver for testing api
testImplementation 'org.mock-server:mockserver-netty:5.15.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal.api.DefaultApi;
import it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal.model.AssertionRef;
import it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal.model.LCUserInfo;
import it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal.model.OidcUserInfo;
import it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal.model.SamlUserInfo;
import it.pagopa.tech.lollipop.consumer.exception.LollipopAssertionNotFoundException;
import it.pagopa.tech.lollipop.consumer.exception.OidcAssertionNotSupported;
import it.pagopa.tech.lollipop.consumer.model.SamlAssertion;
import javax.inject.Inject;

Expand All @@ -30,10 +32,11 @@ public AssertionSimpleClient(ApiClient client) {
* @param assertionRef Assertion unique identification
* @return the retrieved assertion or null if the assertion is not supported (not SAML)
* @throws LollipopAssertionNotFoundException if some error occurred in the request
* @throws OidcAssertionNotSupported if the assertion retrieved is a OIDC token
*/
@Override
public SamlAssertion getAssertion(String jwt, String assertionRef)
throws LollipopAssertionNotFoundException {
throws LollipopAssertionNotFoundException, OidcAssertionNotSupported {
AssertionRef ref = new AssertionRef(assertionRef);

LCUserInfo responseAssertion;
Expand All @@ -53,6 +56,9 @@ public SamlAssertion getAssertion(String jwt, String assertionRef)
response.setAssertionData(assertionData);
return response;
}
if (responseAssertion.getActualInstance().getClass().equals(OidcUserInfo.class)) {
throw new OidcAssertionNotSupported("OIDC Claims not supported yet.");
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* (C)2023 */
package it.pagopa.tech.lollipop.consumer.assertion.client.simple;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class AssertionSimpleClientConfig {

@Builder.Default private String baseUri = "http://localhost:3000";

@Builder.Default private String assertionRequestEndpoint = "/assertions";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@
import it.pagopa.tech.lollipop.consumer.assertion.client.AssertionClient;
import it.pagopa.tech.lollipop.consumer.assertion.client.AssertionClientProvider;
import it.pagopa.tech.lollipop.consumer.assertion.client.simple.internal.ApiClient;
import javax.inject.Inject;

/** Provider class for retrieving an instance of {@link AssertionSimpleClient} */
public class AssertionSimpleClientProvider implements AssertionClientProvider {

private final AssertionSimpleClientConfig assertionClientConfig;

@Inject
public AssertionSimpleClientProvider(AssertionSimpleClientConfig config) {
this.assertionClientConfig = config;
}

/**
* Provide an instance of {@link AssertionSimpleClient}
*
* @return {@link AssertionSimpleClient}
*/
@Override
public AssertionClient provideClient() {
return new AssertionSimpleClient(new ApiClient());
return new AssertionSimpleClient(new ApiClient(assertionClientConfig));
}
}
Loading

0 comments on commit a3fc725

Please sign in to comment.