本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
示例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;
示例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;