fixed #IILTZ Config单词拼错误

This commit is contained in:
冷冷 2018-03-27 23:31:18 +08:00
parent 5a8719b76a
commit 0a73ba0b23
2 changed files with 3 additions and 51 deletions

View File

@ -1,48 +0,0 @@
package com.github.pig.auth.component;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.security.oauth2.common.exceptions.InvalidGrantException;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.security.oauth2.common.exceptions.UnsupportedResponseTypeException;
import org.springframework.security.oauth2.provider.error.DefaultWebResponseExceptionTranslator;
import org.springframework.stereotype.Component;
/**
* @author lengleng
* @date 2017/12/29
* spring security 异常转化器
* 默认的国际化的异常信息在 spring-security-code下messages_zh_CN
* LdapAuthenticationProvider.badCredentials=坏的凭证
* LdapAuthenticationProvider.credentialsExpired=用户凭证已过期
* LdapAuthenticationProvider.disabled=用户已失效
* LdapAuthenticationProvider.expired=用户帐号已过期
* LdapAuthenticationProvider.locked=用户帐号已被锁定
* LdapAuthenticationProvider.emptyUsername=用户名不允许为空
* LdapAuthenticationProvider.onlySupports=仅仅支持UsernamePasswordAuthenticationToken
* PasswordComparisonAuthenticator.badCredentials=坏的凭证
*/
@Component
public class PigWebResponseExceptionTranslator extends DefaultWebResponseExceptionTranslator {
public static final String BAD_MSG = "坏的凭证";
/**
* @param e spring security内部异常
* @return 经过处理的异常信息
* @throws Exception 通用异常
*/
@Override
public ResponseEntity<OAuth2Exception> translate(Exception e) throws Exception {
OAuth2Exception oAuth2Exception;
if (e instanceof InvalidGrantException && StringUtils.equals(BAD_MSG, e.getMessage())) {
oAuth2Exception = new InvalidGrantException("密码错误", e);
} else if (e instanceof InternalAuthenticationServiceException) {
oAuth2Exception = new InvalidGrantException("用户名不存在", e);
} else {
oAuth2Exception = new UnsupportedResponseTypeException("服务处理异常", e);
}
return super.translate(oAuth2Exception);
}
}

View File

@ -1,6 +1,6 @@
package com.github.pig.gateway.componet.config;
import com.github.pig.common.bean.config.FilterUrlsPropertiesConifg;
import com.github.pig.common.bean.config.FilterUrlsPropertiesConfig;
import com.github.pig.gateway.componet.filter.ValidateCodeFilter;
import com.github.pig.gateway.componet.handler.PigAccessDeniedHandler;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,7 +25,7 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
@Autowired
private FilterUrlsPropertiesConifg filterUrlsPropertiesConifg;
private FilterUrlsPropertiesConfig filterUrlsPropertiesConfig;
@Autowired
private OAuth2WebSecurityExpressionHandler expressionHandler;
@Autowired
@ -40,7 +40,7 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
http.headers().frameOptions().disable();
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = http
.authorizeRequests();
for (String url : filterUrlsPropertiesConifg.getAnon()) {
for (String url : filterUrlsPropertiesConfig.getAnon()) {
registry.antMatchers(url).permitAll();
}
registry.anyRequest()