org.springframework.security.authentication.AuthenticationTrustResolver Java Examples

The following examples show how to use org.springframework.security.authentication.AuthenticationTrustResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionsEndpointFilterTest.java    From webauthn4j-spring-security with Apache License 2.0 6 votes vote down vote up
@Test
public void doFilter_test() throws IOException, ServletException {
    OptionsProvider optionsProvider = mock(OptionsProvider.class);
    AttestationOptions attestationOptions = new AttestationOptions(null, null, null, null, null, Collections.emptyList(), null);
    when(optionsProvider.getAttestationOptions(any(), any(), any())).thenReturn(attestationOptions);
    AssertionOptions assertionOptions = new AssertionOptions(null, null, null, null, null, null);
    when(optionsProvider.getAssertionOptions(any(), any(), any())).thenReturn(assertionOptions);
    OptionsEndpointFilter optionsEndpointFilter = new OptionsEndpointFilter(optionsProvider, objectConverter);
    AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
    optionsEndpointFilter.setTrustResolver(trustResolver);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI(OptionsEndpointFilter.FILTER_URL);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain filterChain = new MockFilterChain();

    optionsEndpointFilter.doFilter(request, response, filterChain);
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
}
 
Example #2
Source File: OptionsEndpointFilterTest.java    From webauthn4j-spring-security with Apache License 2.0 6 votes vote down vote up
@Test
public void doFilter_with_error_test() throws IOException, ServletException {
    OptionsProvider optionsProvider = mock(OptionsProvider.class);
    doThrow(new RuntimeException()).when(optionsProvider).getAttestationOptions(any(), any(), any());
    OptionsEndpointFilter optionsEndpointFilter = new OptionsEndpointFilter(optionsProvider, objectConverter);
    AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
    optionsEndpointFilter.setTrustResolver(trustResolver);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI(OptionsEndpointFilter.FILTER_URL);
    MockHttpServletResponse response = new MockHttpServletResponse();
    MockFilterChain filterChain = new MockFilterChain();

    optionsEndpointFilter.doFilter(request, response, filterChain);
    assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value());
}
 
Example #3
Source File: OptionsEndpointFilterTest.java    From webauthn4j-spring-security with Apache License 2.0 5 votes vote down vote up
@Test
public void getter_setter_test() {
    OptionsEndpointFilter optionsEndpointFilter = new OptionsEndpointFilter(mock(OptionsProvider.class), objectConverter);
    AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl();
    optionsEndpointFilter.setTrustResolver(trustResolver);
    assertThat(optionsEndpointFilter.getTrustResolver()).isEqualTo(trustResolver);
}
 
Example #4
Source File: OAuth2MethodSecurityConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
private OAuth2MethodSecurityExpressionHandler getExpressionHandler(
		DefaultMethodSecurityExpressionHandler bean) {
	OAuth2MethodSecurityExpressionHandler handler = new OAuth2MethodSecurityExpressionHandler();
	handler.setApplicationContext(this.applicationContext);
	AuthenticationTrustResolver trustResolver = findInContext(AuthenticationTrustResolver.class);
	if (trustResolver != null) {
		handler.setTrustResolver(trustResolver);
	}
	handler.setExpressionParser(bean.getExpressionParser());
	return handler;
}
 
Example #5
Source File: OptionsEndpointFilter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public AuthenticationTrustResolver getTrustResolver() {
    return trustResolver;
}
 
Example #6
Source File: OptionsEndpointFilter.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
public void setTrustResolver(AuthenticationTrustResolver trustResolver) {
    this.trustResolver = trustResolver;
}
 
Example #7
Source File: WebSecurityBeanConfig.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
@Bean
public AuthenticationTrustResolver authenticationTrustResolver() {
    return new AuthenticationTrustResolverImpl();
}
 
Example #8
Source File: WebSecurityBeanConfig.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
@Bean
public AuthenticationTrustResolver authenticationTrustResolver() {
    return new AuthenticationTrustResolverImpl();
}
 
Example #9
Source File: MySecurityExpressionRoot.java    From tutorials with MIT License 4 votes vote down vote up
public void setTrustResolver(AuthenticationTrustResolver trustResolver) {
    this.trustResolver = trustResolver;
}