本文整理汇总了Java中org.apache.shiro.authc.AuthenticationException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationException.getMessage方法的具体用法?Java AuthenticationException.getMessage怎么用?Java AuthenticationException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.authc.AuthenticationException
的用法示例。
在下文中一共展示了AuthenticationException.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLoginFailure
import org.apache.shiro.authc.AuthenticationException; //导入方法依赖的package包/类
/**
* 登录失败调用事件
*/
@Override
protected boolean onLoginFailure(AuthenticationToken token,
AuthenticationException e, ServletRequest request, ServletResponse response) {
String className = e.getClass().getName(), message = "";
if (IncorrectCredentialsException.class.getName().equals(className)
|| UnknownAccountException.class.getName().equals(className)){
message = "用户或密码错误, 请重试.";
}
else if (e.getMessage() != null && StringUtils.startsWith(e.getMessage(), "msg:")){
message = StringUtils.replace(e.getMessage(), "msg:", "");
}
else{
message = "系统出现点问题,请稍后再试!";
e.printStackTrace(); // 输出到控制台
}
request.setAttribute(getFailureKeyAttribute(), className);
request.setAttribute(getMessageParam(), message);
return true;
}
示例2: onLoginFailure
import org.apache.shiro.authc.AuthenticationException; //导入方法依赖的package包/类
/**
* 登录失败调用事件
*/
@Override
protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request,
ServletResponse response) {
String className = e.getClass().getName(), message = "";
if (IncorrectCredentialsException.class.getName().equals(className)
|| UnknownAccountException.class.getName().equals(className)) {
message = "用户或密码错误, 请重试.";
} else if (e.getMessage() != null && StringUtils.startsWith(e.getMessage(), "msg:")) {
message = StringUtils.replace(e.getMessage(), "msg:", "");
} else {
message = "系统出现点问题,请稍后再试!";
e.printStackTrace(); // 输出到控制台
}
request.setAttribute(getFailureKeyAttribute(), className);
request.setAttribute(getMessageParam(), message);
return true;
}
示例3: onLoginFailure
import org.apache.shiro.authc.AuthenticationException; //导入方法依赖的package包/类
/**
* 登录失败调用事件
*/
@Override
protected boolean onLoginFailure(AuthenticationToken token,
AuthenticationException e, ServletRequest request, ServletResponse response) {
String className = e.getClass().getName(), message = "";
if (IncorrectCredentialsException.class.getName().equals(className)
|| UnknownAccountException.class.getName().equals(className)){
message = "用户或密码错误, 请重试.";
}
else if (e.getMessage() != null && StringUtils.startsWith(e.getMessage(), "msg:")){
message = StringUtils.replace(e.getMessage(), "msg:", "");
}
else{
message = "系统出现点问题,请稍后再试!";
e.printStackTrace(); // 输出到控制台
}
request.setAttribute(getFailureKeyAttribute(), className);
request.setAttribute(getMessageParam(), message);
return true;
}
示例4: authenticateByEmailAddress
import org.apache.shiro.authc.AuthenticationException; //导入方法依赖的package包/类
@Override
public int authenticateByEmailAddress(
long companyId, String emailAddress, String password,
Map<String, String[]> headerMap, Map<String, String[]> parameterMap)
throws AuthException {
if (_log.isInfoEnabled()) {
_log.info("authenticateByEmailAddress");
}
UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(
emailAddress, password);
Subject currentUser = SecurityUtils.getSubject();
try {
currentUser.login(usernamePasswordToken);
boolean authenticated = currentUser.isAuthenticated();
if (authenticated) {
if (_log.isInfoEnabled()) {
_log.info("authenticated");
}
return SKIP_LIFERAY_CHECK;
}
else {
return FAILURE;
}
}
catch (AuthenticationException ae) {
_log.error(ae.getMessage(), ae);
throw new AuthException(ae.getMessage(), ae);
}
}
示例5: setFailureAttribute
import org.apache.shiro.authc.AuthenticationException; //导入方法依赖的package包/类
protected void setFailureAttribute(ServletRequest request, AuthenticationException ae) {
request.setAttribute(getFailureKeyAttribute(), ae.getClass().getName());
if (ae.getMessage() != null && StringUtils.startsWith(ae.getMessage(), "msg:")){
String message = StringUtils.replace(ae.getMessage(), "msg:", "");
request.setAttribute(getMessageParam(), message);
}
}