@Test(expected = UnauthorizedUserException.class) public void testSaveAppAuthenticationTokenUnauthorized() throws RemoteApiException { RemoteApiException apiException = new RemoteApiException(401, "Unauthorized"); doThrow(apiException).when(httpClient).doPost(eq(PATH_AUTHENTICATE), anyMap(), anyMap(), any(AppToken.class), eq(AppToken.class)); apiClient.saveAppAuthenticationToken(MOCK_SESSION, MOCK_INTEGRATION_ID, mockAppToken); }
public void saveAppAuthenticationToken(String sessionToken, String integrationId, AppToken appToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(appToken.getAppToken(), TOKEN_APPLICATION); checkParam(appToken.getSymphonyToken(), TOKEN_SYMPHONY); AppToken appTokenWithoutAppId = new AppToken(null, appToken.getAppToken(), appToken.getSymphonyToken()); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), appTokenWithoutAppId, AppToken.class); } catch (RemoteApiException e) { 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 void saveAppAuthenticationToken(String sessionToken, String integrationId, AppToken appToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(appToken.getAppToken(), TOKEN_APPLICATION); checkParam(appToken.getSymphonyToken(), TOKEN_SYMPHONY); AppToken appTokenWithoutAppId = new AppToken(null, appToken.getAppToken(), appToken.getSymphonyToken()); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), appTokenWithoutAppId, AppToken.class); } catch (RemoteApiException e) { 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 void saveAppAuthenticationToken(String sessionToken, String integrationId, AppToken appToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(appToken.getAppToken(), TOKEN_APPLICATION); checkParam(appToken.getSymphonyToken(), TOKEN_SYMPHONY); AppToken appTokenWithoutAppId = new AppToken(null, appToken.getAppToken(), appToken.getSymphonyToken()); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), appTokenWithoutAppId, AppToken.class); } catch (RemoteApiException e) { 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 void saveAppAuthenticationToken(String sessionToken, String integrationId, AppToken appToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(appToken.getAppToken(), TOKEN_APPLICATION); checkParam(appToken.getSymphonyToken(), TOKEN_SYMPHONY); AppToken appTokenWithoutAppId = new AppToken(null, appToken.getAppToken(), appToken.getSymphonyToken()); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), appTokenWithoutAppId, AppToken.class); } catch (RemoteApiException e) { 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 void saveAppAuthenticationToken(String sessionToken, String integrationId, AppToken appToken) { try { checkAuthToken(sessionToken); checkParam(integrationId, INTEGRATION_ID); checkParam(appToken.getAppToken(), TOKEN_APPLICATION); checkParam(appToken.getSymphonyToken(), TOKEN_SYMPHONY); AppToken appTokenWithoutAppId = new AppToken(null, appToken.getAppToken(), appToken.getSymphonyToken()); String path = "/v1/configuration/" + apiClient.escapeString(integrationId) + "/authentication/"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), appTokenWithoutAppId, AppToken.class); } catch (RemoteApiException e) { 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);  }