@Test public void test_hasApplicationId_correctApplicationId() throws Throwable { String signature = StreamUtils.copyToString(new ClassPathResource("data/signature").getInputStream(), StandardCharsets.UTF_8).trim(); mvc.perform(post("/cek/v1") .header(CLOVA_SIGNATURE_REQUEST_HEADER, signature) .content(CEKRequestGenerator.requestBodyBuilder() .intent("CEKRequestExtensionIdVerifierTest") .placeholder("applicationId", "bbb") .build()) .contentType(MediaType.APPLICATION_JSON)) .andDo(print()) .andExpect(status().isOk()); verify(handler).handleExtensionIdVerifierTest(); }
@Override public void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson, SystemContext system) throws SecurityException { if (this.applicationIds == null || this.applicationIds.isEmpty()) { return; } String applicationId = system.getApplication().getApplicationId(); if (StringUtils.isBlank(applicationId)) { throw new SecurityException("applicationId is missing."); } if (!this.applicationIds.contains(applicationId)) { throw new SecurityException(String.format("[%s] is not expected applicationId.", applicationId)); } }
CEKRequestExtensionIdVerifier implements CEKRequestVerifier { @Override public void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson, SystemContext system) throws SecurityException { if (this.applicationIds == null || this.applicationIds.isEmpty()) { return; } String applicationId = system.getApplication().getApplicationId(); if (StringUtils.isBlank(applicationId)) { throw new SecurityException("applicationId is missing."); } if (!this.applicationIds.contains(applicationId)) { throw new SecurityException(String.format("[%s] is not expected applicationId.", applicationId)); } } }
CEKRequestExtensionIdVerifier implements CEKRequestVerifier { @Override public void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson, SystemContext system) throws SecurityException { if (this.applicationIds == null || this.applicationIds.isEmpty()) { return; } String applicationId = system.getApplication().getApplicationId(); if (StringUtils.isBlank(applicationId)) { throw new SecurityException("applicationId is missing."); } if (!this.applicationIds.contains(applicationId)) { throw new SecurityException(String.format("[%s] is not expected applicationId.", applicationId)); } } CEKRequestExtensionIdVerifier(Collection<String> applicationIds); }
CEKRequestExtensionIdVerifier implements CEKRequestVerifier { @Override public void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson, SystemContext system) throws SecurityException { if (this.applicationIds == null || this.applicationIds.isEmpty()) { return; } String applicationId = system.getApplication().getApplicationId(); if (StringUtils.isBlank(applicationId)) { throw new SecurityException("applicationId is missing."); } if (!this.applicationIds.contains(applicationId)) { throw new SecurityException(String.format("[%s] is not expected applicationId.", applicationId)); } } CEKRequestExtensionIdVerifier(Collection<String> applicationIds); @Override void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson,
                       SystemContext system); }
CEKRequestExtensionIdVerifier implements CEKRequestVerifier { @Override public void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson, SystemContext system) throws SecurityException { if (this.applicationIds == null || this.applicationIds.isEmpty()) { return; } String applicationId = system.getApplication().getApplicationId(); if (StringUtils.isBlank(applicationId)) { throw new SecurityException("applicationId is missing."); } if (!this.applicationIds.contains(applicationId)) { throw new SecurityException(String.format("[%s] is not expected applicationId.", applicationId)); } } CEKRequestExtensionIdVerifier(Collection<String> applicationIds); @Override void verify(HttpServletRequest request, CEKRequestMessage requestMessage, String requestJson,
                       SystemContext system);  }