• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExpiredCredentialsException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.shiro.authc.ExpiredCredentialsException的典型用法代码示例。如果您正苦于以下问题:Java ExpiredCredentialsException类的具体用法?Java ExpiredCredentialsException怎么用?Java ExpiredCredentialsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExpiredCredentialsException类属于org.apache.shiro.authc包,在下文中一共展示了ExpiredCredentialsException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doGetAuthenticationInfo

import org.apache.shiro.authc.ExpiredCredentialsException; //导入依赖的package包/类
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    UsernamePasswordToken upToken = (UsernamePasswordToken) token;

    SimpleAccount account = getAccountFromUsername(upToken.getUsername());

    if (account != null) {
        if (account.isLocked()) {
            throw new LockedAccountException("Account [" + account + "] is locked.");
        }
        if (account.isCredentialsExpired()) {
            String msg = "The credentials for account [" + account + "] are expired";
            throw new ExpiredCredentialsException(msg);
        }
    }

    return account;
}
 
开发者ID:kalixia,项目名称:kha,代码行数:19,代码来源:KhaRealm.java


示例2: doGetAuthenticationInfo

import org.apache.shiro.authc.ExpiredCredentialsException; //导入依赖的package包/类
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException {
    OAuth2Token token = (OAuth2Token) authToken;

    SimpleAccount account = authorizationServer.getAccountFromAccessToken(token.getToken());

    if (account != null) {
        if (account.isLocked()) {
            throw new LockedAccountException("Account [" + account + "] is locked.");
        }
        if (account.isCredentialsExpired()) {
            String msg = "The credentials for account [" + account + "] are expired";
            throw new ExpiredCredentialsException(msg);
        }
    }

    return account;
}
 
开发者ID:kalixia,项目名称:Grapi,代码行数:19,代码来源:OAuth2Realm.java


示例3: onLoginFailure

import org.apache.shiro.authc.ExpiredCredentialsException; //导入依赖的package包/类
@Override
protected boolean onLoginFailure(AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response) {
	if (WebHelper.isAjax((HttpServletRequest) request)) {
		Result result = Result.failure();
		if (e instanceof IncorrectCredentialsException) {
			result.message("密码错误");
		} else if (e instanceof ExpiredCredentialsException) {
			result.message("密码已过期");
		} else if (e instanceof UnknownAccountException) {
			result.message("该账号不存在");
		} else if (e instanceof DisabledAccountException) {
			result.message("该账号已禁用");
		} else if (e instanceof LockedAccountException) {
			result.message("该账号已锁定");
		} else if (e instanceof AccountException) {
			result.message("账号错误");
		} else if (e instanceof CredentialsException) {
			result.message("密码错误");
		}
		try {
			writeObject(request, response, result);
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
		return false;
	}
	return super.onLoginFailure(token, e, request, response);
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:29,代码来源:AjaxAuthenticationFilter.java


示例4: doGetAuthenticationInfo

import org.apache.shiro.authc.ExpiredCredentialsException; //导入依赖的package包/类
@Override
protected AuthenticationInfo doGetAuthenticationInfo(
		final AuthenticationToken token) throws AuthenticationException {
	if (isClosed()) {
		throw new ForwardedRuntimeException(AuthManagementException.class,
				1003);
	}

	final UsernamePasswordToken upToken = (UsernamePasswordToken) token;
	final SimpleAccount account = this.users.get(upToken.getUsername());

	if (account != null) {

		if (account.isLocked()) {
			throw new LockedAccountException("Account [" + account
					+ "] is locked.");
		}
		if (account.isCredentialsExpired()) {
			throw new ExpiredCredentialsException(
					"The credentials for account [" + account
							+ "] are expired");
		}

	}

	return account;
}
 
开发者ID:pmeisen,项目名称:dis-timeintervaldataanalyzer,代码行数:28,代码来源:MapDbAuthorizingRealm.java


示例5: assertCredentialsNotExpired

import org.apache.shiro.authc.ExpiredCredentialsException; //导入依赖的package包/类
/**
 * Asserts that the persisted account is not expired, and if not, throws an ExpiredCredentialsException.
 *
 * @param account the persisted {@link AccountEntity}
 * @throws ExpiredCredentialsException it the account is expired
 */
private void assertCredentialsNotExpired(AccountEntity account) throws ExpiredCredentialsException {
    if (account.getIsCredentialsExpired()) {
        // the account is expired. Throw ExpiredCredentialsException
        StringBuilder sb = new StringBuilder();
        sb.append("Credentials is expired for user ");
        sb.append(account.getUsername());

        throw new ExpiredCredentialsException(sb.toString());
    }
}
 
开发者ID:panifex,项目名称:panifex-platform,代码行数:17,代码来源:PersistenceRealm.java


示例6: expiredCredentialsTest

import org.apache.shiro.authc.ExpiredCredentialsException; //导入依赖的package包/类
/**
 * Simulates the unsuccessful authentication process through {@link PersistenceRealm},
 * because the account has been expired.
 * <p>
 * {@link org.apache.shiro.authc.ExpiredCredentialsException} must be thrown during the process.
 */
@Test
public void expiredCredentialsTest() {
    // create mocks
    AccountEntity accountMock = createMock(AccountEntity.class);
    UsernamePasswordToken tokenMock = createMock(UsernamePasswordToken.class);

    // expectations
    expect(tokenMock.getUsername()).andReturn(USERNAME);

    expect(accountRepositoryMock.getAccountByUsername(entityManagerMock, USERNAME)).andReturn(accountMock);
    expect(accountMock.getUsername()).andReturn(USERNAME);
    expect(accountMock.getPassword()).andReturn(PASSWORD_HASH);
    expect(accountMock.getPasswordSalt()).andReturn(PASSWORD_SALT);
    expect(accountMock.getIsCredentialsExpired()).andReturn(true);

    replayAll();

    try {
        // authentificate token
        realm.getAuthenticationInfo(tokenMock);
    } catch (ExpiredCredentialsException e) {
        // expected
        verifyAll();
        return;
    }

    fail("ExpiredCredentialException have must be thrown");
}
 
开发者ID:panifex,项目名称:panifex-platform,代码行数:35,代码来源:PersistenceRealmTest.java



注:本文中的org.apache.shiro.authc.ExpiredCredentialsException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SecurityGroup类代码示例发布时间:2022-05-21
下一篇:
Java Activation类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap