RedirectResolverFactoryBean implements FactoryBean<RedirectResolver> { @Override public RedirectResolver getObject() { NormalizedRedirectResolver defaultRedirectResolver = new NormalizedRedirectResolver(); defaultRedirectResolver.setMatchSubdomains(false); return allowUnsafeMatching ? new LegacyRedirectResolver() : defaultRedirectResolver; } RedirectResolverFactoryBean(
            @Value("${uaa.oauth.redirect_uri.allow_unsafe_matching:true}") boolean allowUnsafeMatching
    ); @Override RedirectResolver getObject(); @Override Class<?> getObjectType(); @Override boolean isSingleton();  }
@Test void allowUnsafeMatching_shouldReturnLegacyRedirectResolver() throws Exception { FactoryBean<RedirectResolver> factory = new RedirectResolverFactoryBean(true); assertThat(factory.getObject(), instanceOf(LegacyRedirectResolver.class)); }
@Test void disallowUnsafeMatching_shouldReturnSpringSecurityOauth2RedirectResolver_withDontMatchSubdomain() throws Exception { FactoryBean<RedirectResolver> factory = new RedirectResolverFactoryBean(false); RedirectResolver redirectResolver = factory.getObject(); assertThat(redirectResolver, instanceOf(DefaultRedirectResolver.class)); assertThat(ReflectionTestUtils.getField(redirectResolver, "matchSubdomains"), is(false)); }