resources Builders 校验

本文详细介绍了EclipseJDT在Java项目中的应用,特别是其增量项目构建器如何实时编译更新的Java源文件,并追踪依赖进行重新编译。此外,文章还探讨了插件如何扩展组织资源的构建和性质点,实现更高效的工作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.ibm.com/developerworks/cn/java/j-lo-apde/

Eclipse JDT(Java Development Tools)定义了一个增量项目构建器,每当 java 项目中增加或修改一个文件时,该构建器都会把 java 源文件编译成一个 class 文件,同时追踪依赖文件并且在需要的时候重新编译这些文件。插件扩展了 org.eclipse.core.resources.builders 和 org.eclipse.core.resources.nature 两个扩展点



http://www.verydemo.com/demo_c89_i114313.html

http://space.itpub.net/13081368/viewspace-374853



是在这个当中实现的package com.open.capacity.server.config; import com.open.capacity.props.PermitUrlProperties; import com.open.capacity.server.handler.OauthLogoutHandler; import com.open.capacity.server.mobile.app.PhoneOrAccountAuthenticationSecurityConfig; import com.open.capacity.server.mobile.wechat.UnionIdAuthenticationSecurityConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; import java.util.List; import static org.apache.commons.lang3.StringUtils.isEmpty; /** * spring security配置 * * @author owen 624191343@qq.com * @version 创建时间:2017年11月12日 上午22:57:51 2017年10月16日 * 在WebSecurityConfigurerAdapter不拦截oauth要开放的资源 */ @Configuration //@EnableWebSecurity //@EnableGlobalMethodSecurity(prePostEnabled = true) @EnableConfigurationProperties(PermitUrlProperties.class) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private AuthenticationSuccessHandler authenticationSuccessHandler; @Autowired private AuthenticationFailureHandler authenticationFailureHandler; // @Autowired // private LogoutSuccessHandler logoutSuccessHandler; @Autowired(required = false) private AuthenticationEntryPoint authenticationEntryPoint; @Resource private UserDetailsService userDetailsService; @Autowired private PasswordEncoder passwordEncoder; @Autowired private OauthLogoutHandler oauthLogoutHandler; @Autowired private PermitUrlProperties permitUrlProperties ; @Autowired private ValidateCodeSecurityConfig validateCodeSecurityConfig ; @Autowired private PhoneOrAccountAuthenticationSecurityConfig phoneOrAccountAuthenticationSecurityConfig; @Autowired private UnionIdAuthenticationSecurityConfig unionIdAuthenticationSecurityConfig; @Override public void configure(WebSecurity web) throws Exception { web.ignoring().antMatchers("/v2/api-docs", "/configuration/ui", "/swagger-resources", "/configuration/security", "/swagger-ui.html", "/webjars/**", "/doc.html", "/login.html"); web.ignoring().antMatchers("/js/**"); web.ignoring().antMatchers("/css/**"); web.ignoring().antMatchers("/health"); // 忽略登录界面 web.ignoring().antMatchers("/login.html"); web.ignoring().antMatchers("/index.html"); web.ignoring().antMatchers("/oauth/user/token"); web.ignoring().antMatchers("/oauth/client/token"); web.ignoring().antMatchers("/validata/code/**"); web.ignoring().antMatchers(permitUrlProperties.getIgnored()); } /** * 认证管理 * * @return 认证管理对象 * @throws Exception * 认证异常信息 */ @Override @Bean public AuthenticationManager authenticationManagerBean() throws Exception { return super.authenticationManagerBean(); } @Override /*protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .anyRequest().authenticated(); http.formLogin().loginPage("/login.html").loginProcessingUrl("/user/login") .successHandler(authenticationSuccessHandler).failureHandler(authenticationFailureHandler); http.logout().logoutSuccessUrl("/login.html") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()) .addLogoutHandler(oauthLogoutHandler).clearAuthentication(true); //增加验证码处理 http.apply(validateCodeSecurityConfig) .and() // http.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler); .apply(phoneOrAccountAuthenticationSecurityConfig) .and() .apply(unionIdAuthenticationSecurityConfig) .and() .csrf().disable(); // 解决不允许显示在iframe的问题 http.headers().frameOptions().disable(); http.headers().cacheControl(); // 基于密码 等模式可以无session,不支持授权码模式 if (authenticationEntryPoint != null) { http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint); http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); } else { // 授权码模式单独处理,需要session的支持,此模式可以支持所有oauth2的认证 http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED); } }*/ protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .anyRequest().authenticated() .and() .exceptionHandling() .authenticationEntryPoint((request, response, authException) -> { // 检查是否为需要校验参数的请求 if (isTokenRequest(request)) { // 检查所有参数,收集所有缺失参数的错误 List<String> errorMessages = checkAllParams(request); if (!errorMessages.isEmpty()) { // 参数缺失,返回400错误 sendErrorResponse(response, HttpStatus.BAD_REQUEST, String.join("; ", errorMessages)); return; } } }); // 配置表单登录,但禁用默认的登录页面跳转 http.formLogin() .loginProcessingUrl("/user/login") .successHandler(authenticationSuccessHandler) .failureHandler(authenticationFailureHandler) .permitAll() .and() .logout() .logoutSuccessUrl("/login.html") .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()) .addLogoutHandler(oauthLogoutHandler) .clearAuthentication(true); // 应用自定义安全配置 http.apply(validateCodeSecurityConfig) .and() .apply(phoneOrAccountAuthenticationSecurityConfig) .and() .apply(unionIdAuthenticationSecurityConfig); // 解决不允许显示在iframe的问题 http.headers().frameOptions().disable(); http.headers().cacheControl(); // 对所有请求使用无状态会话策略 http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); } /** * 判断是否为获取token的请求 */ private boolean isTokenRequest(HttpServletRequest request) { return "/oauth/app/verifyCode/token".equals(request.getRequestURI()) && "POST".equalsIgnoreCase(request.getMethod()); } /** * 检查所有参数,返回所有缺失参数的错误信息列表 */ private List<String> checkAllParams(HttpServletRequest request) { List<String> errors = new ArrayList<>(); if (isEmpty(request.getParameter("phoneOrAccount"))) { errors.add("账号不能为空"); } if (isEmpty(request.getParameter("accountType"))) { errors.add("账号类型不能为空"); } if (isEmpty(request.getParameter("deviceCode"))) { errors.add("机器码不能为空"); } if (isEmpty(request.getParameter("code"))) { errors.add("图形验证码不能为空"); } if (isEmpty(request.getParameter("verifyCode"))) { errors.add("短信验证码不能为空"); } return errors; } /** * 检查字符串是否为空 */ private boolean isEmpty(String value) { return value == null || value.trim().isEmpty(); } /** * 发送错误响应 */ private void sendErrorResponse(HttpServletResponse response, HttpStatus status, String message) throws IOException { response.setContentType("application/json;charset=UTF-8"); response.setStatus(status.value()); response.getWriter().write("{\"resp_code\":" + status.value() + ",\"rsp_msg\":\"" + message + "\",\"datas\":null}"); } /** * 全局用户信息 * * @param auth * 认证管理 * @throws Exception * 用户认证异常信息 */ @Autowired public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder); } }
最新发布
06-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值