Java 类org.springframework.boot.autoconfigure.security.oauth2.method.OAuth2MethodSecurityConfiguration 实例源码

项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultPrePostSecurityAnnotations() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(PrePostAnnotationSecurityMetadataSource.class.getName());
    verifyAuthentication(config);
}
项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testClassicSecurityAnnotationOverride() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    this.context.register(SecuredEnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(SecuredAnnotationSecurityMetadataSource.class.getName());
    verifyAuthentication(config, HttpStatus.OK);
}
项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testJsr250SecurityAnnotationOverride() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    this.context.register(Jsr250EnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(Jsr250MethodSecurityMetadataSource.class.getName());
    verifyAuthentication(config, HttpStatus.OK);
}
项目:spring-boot-concourse    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultPrePostSecurityAnnotations() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(PrePostAnnotationSecurityMetadataSource.class.getName());
    verifyAuthentication(config);
}
项目:spring-boot-concourse    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testClassicSecurityAnnotationOverride() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(SecuredEnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(SecuredAnnotationSecurityMetadataSource.class.getName());
    verifyAuthentication(config, HttpStatus.OK);
}
项目:spring-boot-concourse    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testJsr250SecurityAnnotationOverride() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Jsr250EnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(Jsr250MethodSecurityMetadataSource.class.getName());
    verifyAuthentication(config, HttpStatus.OK);
}
项目:contestparser    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultConfiguration() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(AUTHORIZATION_SERVER_CONFIG);
    this.context.getBean(RESOURCE_SERVER_CONFIG);
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(BaseClientDetails.class);
    AuthorizationEndpoint endpoint = this.context
            .getBean(AuthorizationEndpoint.class);
    UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils
            .getField(endpoint, "userApprovalHandler");
    ClientDetailsService clientDetailsService = this.context
            .getBean(ClientDetailsService.class);
    ClientDetails clientDetails = clientDetailsService
            .loadClientByClientId(config.getClientId());
    assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService), equalTo(true));
    assertThat(AopUtils.getTargetClass(clientDetailsService).getName(),
            is(equalTo(InMemoryClientDetailsService.class.getName())));
    assertThat(handler instanceof ApprovalStoreUserApprovalHandler, equalTo(true));
    assertThat(clientDetails, equalTo(config));
    verifyAuthentication(config);
}
项目:contestparser    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultPrePostSecurityAnnotations() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size(), equalTo(1));
    assertThat(sources.get(0).getClass().getName(),
            equalTo(PrePostAnnotationSecurityMetadataSource.class.getName()));
    verifyAuthentication(config);
}
项目:contestparser    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testClassicSecurityAnnotationOverride() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(SecuredEnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size(), equalTo(1));
    assertThat(sources.get(0).getClass().getName(),
            equalTo(SecuredAnnotationSecurityMetadataSource.class.getName()));
    verifyAuthentication(config, HttpStatus.OK);
}
项目:contestparser    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testJsr250SecurityAnnotationOverride() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Jsr250EnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size(), equalTo(1));
    assertThat(sources.get(0).getClass().getName(),
            equalTo(Jsr250MethodSecurityMetadataSource.class.getName()));
    verifyAuthentication(config, HttpStatus.OK);
}
项目:spring-security-oauth2-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultConfiguration() {
    this.context = new AnnotationConfigServletWebServerApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(AUTHORIZATION_SERVER_CONFIG);
    this.context.getBean(RESOURCE_SERVER_CONFIG);
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(BaseClientDetails.class);
    AuthorizationEndpoint endpoint = this.context
            .getBean(AuthorizationEndpoint.class);
    UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils
            .getField(endpoint, "userApprovalHandler");
    ClientDetailsService clientDetailsService = this.context
            .getBean(ClientDetailsService.class);
    ClientDetails clientDetails = clientDetailsService
            .loadClientByClientId(config.getClientId());
    assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService)).isTrue();
    assertThat(AopUtils.getTargetClass(clientDetailsService).getName())
            .isEqualTo(InMemoryClientDetailsService.class.getName());
    assertThat(handler).isInstanceOf(ApprovalStoreUserApprovalHandler.class);
    assertThat(clientDetails).isEqualTo(config);
    verifyAuthentication(config);
    assertThat(this.context.getBeanNamesForType(OAuth2RestOperations.class))
            .isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultConfiguration() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(AUTHORIZATION_SERVER_CONFIG);
    this.context.getBean(RESOURCE_SERVER_CONFIG);
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(BaseClientDetails.class);
    AuthorizationEndpoint endpoint = this.context
            .getBean(AuthorizationEndpoint.class);
    UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils
            .getField(endpoint, "userApprovalHandler");
    ClientDetailsService clientDetailsService = this.context
            .getBean(ClientDetailsService.class);
    ClientDetails clientDetails = clientDetailsService
            .loadClientByClientId(config.getClientId());
    assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService)).isTrue();
    assertThat(AopUtils.getTargetClass(clientDetailsService).getName())
            .isEqualTo(InMemoryClientDetailsService.class.getName());
    assertThat(handler).isInstanceOf(ApprovalStoreUserApprovalHandler.class);
    assertThat(clientDetails).isEqualTo(config);
    verifyAuthentication(config);
    assertThat(this.context.getBeanNamesForType(OAuth2RestOperations.class))
            .isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultPrePostSecurityAnnotations() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(PrePostAnnotationSecurityMetadataSource.class.getName());
    verifyAuthentication(config);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testClassicSecurityAnnotationOverride() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(SecuredEnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(SecuredAnnotationSecurityMetadataSource.class.getName());
    verifyAuthentication(config, HttpStatus.OK);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testJsr250SecurityAnnotationOverride() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(Jsr250EnabledConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(ClientDetails.class);
    DelegatingMethodSecurityMetadataSource source = this.context
            .getBean(DelegatingMethodSecurityMetadataSource.class);
    List<MethodSecurityMetadataSource> sources = source
            .getMethodSecurityMetadataSources();
    assertThat(sources.size()).isEqualTo(1);
    assertThat(sources.get(0).getClass().getName())
            .isEqualTo(Jsr250MethodSecurityMetadataSource.class.getName());
    verifyAuthentication(config, HttpStatus.OK);
}
项目:spring-boot-concourse    文件:OAuth2AutoConfigurationTests.java   
@Test
public void testDefaultConfiguration() {
    this.context = new AnnotationConfigEmbeddedWebApplicationContext();
    this.context.register(AuthorizationAndResourceServerConfiguration.class,
            MinimalSecureWebApplication.class);
    this.context.refresh();
    this.context.getBean(AUTHORIZATION_SERVER_CONFIG);
    this.context.getBean(RESOURCE_SERVER_CONFIG);
    this.context.getBean(OAuth2MethodSecurityConfiguration.class);
    ClientDetails config = this.context.getBean(BaseClientDetails.class);
    AuthorizationEndpoint endpoint = this.context
            .getBean(AuthorizationEndpoint.class);
    UserApprovalHandler handler = (UserApprovalHandler) ReflectionTestUtils
            .getField(endpoint, "userApprovalHandler");
    ClientDetailsService clientDetailsService = this.context
            .getBean(ClientDetailsService.class);
    ClientDetails clientDetails = clientDetailsService
            .loadClientByClientId(config.getClientId());
    assertThat(AopUtils.isJdkDynamicProxy(clientDetailsService)).isTrue();
    assertThat(AopUtils.getTargetClass(clientDetailsService).getName())
            .isEqualTo(InMemoryClientDetailsService.class.getName());
    assertThat(handler).isInstanceOf(ApprovalStoreUserApprovalHandler.class);
    assertThat(clientDetails).isEqualTo(config);
    verifyAuthentication(config);
    assertThat(this.context.getBeanNamesForType(OAuth2RestOperations.class))
            .isEmpty();
}