Search in sources :

Example 1 with ExtensionAppTokens

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

the class PodAuthController method handleRequest.

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String qs = request.getQueryString();
    Map<String, String> params = decodeQuery(qs);
    Map<String, Object> appData = new HashMap<>();
    appData.put("circleOfTrust", circleOfTrust);
    appData.put("appId", appIdentity.getCommonName());
    if ((params.containsKey("podId")) && (this.circleOfTrust != CircleOfTrust.OFF)) {
        // do circle of trust if pod id is set.
        String podId = params.get("podId");
        String appToken = appTokenStrategy.generateAppToken();
        ExtensionAppTokens tokens = queryStrategies(podId, appToken);
        appTokenStrategy.storeAppToken(appToken, tokens.getSymphonyToken());
        appData.put("tokenA", tokens.getAppToken());
        appData.put("appId", tokens.getAppId());
        appData.put("expireAt", tokens.getExpireAt());
    }
    ModelAndView mv = new ModelAndView(v, appData);
    return mv;
}
Also used : ExtensionAppTokens(com.symphony.api.model.ExtensionAppTokens) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 2 with ExtensionAppTokens

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

the class TokenRequestIT method doRequestToken.

@Test
public void doRequestToken() throws Exception {
    ExtensionAppTokens eat = cpts.getTokens("abc123", "develop");
    Assertions.assertNotNull(eat.getSymphonyToken());
    Assertions.assertEquals("symphony-practice-app", eat.getAppId());
    Assertions.assertEquals("abc123", eat.getAppToken());
}
Also used : ExtensionAppTokens(com.symphony.api.model.ExtensionAppTokens) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ExtensionAppTokens

use of com.symphony.api.model.ExtensionAppTokens 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 4 with ExtensionAppTokens

use of com.symphony.api.model.ExtensionAppTokens 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 5 with ExtensionAppTokens

use of com.symphony.api.model.ExtensionAppTokens 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)

Aggregations

ExtensionAppTokens (com.symphony.api.model.ExtensionAppTokens)6 CertificateAuthenticationApi (com.symphony.api.authenticator.CertificateAuthenticationApi)4 ExtensionAppAuthenticateRequest (com.symphony.api.model.ExtensionAppAuthenticateRequest)4 Test (org.junit.jupiter.api.Test)3 AbstractApiBuilder (com.symphony.api.bindings.AbstractApiBuilder)2 ConfigurableApiBuilder (com.symphony.api.bindings.ConfigurableApiBuilder)2 AbstractTest (org.finos.symphony.toolkit.spring.app.AbstractTest)2 ApiBuilder (com.symphony.api.bindings.ApiBuilder)1 HashMap (java.util.HashMap)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1