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;
}
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());
}
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;
}
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());
}
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;
}
Aggregations