diff --git a/src/main/java/eu/h2020/symbiote/client/AbstractSymbIoTeClientFactory.java b/src/main/java/eu/h2020/symbiote/client/AbstractSymbIoTeClientFactory.java index 5b669df..7ba5f07 100644 --- a/src/main/java/eu/h2020/symbiote/client/AbstractSymbIoTeClientFactory.java +++ b/src/main/java/eu/h2020/symbiote/client/AbstractSymbIoTeClientFactory.java @@ -3,6 +3,7 @@ import eu.h2020.symbiote.client.feign.SymbIoTeFeignClientFactory; import eu.h2020.symbiote.client.interfaces.*; import eu.h2020.symbiote.security.commons.exceptions.custom.SecurityHandlerException; +import eu.h2020.symbiote.security.communication.IAAMClient; import java.security.NoSuchAlgorithmException; @@ -45,6 +46,8 @@ public static AbstractSymbIoTeClientFactory getFactory(Config config) public abstract PRClient getPRClient(); + public abstract IAAMClient getAAMClient(); + /** * The type of factory. For now there is just one type but we followed the abstract factory pattern to facilitate * future extension diff --git a/src/main/java/eu/h2020/symbiote/client/feign/SymbIoTeFeignClientFactory.java b/src/main/java/eu/h2020/symbiote/client/feign/SymbIoTeFeignClientFactory.java index 219ff15..6ad45bb 100644 --- a/src/main/java/eu/h2020/symbiote/client/feign/SymbIoTeFeignClientFactory.java +++ b/src/main/java/eu/h2020/symbiote/client/feign/SymbIoTeFeignClientFactory.java @@ -4,7 +4,12 @@ import eu.h2020.symbiote.client.interfaces.*; import eu.h2020.symbiote.security.ClientSecurityHandlerFactory; import eu.h2020.symbiote.security.commons.exceptions.custom.SecurityHandlerException; +import eu.h2020.symbiote.security.communication.AAMClient; +import eu.h2020.symbiote.security.communication.IAAMClient; +import eu.h2020.symbiote.security.communication.payloads.AAM; import eu.h2020.symbiote.security.handler.ISecurityHandler; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; @@ -12,6 +17,7 @@ import javax.net.ssl.X509TrustManager; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; +import java.util.Map; /** * Factory for creating Feign symbIoTe clients @@ -20,6 +26,8 @@ */ public class SymbIoTeFeignClientFactory extends AbstractSymbIoTeClientFactory { + private static final Log logger = LogFactory.getLog(SymbIoTeFeignClientFactory.class); + private final ISecurityHandler securityHandler; private final String coreAddress; private final String homePlatformId; @@ -99,4 +107,15 @@ public RAPClient getRapClient() { public PRClient getPRClient() { return new FeignPRClient(securityHandler, homePlatformId, username, password, clientId); } + + @Override + public IAAMClient getAAMClient() { + try { + Map availableAAMs = securityHandler.getAvailableAAMs(); + return new AAMClient(availableAAMs.get(homePlatformId).getAamAddress()); + } catch (SecurityHandlerException e) { + logger.error("Could not create AAMClient", e); + } + return null; + } }