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

Java CredentialsAlreadyUsedException类代码示例

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

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



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

示例1: changeCredentials

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
@Override
public void changeCredentials(final MemberUser user, final String newCredentials) throws CredentialsAlreadyUsedException {
    ServiceClient client = fetchService.fetch(LoggedUser.serviceClient(), RelationshipHelper.nested(ServiceClient.Relationships.CHANNEL, Channel.Relationships.PRINCIPALS));
    switch (client.getChannel().getCredentials()) {
        case LOGIN_PASSWORD:
            changePassword(user, null, newCredentials, false);
            break;
        case PIN:
            changePin(user, newCredentials);
            break;
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:13,代码来源:AccessServiceImpl.java


示例2: changePin

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
private MemberUser changePin(MemberUser user, final String plainPin) {

        // Before changing, ensure that the new pin is valid
        final ValidationError validationResult = new PinValidation(user.getMember()).validate(user, "pin", plainPin);
        if (validationResult != null) {
            throw new ValidationException("pin", "channel.credentials.PIN", validationResult);
        }

        final String pin = hashHandler.hash(user.getSalt(), plainPin);
        user = fetchService.fetch(user, RelationshipHelper.nested(User.Relationships.ELEMENT, Element.Relationships.GROUP));
        final String currentPin = user.getPin();

        final PasswordPolicy passwordPolicy = user.getElement().getGroup().getBasicSettings().getPasswordPolicy();
        if (passwordPolicy != null && passwordPolicy != PasswordPolicy.NONE) {
            // Check if it was already in use when there's a password policy
            if (StringUtils.trimToEmpty(currentPin).equalsIgnoreCase(pin) || passwordHistoryLogDao.wasAlreadyUsed(user, PasswordType.PIN, pin)) {
                throw new CredentialsAlreadyUsedException(Credentials.PIN, user);
            }
        }

        // Ensure the login password is not equals to the pin or transaction password
        if (pin.equalsIgnoreCase(user.getPassword()) || pin.equalsIgnoreCase(user.getTransactionPassword())) {
            throw new ValidationException("changePin.error.sameAsLoginOrTransactionPassword");
        }

        // Set the new pin
        user.setPin(pin);

        // Log the pin history
        if (StringUtils.isNotEmpty(currentPin)) {
            final PasswordHistoryLog log = new PasswordHistoryLog();
            log.setDate(Calendar.getInstance());
            log.setUser(user);
            log.setType(PasswordType.PIN);
            log.setPassword(currentPin);
            passwordHistoryLogDao.insert(log);
        }

        return user;
    }
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:41,代码来源:AccessServiceImpl.java


示例3: changePassword

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
private <U extends User> U changePassword(U user, final String oldPassword, final String plainNewPassword, final boolean forceChange) {
    user = fetchService.reload(user, RelationshipHelper.nested(User.Relationships.ELEMENT, Element.Relationships.GROUP));

    // Before changing, ensure that the new password is valid
    final ValidationError validationResult = new LoginPasswordValidation(user.getElement()).validate(user, "password", plainNewPassword);
    if (validationResult != null) {
        throw new ValidationException("password", "channel.credentials.LOGIN_PASSWORD", validationResult);
    }

    final String currentPassword = user.getPassword();
    final String hashedOldPassword = hashHandler.hash(user.getSalt(), oldPassword);
    if (StringUtils.isNotEmpty(oldPassword) && !hashedOldPassword.equalsIgnoreCase(currentPassword)) {
        throw new InvalidCredentialsException(Credentials.LOGIN_PASSWORD, user);
    }

    final String newPassword = hashHandler.hash(user.getSalt(), plainNewPassword);

    final PasswordPolicy passwordPolicy = user.getElement().getGroup().getBasicSettings().getPasswordPolicy();
    if (passwordPolicy != PasswordPolicy.NONE) {
        // Check if it was already in use when there's a password policy
        if (StringUtils.trimToEmpty(currentPassword).equalsIgnoreCase(newPassword) || passwordHistoryLogDao.wasAlreadyUsed(user, PasswordType.LOGIN, newPassword)) {
            throw new CredentialsAlreadyUsedException(Credentials.LOGIN_PASSWORD, user);
        }
    }

    // Ensure the login password is not equals to the pin or transaction password
    if (newPassword.equalsIgnoreCase(user.getTransactionPassword()) || (user instanceof MemberUser && newPassword.equalsIgnoreCase(((MemberUser) user).getPin()))) {
        throw new ValidationException("changePassword.error.sameAsTransactionPasswordOrPin");
    }

    user.setPassword(newPassword);
    user.setPasswordDate(forceChange ? null : Calendar.getInstance());
    // Ensure that the returning user will have the ELEMENT and GROUP fetched
    user = fetchService.fetch(userDao.update(user), FETCH);
    if (user instanceof OperatorUser) {
        // When an operator, also ensure that the member will have the ELEMENT and GROUP fetched
        final Operator operator = ((OperatorUser) user).getOperator();
        final Member member = fetchService.fetch(operator.getMember(), Element.Relationships.USER, Element.Relationships.GROUP);
        operator.setMember(member);
    }

    // Log the password history
    if (StringUtils.isNotEmpty(currentPassword)) {
        final PasswordHistoryLog log = new PasswordHistoryLog();
        log.setDate(Calendar.getInstance());
        log.setUser(user);
        log.setType(PasswordType.LOGIN);
        log.setPassword(currentPassword);
        passwordHistoryLogDao.insert(log);
    }

    return user;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:54,代码来源:AccessServiceImpl.java


示例4: changePassword

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
@Override
public User changePassword(final ChangeLoginPasswordDTO params) throws InvalidCredentialsException, BlockedCredentialsException, CredentialsAlreadyUsedException {
    checkChangePassword(params);
    return accessService.changePassword(params);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:6,代码来源:AccessServiceSecurity.java


示例5: changePin

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
@Override
public MemberUser changePin(final ChangePinDTO params) throws InvalidCredentialsException, BlockedCredentialsException, CredentialsAlreadyUsedException {
    checkChangePin(params);
    return accessService.changePin(params);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:6,代码来源:AccessServiceSecurity.java


示例6: changePassword

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
/**
 * Changes the password of the given user
 */
User changePassword(ChangeLoginPasswordDTO params) throws InvalidCredentialsException, BlockedCredentialsException, CredentialsAlreadyUsedException;
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:5,代码来源:AccessService.java


示例7: changePin

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
/**
 * Changes the pin of the given member user
 * @throws InvalidCredentialsException When the given pin is invalid
 * @throws BlockedCredentialsException When the transaction password was invalid a few times, it becomes blocked
 * @throws CredentialsAlreadyUsedException When the given new password was already used for that user in past
 */
MemberUser changePin(ChangePinDTO params) throws InvalidCredentialsException, BlockedCredentialsException, CredentialsAlreadyUsedException;
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:8,代码来源:AccessService.java


示例8: changeCredentials

import nl.strohalm.cyclos.services.access.exceptions.CredentialsAlreadyUsedException; //导入依赖的package包/类
/**
 * Changes a member credentials according to the current web service channel. Must be invoked by web services.
 */
void changeCredentials(final MemberUser user, final String newCredentials) throws CredentialsAlreadyUsedException;
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:5,代码来源:AccessServiceLocal.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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