本文整理汇总了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());
}
示例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);
}
示例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())
;
}
示例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
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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
}
示例11: oauth2AccessDeniedHandler
import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Bean
public OAuth2AccessDeniedHandler oauth2AccessDeniedHandler() {
return new OAuth2AccessDeniedHandler();
}
示例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());
}
示例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;
}
示例15: oauthAccessDeniedHandler
import org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler; //导入依赖的package包/类
@Bean
public OAuth2AccessDeniedHandler oauthAccessDeniedHandler() {
return new OAuth2AccessDeniedHandler();
}