@Test(expected = UnauthorizedAppException.class) public void testGetPodPublicCertificateUnauthorized() throws RemoteApiException { mockRemoteExceptionDoGet(401, "unauthorized"); authenticationAppApiClient.getPodPublicCertificate(APP_ID); }
public PodCertificate getPodPublicCertificate(String appId) { Map<String, String> headerParams = new HashMap<>(); headerParams.put("appId", appId); Map<String, String> queryParams = new HashMap<>(); try { return apiClient.doGet(CERTIFICATE_PATH, headerParams, queryParams, PodCertificate.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION, appId); throw new UnauthorizedAppException(message, e, solution); } if (e.getCode() == Response.Status.BAD_REQUEST.getStatusCode()) { String message = logMessage.getMessage(BAD_REQUEST_MESSAGE); String solution = logMessage.getMessage(BAD_REQUEST_MESSAGE_SOLUTION, appId); throw new InvalidAppTokenException(message, e, solution); } String message = logMessage.getMessage(POD_UNEXPECTED_MESSAGE); String solution = logMessage.getMessage(POD_UNEXPECTED_MESSAGE_SOLUTION); throw new UnexpectedAppAuthenticationException(message, e, solution); } }
AuthenticationAppApiClient { public PodCertificate getPodPublicCertificate(String appId) { Map<String, String> headerParams = new HashMap<>(); headerParams.put("appId", appId); Map<String, String> queryParams = new HashMap<>(); try { return apiClient.doGet(CERTIFICATE_PATH, headerParams, queryParams, PodCertificate.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION, appId); throw new UnauthorizedAppException(message, e, solution); } if (e.getCode() == Response.Status.BAD_REQUEST.getStatusCode()) { String message = logMessage.getMessage(BAD_REQUEST_MESSAGE); String solution = logMessage.getMessage(BAD_REQUEST_MESSAGE_SOLUTION, appId); throw new InvalidAppTokenException(message, e, solution); } String message = logMessage.getMessage(POD_UNEXPECTED_MESSAGE); String solution = logMessage.getMessage(POD_UNEXPECTED_MESSAGE_SOLUTION); throw new UnexpectedAppAuthenticationException(message, e, solution); } } }
AuthenticationAppApiClient { public PodCertificate getPodPublicCertificate(String appId) { Map<String, String> headerParams = new HashMap<>(); headerParams.put("appId", appId); Map<String, String> queryParams = new HashMap<>(); try { return apiClient.doGet(CERTIFICATE_PATH, headerParams, queryParams, PodCertificate.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION, appId); throw new UnauthorizedAppException(message, e, solution); } if (e.getCode() == Response.Status.BAD_REQUEST.getStatusCode()) { String message = logMessage.getMessage(BAD_REQUEST_MESSAGE); String solution = logMessage.getMessage(BAD_REQUEST_MESSAGE_SOLUTION, appId); throw new InvalidAppTokenException(message, e, solution); } String message = logMessage.getMessage(POD_UNEXPECTED_MESSAGE); String solution = logMessage.getMessage(POD_UNEXPECTED_MESSAGE_SOLUTION); throw new UnexpectedAppAuthenticationException(message, e, solution); } } AuthenticationAppApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
AuthenticationAppApiClient { public PodCertificate getPodPublicCertificate(String appId) { Map<String, String> headerParams = new HashMap<>(); headerParams.put("appId", appId); Map<String, String> queryParams = new HashMap<>(); try { return apiClient.doGet(CERTIFICATE_PATH, headerParams, queryParams, PodCertificate.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION, appId); throw new UnauthorizedAppException(message, e, solution); } if (e.getCode() == Response.Status.BAD_REQUEST.getStatusCode()) { String message = logMessage.getMessage(BAD_REQUEST_MESSAGE); String solution = logMessage.getMessage(BAD_REQUEST_MESSAGE_SOLUTION, appId); throw new InvalidAppTokenException(message, e, solution); } String message = logMessage.getMessage(POD_UNEXPECTED_MESSAGE); String solution = logMessage.getMessage(POD_UNEXPECTED_MESSAGE_SOLUTION); throw new UnexpectedAppAuthenticationException(message, e, solution); } } AuthenticationAppApiClient(HttpApiClient apiClient, LogMessageSource logMessage); AppToken authenticate(String appId, String appToken); PodCertificate getPodPublicCertificate(String appId); }
AuthenticationAppApiClient { public PodCertificate getPodPublicCertificate(String appId) { Map<String, String> headerParams = new HashMap<>(); headerParams.put("appId", appId); Map<String, String> queryParams = new HashMap<>(); try { return apiClient.doGet(CERTIFICATE_PATH, headerParams, queryParams, PodCertificate.class); } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION, appId); throw new UnauthorizedAppException(message, e, solution); } if (e.getCode() == Response.Status.BAD_REQUEST.getStatusCode()) { String message = logMessage.getMessage(BAD_REQUEST_MESSAGE); String solution = logMessage.getMessage(BAD_REQUEST_MESSAGE_SOLUTION, appId); throw new InvalidAppTokenException(message, e, solution); } String message = logMessage.getMessage(POD_UNEXPECTED_MESSAGE); String solution = logMessage.getMessage(POD_UNEXPECTED_MESSAGE_SOLUTION); throw new UnexpectedAppAuthenticationException(message, e, solution); } } AuthenticationAppApiClient(HttpApiClient apiClient, LogMessageSource logMessage); AppToken authenticate(String appId, String appToken); PodCertificate getPodPublicCertificate(String appId);  }