SamlResponseLoggerBinding implements SAMLBinding { @Override public boolean supports(InTransport transport) { if (!(transport instanceof HttpServletRequestAdapter)) { return false; } HttpServletRequest httpServletRequest = ((HttpServletRequestAdapter) transport).getWrappedRequest(); LOGGER.warn("Malformed SAML response. More details at log level DEBUG."); if (httpServletRequest == null) { LOGGER.debug("HttpServletRequest is null - no information to log"); return false; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Method: {}, Params (name/size): {}, Content-type: {}, Request-size: {}, {}: {}", httpServletRequest.getMethod(), describeParameters(httpServletRequest), httpServletRequest.getContentType(), httpServletRequest.getContentLength(), X_VCAP_REQUEST_ID_HEADER, httpServletRequest.getHeader(X_VCAP_REQUEST_ID_HEADER)); } return false; }  @Override boolean supports(InTransport transport); @Override boolean supports(OutTransport transport); @Override MessageDecoder getMessageDecoder(); @Override MessageEncoder getMessageEncoder(); @Override String getBindingURI(); @Override void getSecurityPolicy(List<SecurityPolicyRule> securityPolicy, SAMLMessageContext samlContext); static final String X_VCAP_REQUEST_ID_HEADER; }
@Test void doesNotFailWithSomethingOtherThanHttpServletRequestAdapter() { InputStreamInTransportAdapter inputStreamInTransportAdapter = new InputStreamInTransportAdapter(null); assertDoesNotThrow(() -> samlResponseLoggerBinding.supports(inputStreamInTransportAdapter)); }
@Test void doesNotFailWithNullServletRequest() { HttpServletRequestAdapter httpServletRequestAdapter = new HttpServletRequestAdapter(null); Configurator.setRootLevel(DEBUG); assertDoesNotThrow(() -> samlResponseLoggerBinding.supports(httpServletRequestAdapter)); }
@Test void doesNotFailWithNullParameterMap() { HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class); when(mockHttpServletRequest.getParameterMap()).thenReturn(null); HttpServletRequestAdapter httpServletRequestAdapter = new HttpServletRequestAdapter(mockHttpServletRequest); Configurator.setRootLevel(DEBUG); assertDoesNotThrow(() -> samlResponseLoggerBinding.supports(httpServletRequestAdapter)); }
@Test void doesNotFailWithNullParameter() { HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class); Map<String, String[]> parameters = new HashMap<>(); parameters.put(null, null); parameters.put("key1", null); parameters.put("key2", new String[]{null}); parameters.put("key3", new String[]{"value", null}); when(mockHttpServletRequest.getParameterMap()).thenReturn(parameters); HttpServletRequestAdapter httpServletRequestAdapter = new HttpServletRequestAdapter(mockHttpServletRequest); Configurator.setRootLevel(DEBUG); assertDoesNotThrow(() -> samlResponseLoggerBinding.supports(httpServletRequestAdapter)); }