@Test public void testGetAppAuthenticationToken() throws RemoteApiException { doReturn(mockAppToken).when(httpClient).doGet(eq(PATH_GET_APP_TOKEN), anyMap(), anyMap(), eq(AppToken.class)); AppToken result = apiClient.getAppAuthenticationToken(MOCK_SESSION, MOCK_INTEGRATION_ID, MOCK_APP_TOKEN); assertEquals(mockAppToken, result); }
public AppToken getAppAuthenticationToken(String sessionToken, String integrationId, String applicationToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(applicationToken, TOKEN_APPLICATION); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/" + applicationToken; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doGet(path, headerParams, Collections.<String, String>emptyMap(), AppToken.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.NOT_FOUND.getStatusCode()) { return null; } if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } if (e.getCode() == Response.Status.FORBIDDEN.getStatusCode()) { String message = logMessage.getMessage(FORBIDDEN_MESSAGE); String solution = logMessage.getMessage(FORBIDDEN_MESSAGE_SOLUTION); throw new ForbiddenAuthException(message, solution); } throw new UnexpectedAuthException(logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } }
IntegrationAuthApiClient extends BasePodApiClient { public AppToken getAppAuthenticationToken(String sessionToken, String integrationId, String applicationToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(applicationToken, TOKEN_APPLICATION); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/" + applicationToken; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doGet(path, headerParams, Collections.<String, String>emptyMap(), AppToken.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.NOT_FOUND.getStatusCode()) { return null; } if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } if (e.getCode() == Response.Status.FORBIDDEN.getStatusCode()) { String message = logMessage.getMessage(FORBIDDEN_MESSAGE); String solution = logMessage.getMessage(FORBIDDEN_MESSAGE_SOLUTION); throw new ForbiddenAuthException(message, solution); } throw new UnexpectedAuthException(logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } }
IntegrationAuthApiClient extends BasePodApiClient { public AppToken getAppAuthenticationToken(String sessionToken, String integrationId, String applicationToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(applicationToken, TOKEN_APPLICATION); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/" + applicationToken; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doGet(path, headerParams, Collections.<String, String>emptyMap(), AppToken.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.NOT_FOUND.getStatusCode()) { return null; } if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } if (e.getCode() == Response.Status.FORBIDDEN.getStatusCode()) { String message = logMessage.getMessage(FORBIDDEN_MESSAGE); String solution = logMessage.getMessage(FORBIDDEN_MESSAGE_SOLUTION); throw new ForbiddenAuthException(message, solution); } throw new UnexpectedAuthException(logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } IntegrationAuthApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
IntegrationAuthApiClient extends BasePodApiClient { public AppToken getAppAuthenticationToken(String sessionToken, String integrationId, String applicationToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(applicationToken, TOKEN_APPLICATION); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/" + applicationToken; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doGet(path, headerParams, Collections.<String, String>emptyMap(), AppToken.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.NOT_FOUND.getStatusCode()) { return null; } if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } if (e.getCode() == Response.Status.FORBIDDEN.getStatusCode()) { String message = logMessage.getMessage(FORBIDDEN_MESSAGE); String solution = logMessage.getMessage(FORBIDDEN_MESSAGE_SOLUTION); throw new ForbiddenAuthException(message, solution); } throw new UnexpectedAuthException(logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } IntegrationAuthApiClient(HttpApiClient apiClient, LogMessageSource logMessage); void saveUserAuthData(String sessionToken, String integrationId,
      UserAuthorizationData userData); UserAuthorizationData getUserAuthData(String sessionToken, String integrationId,
      Long userId, String url); List<UserAuthorizationData> searchUserAuthData(String sessionToken, String integrationId,
      Map<String, String> filter); void saveAppAuthenticationToken(String sessionToken, String integrationId,
      AppToken appToken); AppToken getAppAuthenticationToken(String sessionToken, String integrationId,
      String applicationToken); }
IntegrationAuthApiClient extends BasePodApiClient { public AppToken getAppAuthenticationToken(String sessionToken, String integrationId, String applicationToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(applicationToken, TOKEN_APPLICATION); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/" + applicationToken; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doGet(path, headerParams, Collections.<String, String>emptyMap(), AppToken.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.NOT_FOUND.getStatusCode()) { return null; } if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } if (e.getCode() == Response.Status.FORBIDDEN.getStatusCode()) { String message = logMessage.getMessage(FORBIDDEN_MESSAGE); String solution = logMessage.getMessage(FORBIDDEN_MESSAGE_SOLUTION); throw new ForbiddenAuthException(message, solution); } throw new UnexpectedAuthException(logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } IntegrationAuthApiClient(HttpApiClient apiClient, LogMessageSource logMessage); void saveUserAuthData(String sessionToken, String integrationId,
      UserAuthorizationData userData); UserAuthorizationData getUserAuthData(String sessionToken, String integrationId,
      Long userId, String url); List<UserAuthorizationData> searchUserAuthData(String sessionToken, String integrationId,
      Map<String, String> filter); void saveAppAuthenticationToken(String sessionToken, String integrationId,
      AppToken appToken); AppToken getAppAuthenticationToken(String sessionToken, String integrationId,
      String applicationToken);  }