本文整理汇总了Java中org.springframework.security.cas.web.CasAuthenticationFilter类的典型用法代码示例。如果您正苦于以下问题:Java CasAuthenticationFilter类的具体用法?Java CasAuthenticationFilter怎么用?Java CasAuthenticationFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CasAuthenticationFilter类属于org.springframework.security.cas.web包,在下文中一共展示了CasAuthenticationFilter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
void configure(CasAuthenticationFilter filter) {
if (requiresAuthenticationRequestMatcher != null) {
filter.setRequiresAuthenticationRequestMatcher(requiresAuthenticationRequestMatcher);
}
if (authenticationFailureHandler != null) {
filter.setAuthenticationFailureHandler(authenticationFailureHandler);
}
if (proxyAuthenticationFailureHandler != null) {
filter.setProxyAuthenticationFailureHandler(proxyAuthenticationFailureHandler);
}
if (authenticationSuccessHandler != null) {
filter.setAuthenticationSuccessHandler(authenticationSuccessHandler);
}
if (proxyReceptorUrl != null) {
filter.setProxyReceptorUrl(proxyReceptorUrl);
}
if (proxyGrantingTicketStorage != null) {
filter.setProxyGrantingTicketStorage(proxyGrantingTicketStorage);
}
if (serviceAuthenticationDetailsSource != null) {
filter.setAuthenticationDetailsSource(serviceAuthenticationDetailsSource);
}
}
开发者ID:kakawait,项目名称:cas-security-spring-boot-starter,代码行数:24,代码来源:CasAuthenticationFilterConfigurer.java
示例2: configure
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests() // 配置安全策略
.antMatchers("/", "/index").permitAll() // 定义首页请求不需要验证
.anyRequest().authenticated() // 其余的所有请求都需要验证
.and()
.logout()
.permitAll() // 定义logout不需要验证
.and()
.formLogin(); // 使用form表单登录
http.exceptionHandling().authenticationEntryPoint(casAuthenticationEntryPoint())
.and()
.addFilter(casAuthenticationFilter())
.addFilterBefore(requestSingleLogoutFilter(), LogoutFilter.class)
.addFilterBefore(singleSignOutFilter(), CasAuthenticationFilter.class);
// http.csrf().disable(); // 禁用CSRF
}
示例3: configure
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterAfter(new CsrfCookieGeneratorFilter(), CsrfFilter.class).exceptionHandling()
.authenticationEntryPoint(casAuthenticationEntryPoint()).and().addFilter(casAuthenticationFilter())
.addFilterBefore(singleSignOutFilter(), CasAuthenticationFilter.class)
.addFilterBefore(requestCasGlobalLogoutFilter(), LogoutFilter.class);
http.headers().frameOptions().disable().authorizeRequests().antMatchers("/").permitAll()
.antMatchers("/login", "/logout", "/secure").authenticated().antMatchers("/filtered")
.hasAuthority(AuthoritiesConstants.ADMIN).anyRequest().authenticated();
/**
* <logout invalidate-session="true" delete-cookies="JSESSIONID" />
*/
http.logout().logoutUrl("/logout").logoutSuccessUrl("/").invalidateHttpSession(true)
.deleteCookies("JSESSIONID");
// http.csrf();
}
示例4: configure
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Override
protected void configure(HttpSecurity http) throws Exception {
http.exceptionHandling().authenticationEntryPoint(restAuthenticationEntryPoint());
http.csrf().disable();
http.headers()
.addHeaderWriter(new HstsHeaderWriter(false));
if (casEnabled) {
http.addFilter(casAuthenticationFilter());
http.addFilter(casLogoutFilter());
}
if (facebookEnabled || googleEnabled || twitterEnabled) {
CallbackFilter callbackFilter = new CallbackFilter(oauthConfig());
callbackFilter.setSuffix(OAUTH_CALLBACK_PATH_SUFFIX);
callbackFilter.setDefaultUrl(rootUrl + apiPath + "/");
http.addFilterAfter(callbackFilter, CasAuthenticationFilter.class);
}
}
示例5: casFilter
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Bean
public CasAuthenticationFilter casFilter() {
CasAuthenticationFilter caf = new CasAuthenticationFilter();
caf.setAuthenticationManager(authenticationManager);
caf.setFilterProcessesUrl("/login");
caf.setProxyGrantingTicketStorage(pgtStorage());
caf.setProxyReceptorUrl("/pgtUrl");
return caf;
}
示例6: casFilter
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Bean
public CasAuthenticationFilter casFilter() {
CasAuthenticationFilter casAuthenticationFilter = new CasAuthenticationFilter();
casAuthenticationFilter.setAuthenticationManager(authenticationManager);
casAuthenticationFilter.setFilterProcessesUrl("/login");
return casAuthenticationFilter;
}
示例7: casFilter
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Bean
public CasAuthenticationFilter casFilter() {
CasAuthenticationFilter caf = new CasAuthenticationFilter();
caf.setAuthenticationManager(authenticationManager);
caf.setFilterProcessesUrl("/login");
caf.setProxyGrantingTicketStorage(pgtStorage());
caf.setProxyReceptorUrl("/pgtUrl");
caf.setServiceProperties(serviceProperties());
caf.setAuthenticationDetailsSource(
new ServiceAuthenticationDetailsSource(
serviceProperties())
);
return caf;
}
示例8: casAuthenticationFilter
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Bean
public CasAuthenticationFilter casAuthenticationFilter() throws Exception {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setAuthenticationManager(authenticationManager());
filter.setAuthenticationSuccessHandler(successHandler());
filter.setAuthenticationFailureHandler(failureHandler());
return filter;
}
示例9: configure
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
/**
* HTTP Security configuration
*
* <pre><http auto-config="true"></pre> is equivalent to:
* <pre>
* <http>
* <form-login />
* <http-basic />
* <logout />
* </http>
* </pre>
*
* Which is equivalent to the following JavaConfig:
*
* <pre>
* http.formLogin()
* .and().httpBasic()
* .and().logout();
* </pre>
*
* @param http HttpSecurity configuration.
* @throws Exception Authentication configuration exception
*
* @see <a href="http://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-jc.html">
* Spring Security 3 to 4 migration</a>
*/
@Override
protected void configure(final HttpSecurity http) throws Exception {
// Matching
http.authorizeRequests()
// FIXME: TODO: Allow anyone to use H2 (NOTE: NOT FOR PRODUCTION USE EVER !!! )
.antMatchers("/admin/h2/**").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/login/*").permitAll()
.antMatchers("/logout").permitAll()
.antMatchers("/signup/*").permitAll()
.antMatchers("/errors/**").permitAll()
.antMatchers("/admin/*").access("hasRole('ADMIN') and isFullyAuthenticated()")
.antMatchers("/events/").hasRole("ADMIN")
.antMatchers("/**").hasRole("USER");
http.addFilterAt(casFilter, CasAuthenticationFilter.class);
http.addFilterBefore(singleSignOutFilter, LogoutFilter.class);
// Logout
http.logout()
.logoutUrl("/logout")
.logoutSuccessUrl(casServerLogout)
.permitAll();
// Anonymous
http.anonymous();
// CSRF is enabled by default, with Java Config
http.csrf().disable();
// Exception Handling
http.exceptionHandling()
.authenticationEntryPoint(casAuthenticationEntryPoint)
.accessDeniedPage("/errors/403")
;
// Enable <frameset> in order to use H2 web console
http.headers().frameOptions().disable();
}
示例10: configure
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
/**
* HTTP Security configuration
*
* <pre><http auto-config="true"></pre> is equivalent to:
* <pre>
* <http>
* <form-login />
* <http-basic />
* <logout />
* </http>
* </pre>
*
* Which is equivalent to the following JavaConfig:
*
* <pre>
* http.formLogin()
* .and().httpBasic()
* .and().logout();
* </pre>
*
* @param http HttpSecurity configuration.
* @throws Exception Authentication configuration exception
*
* @see <a href="http://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-jc.html">
* Spring Security 3 to 4 migration</a>
*/
@Override
protected void configure(final HttpSecurity http) throws Exception {
// Matching
http.authorizeRequests()
// FIXME: TODO: Allow anyone to use H2 (NOTE: NOT FOR PRODUCTION USE EVER !!! )
.antMatchers("/admin/h2/**").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/login/*").permitAll()
.antMatchers("/logout").permitAll()
.antMatchers("/signup/*").permitAll()
.antMatchers("/errors/**").permitAll()
.antMatchers("/admin/*").access("hasRole('ADMIN') and isFullyAuthenticated()")
.antMatchers("/events/").hasRole("ADMIN")
.antMatchers("/**").hasRole("USER");
// Login
/*http.formLogin()
.loginPage("/login/form")
.loginProcessingUrl("/login")
.failureUrl("/login/form?error")
.usernameParameter("username")
.passwordParameter("password")
.defaultSuccessUrl("/default", true)
.permitAll();*/
// Logout
http.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/login/form?logout")
.deleteCookies("JSESSIONID").invalidateHttpSession(true)
.permitAll();
// Anonymous
http.anonymous();
// CSRF is enabled by default, with Java Config
http.csrf().disable();
http.addFilterAt(casFilter, CasAuthenticationFilter.class);
// Exception Handling
http.exceptionHandling()
.authenticationEntryPoint(casAuthenticationEntryPoint)
.accessDeniedPage("/errors/403")
;
// Enable <frameset> in order to use H2 web console
http.headers().frameOptions().disable();
}
示例11: authenticate
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
}
if (authentication instanceof UsernamePasswordAuthenticationToken
&& (!CasAuthenticationFilter.CAS_STATEFUL_IDENTIFIER.equals(authentication.getPrincipal().toString())
&& !CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal().toString()))) {
// UsernamePasswordAuthenticationToken not CAS related
return null;
}
// If an existing CasAuthenticationToken, just check we created it
if (authentication instanceof CasAuthenticationToken) {
if (this.key.hashCode() == ((CasAuthenticationToken) authentication).getKeyHash()) {
return authentication;
} else {
throw new BadCredentialsException(messages.getMessage("CasAuthenticationProvider.incorrectKey",
"The presented CasAuthenticationToken does not contain the expected key"));
}
}
// Ensure credentials are presented
if ((authentication.getCredentials() == null) || "".equals(authentication.getCredentials())) {
throw new BadCredentialsException(messages.getMessage("CasAuthenticationProvider.noServiceTicket",
"Failed to provide a CAS service ticket to validate"));
}
boolean stateless = false;
if (authentication instanceof UsernamePasswordAuthenticationToken
&& CasAuthenticationFilter.CAS_STATELESS_IDENTIFIER.equals(authentication.getPrincipal())) {
stateless = true;
}
CasAuthenticationToken result = null;
if (stateless) {
// Try to obtain from cache
result = statelessTicketCache.getByTicketId(authentication.getCredentials().toString());
}
if (result == null) {
result = this.authenticateNow(authentication);
result.setDetails(authentication.getDetails());
}
if (stateless) {
// Add to cache
statelessTicketCache.putTicketInCache(result);
}
return result;
}
示例12: casAuthenticationFilter
import org.springframework.security.cas.web.CasAuthenticationFilter; //导入依赖的package包/类
@Override
public CasAuthenticationFilter casAuthenticationFilter() {
return null;
}