@Test public void testGetBotUserAccountKey() throws RemoteApiException { doReturn(MOCK_DATA).when(apiClient) .doGet(API_PATH, hParams(), qParams(), UserKeyManagerData.class); UserKeyManagerData data = relayApiClient.getUserAccountKeyManagerData(MOCK_SESSION_TOKEN, MOCK_KM_TOKEN); assertEquals(MOCK_DATA, data); }
public UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession) { try { checkAuthToken(sessionToken); checkKMAuthToken(kmSession); String path = "/relay/keys/me"; StringBuffer cookie = new StringBuffer(SESSION_KEY_HEADER_PARAM); cookie.append("=").append(sessionToken).append("; "); cookie.append(KM_SESSION_TOKEN_HEADER_PARAM).append("=").append(kmSession); Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); headerParams.put(COOKIE_HEADER_PARAM, cookie.toString()); Map<String, String> queryParams = new HashMap<>(); return apiClient.doGet(path, headerParams, queryParams, UserKeyManagerData.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)); } }
RelayApiClient extends BasePodApiClient { public UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession) { try { checkAuthToken(sessionToken); checkKMAuthToken(kmSession); String path = "/relay/keys/me"; StringBuffer cookie = new StringBuffer(SESSION_KEY_HEADER_PARAM); cookie.append("=").append(sessionToken).append("; "); cookie.append(KM_SESSION_TOKEN_HEADER_PARAM).append("=").append(kmSession); Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); headerParams.put(COOKIE_HEADER_PARAM, cookie.toString()); Map<String, String> queryParams = new HashMap<>(); return apiClient.doGet(path, headerParams, queryParams, UserKeyManagerData.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)); } } }
RelayApiClient extends BasePodApiClient { public UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession) { try { checkAuthToken(sessionToken); checkKMAuthToken(kmSession); String path = "/relay/keys/me"; StringBuffer cookie = new StringBuffer(SESSION_KEY_HEADER_PARAM); cookie.append("=").append(sessionToken).append("; "); cookie.append(KM_SESSION_TOKEN_HEADER_PARAM).append("=").append(kmSession); Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); headerParams.put(COOKIE_HEADER_PARAM, cookie.toString()); Map<String, String> queryParams = new HashMap<>(); return apiClient.doGet(path, headerParams, queryParams, UserKeyManagerData.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)); } } RelayApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
RelayApiClient extends BasePodApiClient { public UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession) { try { checkAuthToken(sessionToken); checkKMAuthToken(kmSession); String path = "/relay/keys/me"; StringBuffer cookie = new StringBuffer(SESSION_KEY_HEADER_PARAM); cookie.append("=").append(sessionToken).append("; "); cookie.append(KM_SESSION_TOKEN_HEADER_PARAM).append("=").append(kmSession); Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); headerParams.put(COOKIE_HEADER_PARAM, cookie.toString()); Map<String, String> queryParams = new HashMap<>(); return apiClient.doGet(path, headerParams, queryParams, UserKeyManagerData.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)); } } RelayApiClient(HttpApiClient apiClient, LogMessageSource logMessage); UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession); }
RelayApiClient extends BasePodApiClient { public UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession) { try { checkAuthToken(sessionToken); checkKMAuthToken(kmSession); String path = "/relay/keys/me"; StringBuffer cookie = new StringBuffer(SESSION_KEY_HEADER_PARAM); cookie.append("=").append(sessionToken).append("; "); cookie.append(KM_SESSION_TOKEN_HEADER_PARAM).append("=").append(kmSession); Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); headerParams.put(COOKIE_HEADER_PARAM, cookie.toString()); Map<String, String> queryParams = new HashMap<>(); return apiClient.doGet(path, headerParams, queryParams, UserKeyManagerData.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)); } } RelayApiClient(HttpApiClient apiClient, LogMessageSource logMessage); UserKeyManagerData getUserAccountKeyManagerData(String sessionToken, String kmSession);  }