@Test void retrieveRealmFromUrl() throws Exception { authenticationRealmAwareFilter.setEnableFilter(true); authenticationRealmAwareFilter.setRealmMandatory(true); authenticationRealmAwareFilter.setRealmUrlPattern("/security/{realm}/*"); MvcResult result = mockMvc.perform(post("/security/some_realm/users") .accept(MediaType.APPLICATION_JSON_VALUE) .contentType(MediaType.APPLICATION_JSON_VALUE) .content(getStub("security-users-test.json"))) .andDo(print()).andExpect(status().isCreated()).andReturn(); String realm = result.getResponse().getHeader(SecurityConstants.REALM_HEADER); String content = result.getResponse().getContentAsString(); Map<String, String> resultMap = objectMapper.readValue(content, HashMap.class); assertThat(realm, is("some_realm")); assertThat(resultMap.get("name"), is("Chuck")); assertThat(resultMap.get("lastName"), is("Norris")); }
private String retrieveRealmFromUrl(String url) { Matcher matcher = urlPattern.matcher(url); if (matcher.find()) { return matcher.group(1); } return null; }
AuthenticationRealmAwareFilter implements Filter { private String retrieveRealmFromUrl(String url) { Matcher matcher = urlPattern.matcher(url); if (matcher.find()) { return matcher.group(1); } return null; } }
AuthenticationRealmAwareFilter implements Filter { private String retrieveRealmFromUrl(String url) { Matcher matcher = urlPattern.matcher(url); if (matcher.find()) { return matcher.group(1); } return null; } @Autowired  AuthenticationRealmAwareFilter(OidcAuthenticationHelper oidcAuthenticationHelper); }
AuthenticationRealmAwareFilter implements Filter { private String retrieveRealmFromUrl(String url) { Matcher matcher = urlPattern.matcher(url); if (matcher.find()) { return matcher.group(1); } return null; } @Autowired  AuthenticationRealmAwareFilter(OidcAuthenticationHelper oidcAuthenticationHelper); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain); @Override void destroy(); @Value("${security.oidc.AuthenticationRealmAwareFilter.enable:true}") void setEnableFilter(boolean enableFilter); @Value("${security.oidc.AuthenticationRealmAwareFilter.realmUrlPattern:}") void setRealmUrlPattern(String realmUrlPattern); @Value("${security.oidc.AuthenticationRealmAwareFilter.filterApplyUrlRegex:}") void setFilterApplyUrlRegex(String filterApplyUrlRegex); @Value("${security.oidc.AuthenticationRealmAwareFilter.realmParamName:realm}") void setRealmParamName(String realmParamName); @Value("${security.oidc.AuthenticationRealmAwareFilter.isRealmMandatory:true}") void setRealmMandatory(boolean realmMandatory); @Value("#{'${security.oidc.AuthenticationRealmAwareFilter.filterApplyUrlList:}'.split(',')}") void setFilterApplyUrlList(List<String> filterApplyUrlList); @Value("#{'${security.oidc.AuthenticationRealmAwareFilter.filterIgnoreUrlList:}'.split(',')}") void setFilterIgnoreUrls(List<String> filterIgnoreUrlList); @Override String toString(); }
AuthenticationRealmAwareFilter implements Filter { private String retrieveRealmFromUrl(String url) { Matcher matcher = urlPattern.matcher(url); if (matcher.find()) { return matcher.group(1); } return null; } @Autowired  AuthenticationRealmAwareFilter(OidcAuthenticationHelper oidcAuthenticationHelper); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain); @Override void destroy(); @Value("${security.oidc.AuthenticationRealmAwareFilter.enable:true}") void setEnableFilter(boolean enableFilter); @Value("${security.oidc.AuthenticationRealmAwareFilter.realmUrlPattern:}") void setRealmUrlPattern(String realmUrlPattern); @Value("${security.oidc.AuthenticationRealmAwareFilter.filterApplyUrlRegex:}") void setFilterApplyUrlRegex(String filterApplyUrlRegex); @Value("${security.oidc.AuthenticationRealmAwareFilter.realmParamName:realm}") void setRealmParamName(String realmParamName); @Value("${security.oidc.AuthenticationRealmAwareFilter.isRealmMandatory:true}") void setRealmMandatory(boolean realmMandatory); @Value("#{'${security.oidc.AuthenticationRealmAwareFilter.filterApplyUrlList:}'.split(',')}") void setFilterApplyUrlList(List<String> filterApplyUrlList); @Value("#{'${security.oidc.AuthenticationRealmAwareFilter.filterIgnoreUrlList:}'.split(',')}") void setFilterIgnoreUrls(List<String> filterIgnoreUrlList); @Override String toString(); static final String BASE_REALM_REGEX; }