当前位置: 首页>>代码示例>>Java>>正文


Java OAuth2AccessDeniedHandler类代码示例

本文整理汇总了Java中org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler的典型用法代码示例。如果您正苦于以下问题:Java OAuth2AccessDeniedHandler类的具体用法?Java OAuth2AccessDeniedHandler怎么用?Java OAuth2AccessDeniedHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OAuth2AccessDeniedHandler类属于org.springframework.security.oauth2.provider.error包,在下文中一共展示了OAuth2AccessDeniedHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
 public void configure(final HttpSecurity http) throws Exception {
 	http
 		.requestMatchers().antMatchers("/doctor/**", "/rx/**", "/account/**")
 		.and()
 		.authorizeRequests()
 		.antMatchers(HttpMethod.GET,"/doctor/**").access("#oauth2.hasScope('doctor') and #oauth2.hasScope('read')")
.antMatchers(HttpMethod.POST,"/doctor/**").access("#oauth2.hasScope('doctor') and #oauth2.hasScope('write')")
.antMatchers(HttpMethod.GET,"/rx/**").access("#oauth2.hasScope('doctor') and #oauth2.hasScope('read')")
.antMatchers(HttpMethod.POST,"/rx/**").access("#oauth2.hasScope('doctor') and #oauth2.hasScope('write')")	
.antMatchers("/account/**").permitAll()
.and()
.exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler())
.and()
.csrf().disable();

 }
 
开发者ID:PacktPublishing,项目名称:Building-Web-Apps-with-Spring-5-and-Angular,代码行数:18,代码来源:ResourceServerOAuth2Config.java

示例2: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
    http.requestMatchers()
            .antMatchers("/oauth/token", "/fb/oauth/access_token")
            .and()
            .authorizeRequests()
            .anyRequest()
            .authenticated()
            .and()
            .addFilterAfter(clientCredentialsTokenEndpointFilter(), BasicAuthenticationFilter.class)
            .addFilterAfter(fbClientCredentialsTokenEndpointFilter(), BasicAuthenticationFilter.class)
            .httpBasic()
            .authenticationEntryPoint(clientAuthenticationEntryPoint())
            .and()
            .exceptionHandling()
            .accessDeniedHandler(new OAuth2AccessDeniedHandler());
}
 
开发者ID:osiam,项目名称:auth-server,代码行数:18,代码来源:OAuth2ClientCredentialsSecurity.java

示例3: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
  super.configure(http);
  http
      .authorizeRequests()
      .anyRequest()
      .fullyAuthenticated()
      .anyRequest()
      .access("#oauth2.hasScopeMatching('openid') and #oauth2.hasScopeMatching('profile')");

  ResourceServerSecurityConfigurer configurer = new ResourceServerSecurityConfigurer();
  configurer.setBuilder(http);
  configurer.tokenServices(introspectingTokenService());

  CustomOAuth2ExceptionRenderer exceptionRenderer = new CustomOAuth2ExceptionRenderer();

  OAuth2AuthenticationEntryPoint authenticationEntryPoint = new OAuth2AuthenticationEntryPoint();
  authenticationEntryPoint.setExceptionRenderer(exceptionRenderer);
  configurer.authenticationEntryPoint(authenticationEntryPoint);

  OAuth2AccessDeniedHandler accessDeniedHandler = new OAuth2AccessDeniedHandler();
  accessDeniedHandler.setExceptionRenderer(exceptionRenderer);
  configurer.accessDeniedHandler(accessDeniedHandler);

  configurer.configure(http);
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:27,代码来源:AuthenticatedWebSecurityConfig.java

示例4: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
   	http
   		.anonymous()
   			.disable()
   		.authorizeRequests().anyRequest()
   			.fullyAuthenticated()
   			.and()
        .logout()
            .logoutSuccessUrl("/index.jsp")
            .logoutUrl("/logout.do")
            .invalidateHttpSession(true)
            .and()
   		.exceptionHandling()
   			.accessDeniedHandler(new OAuth2AccessDeniedHandler())
               ;
}
 
开发者ID:ishaigor,项目名称:rest-retro-sample,代码行数:18,代码来源:ClientSecurityConfigurer.java

示例5: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
	// @formatter:off
       http
           .authorizeRequests()
               .expressionHandler(new OAuth2WebSecurityExpressionHandler())
               .antMatchers("/**").fullyAuthenticated()
               .and()
           .requestMatchers()
               .antMatchers("/photos/**")
               .and()
           .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
               .and()
           .exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler())
               .and()
           .apply(new OAuth2ResourceServerConfigurer())
           	.tokenStore(tokenStore);
   	// @formatter:on
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:20,代码来源:ResourceServerConfigurationTests.java

示例6: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
  http.anonymous()//
      .disable()//
      .requestMatchers()//
      .antMatchers("/api/**")//
      .and().authorizeRequests()//
      .antMatchers("/api/**")//
      .fullyAuthenticated()//
      .and().exceptionHandling()//
      .accessDeniedHandler(new OAuth2AccessDeniedHandler());
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:13,代码来源:ResourceServerConfiguration.java

