Search in sources :

Example 1 with ExtensionAppAuthenticateRequest

use of com.symphony.api.model.ExtensionAppAuthenticateRequest in project spring-bot by finos.

the class PodInfoStoreTokenStrategy method certBasedRequest.

@Override
protected ExtensionAppTokens certBasedRequest(String appToken, PodInfo pod) throws Exception {
    ApiBuilder ab = setupApiBuilder(pod, pod.getPayload().getSessionAuthUrl());
    CertificateAuthenticationApi aa = ab.getApi(CertificateAuthenticationApi.class);
    ExtensionAppAuthenticateRequest ar = new ExtensionAppAuthenticateRequest();
    ar.setAppToken(appToken);
    ExtensionAppTokens out = aa.v1AuthenticateExtensionAppPost(ar);
    return out;
}
Also used : ExtensionAppTokens(com.symphony.api.model.ExtensionAppTokens) ExtensionAppAuthenticateRequest(com.symphony.api.model.ExtensionAppAuthenticateRequest) CertificateAuthenticationApi(com.symphony.api.authenticator.CertificateAuthenticationApi) ApiBuilder(com.symphony.api.bindings.ApiBuilder) ConfigurableApiBuilder(com.symphony.api.bindings.ConfigurableApiBuilder)

Example 2 with ExtensionAppAuthenticateRequest

use of com.symphony.api.model.ExtensionAppAuthenticateRequest in project spring-bot by finos.

the class PodAuthControllerByFileTest method testAuthentication.

@Test
public void testAuthentication() throws Exception {
    Mockito.when(abf.getObject()).thenReturn(new AbstractApiBuilder() {

        @SuppressWarnings("unchecked")
        @Override
        public <X> X getApi(Class<X> c) {
            Assertions.assertEquals("https://your.pod.domain:8444/sessionauth", this.url);
            Assertions.assertEquals(CertificateAuthenticationApi.class, c);
            Assertions.assertEquals("myproxy.com", this.proxyHost);
            return (X) authApi;
        }
    });
    Mockito.when(authApi.v1AuthenticateExtensionAppPost(Mockito.any())).thenAnswer(i -> {
        ExtensionAppAuthenticateRequest ar = (ExtensionAppAuthenticateRequest) i.getArgument(0);
        return new ExtensionAppTokens().appId("appid123").appToken(ar.getAppToken()).symphonyToken("Sym123");
    });
    this.mockMvc.perform(get("/symphony-app/podAuth?podId=9999").contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(jsonPath("$.appId", containsString("appid123"))).andExpect(jsonPath("$.tokenA", containsString("someAppId/"))).andExpect(status().isOk());
}
Also used : ExtensionAppTokens(com.symphony.api.model.ExtensionAppTokens) ExtensionAppAuthenticateRequest(com.symphony.api.model.ExtensionAppAuthenticateRequest) AbstractApiBuilder(com.symphony.api.bindings.AbstractApiBuilder) CertificateAuthenticationApi(com.symphony.api.authenticator.CertificateAuthenticationApi) Test(org.junit.jupiter.api.Test) AbstractTest(org.finos.symphony.toolkit.spring.app.AbstractTest)

Example 3 with ExtensionAppAuthenticateRequest

use of com.symphony.api.model.ExtensionAppAuthenticateRequest in project spring-bot by finos.

the class ConfiguredPodTokenStrategy method certBasedRequest.

protected ExtensionAppTokens certBasedRequest(String appToken, PodProperties pod) throws Exception {
    ConfigurableApiBuilder ab = abf.getObject();
    pod.getSessionAuth().configure(ab, new ApiWrapper[] {}, appIdentity, trustManagers);
    CertificateAuthenticationApi aa = ab.getApi(CertificateAuthenticationApi.class);
    ExtensionAppAuthenticateRequest ar = new ExtensionAppAuthenticateRequest();
    ar.setAppToken(appToken);
    ExtensionAppTokens out = aa.v1AuthenticateExtensionAppPost(ar);
    return out;
}
Also used : ExtensionAppTokens(com.symphony.api.model.ExtensionAppTokens) ConfigurableApiBuilder(com.symphony.api.bindings.ConfigurableApiBuilder) ExtensionAppAuthenticateRequest(com.symphony.api.model.ExtensionAppAuthenticateRequest) CertificateAuthenticationApi(com.symphony.api.authenticator.CertificateAuthenticationApi)

Example 4 with ExtensionAppAuthenticateRequest

use of com.symphony.api.model.ExtensionAppAuthenticateRequest in project spring-bot by finos.

the class PodAuthControllerByConfigTest method testAuthentication.

@Test
public void testAuthentication() throws Exception {
    Mockito.when(abf.getObject()).thenReturn(new AbstractApiBuilder() {

        @SuppressWarnings("unchecked")
        @Override
        public <X> X getApi(Class<X> c) {
            Assertions.assertEquals("http://blah.com/sessionauth", this.url);
            Assertions.assertEquals(CertificateAuthenticationApi.class, c);
            return (X) authApi;
        }
    });
    Mockito.when(authApi.v1AuthenticateExtensionAppPost(Mockito.any())).thenAnswer(i -> {
        ExtensionAppAuthenticateRequest ar = (ExtensionAppAuthenticateRequest) i.getArgument(0);
        return new ExtensionAppTokens().appId("appid123").appToken(ar.getAppToken()).symphonyToken("Sym123");
    });
    this.mockMvc.perform(get("/symphony-app/podAuth?podId=666").contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(jsonPath("$.appId", containsString("appid123"))).andExpect(jsonPath("$.tokenA", containsString("someAppId/"))).andExpect(status().isOk());
}
Also used : ExtensionAppTokens(com.symphony.api.model.ExtensionAppTokens) ExtensionAppAuthenticateRequest(com.symphony.api.model.ExtensionAppAuthenticateRequest) AbstractApiBuilder(com.symphony.api.bindings.AbstractApiBuilder) CertificateAuthenticationApi(com.symphony.api.authenticator.CertificateAuthenticationApi) Test(org.junit.jupiter.api.Test) AbstractTest(org.finos.symphony.toolkit.spring.app.AbstractTest)

Aggregations

CertificateAuthenticationApi (com.symphony.api.authenticator.CertificateAuthenticationApi)4 ExtensionAppAuthenticateRequest (com.symphony.api.model.ExtensionAppAuthenticateRequest)4 ExtensionAppTokens (com.symphony.api.model.ExtensionAppTokens)4 AbstractApiBuilder (com.symphony.api.bindings.AbstractApiBuilder)2 ConfigurableApiBuilder (com.symphony.api.bindings.ConfigurableApiBuilder)2 AbstractTest (org.finos.symphony.toolkit.spring.app.AbstractTest)2 Test (org.junit.jupiter.api.Test)2 ApiBuilder (com.symphony.api.bindings.ApiBuilder)1