示例7: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
    http.anonymous().disable().requestMatchers()
            .antMatchers("/user/**")
            .and().authorizeRequests().antMatchers("/user/**")
            .access("hasRole('USER')")
            .and().exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler());
}
 
开发者ID:AgainstWind,项目名称:spring-cloud-demos,代码行数:9,代码来源:ResourceServerConfig.java

示例8: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
    http.
            anonymous().disable()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .authorizeRequests().antMatchers("/user/**").authenticated()
            .and()
            .authorizeRequests().antMatchers("/products/**").authenticated()
            .and()
            .httpBasic().disable()
            .exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler());
}
 
开发者ID:kyasar,项目名称:asam,代码行数:14,代码来源:ResourceServerConfiguration.java

示例9: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    resources.resourceId("oauth2res")
            .tokenServices(tokenService)
            .expressionHandler(new OsiamMethodSecurityExpressionHandler())
            .authenticationEntryPoint(oauthAuthenticationEntryPoint())
            .accessDeniedHandler(new OAuth2AccessDeniedHandler());
}
 
开发者ID:osiam,项目名称:auth-server,代码行数:9,代码来源:OAuth2ResourceServerConfig.java

示例10: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
	// @formatter:off
       http
           .authorizeRequests()
               .expressionHandler(new OAuth2WebSecurityExpressionHandler())
               .antMatchers("/photos").access("#oauth2.denyOAuthClient() and hasRole('ROLE_USER') or #oauth2.hasScope('read')")
               .antMatchers("/photos/trusted/**").access("#oauth2.denyOAuthClient() and hasRole('ROLE_USER') or #oauth2.hasScope('trust')")
               .antMatchers("/photos/user/**").access("#oauth2.denyOAuthClient() and hasRole('ROLE_USER') or #oauth2.hasScope('trust')")
               .antMatchers("/photos/**").access("#oauth2.denyOAuthClient() and hasRole('ROLE_USER') or #oauth2.hasScope('read')")
            .regexMatchers(HttpMethod.DELETE, "/oauth/users/([^/].*?)/tokens/.*")
                .access("#oauth2.clientHasRole('ROLE_CLIENT') and (hasRole('ROLE_USER') or #oauth2.isClient()) and #oauth2.hasScope('write')")
            .regexMatchers(HttpMethod.GET, "/oauth/users/.*")
                .access("#oauth2.clientHasRole('ROLE_CLIENT') and (hasRole('ROLE_USER') or #oauth2.isClient()) and #oauth2.hasScope('read')")
            .regexMatchers(HttpMethod.GET, "/oauth/clients/.*")
                .access("#oauth2.clientHasRole('ROLE_CLIENT') and #oauth2.isClient() and #oauth2.hasScope('read')")
               .and()
           .requestMatchers()
               .antMatchers("/photos/**", "/oauth/users/**", "/oauth/clients/**")
               .and()
           .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER)
               .and()
           .exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler())
               .and()
           // CSRF protection is awkward for machine clients
           .csrf()
               .requireCsrfProtectionMatcher(new AntPathRequestMatcher("/oauth/**")).disable()
           .apply(new OAuth2ResourceServerConfigurer()).tokenStore(tokenStore)
               .resourceId(SPARKLR_RESOURCE_ID);
   	// @formatter:on
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:32,代码来源:OAuth2ServerConfig.java

示例11: oauth2AccessDeniedHandler

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Bean
public OAuth2AccessDeniedHandler oauth2AccessDeniedHandler() {
    return new OAuth2AccessDeniedHandler();
}
 
开发者ID:openmg,项目名称:metagraph-auth,代码行数:5,代码来源:AuthorizationServerConfigurer.java

示例12: configure

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
    http.anonymous().disable().requestMatchers().antMatchers("/register", "/statistic", "/registerByAccount")
            .and().authorizeRequests().antMatchers("/register", "/statistic", "/registerByAccount").access("hasRole('ROLE_USER')")
            .and().exceptionHandling().accessDeniedHandler(new OAuth2AccessDeniedHandler());
}
 
开发者ID:andrsam,项目名称:urlshortener,代码行数:7,代码来源:ResourceServerConfiguration.java

示例13: oAuth2AccessDeniedHandler

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Bean
public OAuth2AccessDeniedHandler oAuth2AccessDeniedHandler() {
    return new OAuth2AccessDeniedHandler();
}
 
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:5,代码来源:AuthorizationServerConfiguration.java

示例14: oauth2AccessDeniedHandler

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Bean
public OAuth2AccessDeniedHandler oauth2AccessDeniedHandler(){
	OAuth2AccessDeniedHandler dh = new OAuth2AccessDeniedHandler();
	dh.setExceptionRenderer(oauth2ExceptionRenderer());
	return dh;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:7,代码来源:OAuth2CustomResultConfiguration.java

示例15: oauthAccessDeniedHandler

import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Bean
public OAuth2AccessDeniedHandler oauthAccessDeniedHandler() {
    return new OAuth2AccessDeniedHandler();
}
 
开发者ID:osiam,项目名称:resource-server,代码行数:5,代码来源:ResourceServer.java


注:本文中的org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。