本文整理汇总了Java中nl.strohalm.cyclos.entities.groups.Group.getBasicSettings方法的典型用法代码示例。如果您正苦于以下问题:Java Group.getBasicSettings方法的具体用法?Java Group.getBasicSettings怎么用?Java Group.getBasicSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nl.strohalm.cyclos.entities.groups.Group
的用法示例。
在下文中一共展示了Group.getBasicSettings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestTransactionPassword
import nl.strohalm.cyclos.entities.groups.Group; //导入方法依赖的package包/类
private boolean requestTransactionPassword(User user) {
user = fetchService.fetch(user, FETCH);
Group group = user.getElement().getGroup();
if (group instanceof OperatorGroup) {
group = fetchService.fetch(group, RelationshipHelper.nested(OperatorGroup.Relationships.MEMBER, Element.Relationships.GROUP));
}
final BasicGroupSettings settings = group.getBasicSettings();
return settings.getTransactionPassword().isUsed();
}
示例2: generateTransactionPassword
import nl.strohalm.cyclos.entities.groups.Group; //导入方法依赖的package包/类
@Override
public String generateTransactionPassword() {
User user = LoggedUser.user();
// Load operator´s member and group of operator´s member
if (user instanceof OperatorUser) {
Element element = user.getElement();
element = fetchService.fetch(element, RelationshipHelper.nested(Operator.Relationships.MEMBER, Element.Relationships.GROUP));
}
// If the transaction password is not used for the logged user, return null
if (!requestTransactionPassword(user)) {
throw new UnexpectedEntityException();
}
// If there is already a password, return null
final String current = user.getTransactionPassword();
if (current != null) {
return null;
}
// Get the chars
final AccessSettings accessSettings = settingsService.getAccessSettings();
final String chars = accessSettings.getTransactionPasswordChars();
// Get the password length
Group group = user.getElement().getGroup();
if (group instanceof OperatorGroup) {
group = fetchService.fetch(group, RelationshipHelper.nested(OperatorGroup.Relationships.MEMBER, Element.Relationships.GROUP));
}
final BasicGroupSettings basicSettings = group.getBasicSettings();
final int length = basicSettings.getTransactionPasswordLength();
// Generate a new one, and store it
final StringBuilder buffer = new StringBuilder(length);
final Random rnd = new Random();
for (int i = 0; i < length; i++) {
buffer.append(chars.charAt(rnd.nextInt(chars.length())));
}
final String transactionPassword = buffer.toString();
user.setTransactionPassword(hashHandler.hash(user.getSalt(), transactionPassword));
user.setTransactionPasswordStatus(TransactionPasswordStatus.ACTIVE);
user = userDao.update(user);
return transactionPassword;
}
示例3: checkTransactionPassword
import nl.strohalm.cyclos.entities.groups.Group; //导入方法依赖的package包/类
private User checkTransactionPassword(User user, final String plainTransactionPassword, final String remoteAddress) {
user = fetchService.fetch(user, RelationshipHelper.nested(User.Relationships.ELEMENT, Element.Relationships.GROUP));
// Check if not already blocked
if (user.getTransactionPasswordStatus().equals(MemberUser.TransactionPasswordStatus.BLOCKED)) {
throw new BlockedCredentialsException(Credentials.TRANSACTION_PASSWORD, user);
}
final String transactionPassword = hashHandler.hash(user.getSalt(), plainTransactionPassword == null ? null : plainTransactionPassword.toUpperCase());
String userTransactionPassword = user.getTransactionPassword();
if (userTransactionPassword == null || !userTransactionPassword.equalsIgnoreCase(transactionPassword)) {
final Group group = user.getElement().getGroup();
final BasicGroupSettings settings = group.getBasicSettings();
final int maxTries = settings.getMaxTransactionPasswordWrongTries();
wrongCredentialAttemptsDao.record(user, Credentials.TRANSACTION_PASSWORD);
int wrongAttempts = wrongCredentialAttemptsDao.count(wrongAttemptsLimit(), user, Credentials.TRANSACTION_PASSWORD);
if (wrongAttempts == maxTries) {
// Send an alert
if (user instanceof AdminUser) {
alertService.create(SystemAlert.Alerts.ADMIN_TRANSACTION_PASSWORD_BLOCKED_BY_TRIES, user.getUsername(), wrongAttempts, remoteAddress);
} else {
Member m;
if (user instanceof MemberUser) {
m = ((MemberUser) user).getMember();
} else {
m = ((OperatorUser) user).getOperator().getMember();
}
alertService.create(m, MemberAlert.Alerts.TRANSACTION_PASSWORD_BLOCKED_BY_TRIES, wrongAttempts, remoteAddress);
memberNotificationHandler.blockedCredentialsNotification(user, Credentials.TRANSACTION_PASSWORD);
}
// Block the transaction password and clear previous attempts
final ResetTransactionPasswordDTO dto = new ResetTransactionPasswordDTO();
dto.setAllowGeneration(false);
dto.setUser(user);
resetTransactionPassword(dto);
wrongCredentialAttemptsDao.clear(user, Credentials.TRANSACTION_PASSWORD);
throw new BlockedCredentialsException(Credentials.TRANSACTION_PASSWORD, user);
}
throw new InvalidCredentialsException(Credentials.TRANSACTION_PASSWORD, user);
}
// Everything ok - remove any previous wrong attempts
wrongCredentialAttemptsDao.clear(user, Credentials.TRANSACTION_PASSWORD);
return user;
}
示例4: resolveValidationError
import nl.strohalm.cyclos.entities.groups.Group; //导入方法依赖的package包/类
private ValidationError resolveValidationError(final boolean loginPassword, final boolean numeric, final Element element, final Object object, final Object property, final String credential) {
if (StringUtils.isEmpty(credential)) {
return null;
}
final Group group = fetchService.fetch(element.getGroup());
final BasicGroupSettings settings = group.getBasicSettings();
RangeConstraint length;
if (loginPassword) {
length = settings.getPasswordLength();
} else {
final MemberGroup memberGroup = (MemberGroup) group;
length = memberGroup.getMemberSettings().getPinLength();
}
// Validate the password length
final ValidationError lengthResult = new LengthValidation(length).validate(object, property, credential);
if (lengthResult != null) {
return lengthResult;
}
final String keyPrefix = loginPassword ? "changePassword.error." : "changePin.error.";
// Check for characters
if (numeric && !(group instanceof AdminGroup)) {
// Must be numeric
if (!StringUtils.isNumeric(credential)) {
return new ValidationError(keyPrefix + "mustBeNumeric");
}
}
if (loginPassword && !numeric) {
// When the virtual keyboard is enabled, make sure that the login password has no special characters
final AccessSettings accessSettings = settingsService.getAccessSettings();
if (accessSettings.isVirtualKeyboard() && StringHelper.hasSpecial(credential)) {
return new ValidationError("changePassword.error.mustContainOnlyLettersOrNumbers");
}
}
// Validate the password policy
final PasswordPolicy policy = settings.getPasswordPolicy();
if (policy == null || policy == PasswordPolicy.NONE) {
// Nothing to enforce
return null;
}
// Check for characters
if (loginPassword && !numeric) {
// Keys are hard coded with changePassword.error because pin is always numeric
switch (policy) {
case AVOID_OBVIOUS_LETTERS_NUMBERS:
// Must include letters and numbers
if (!StringHelper.hasDigits(credential) || !StringHelper.hasLetters(credential)) {
return new ValidationError("changePassword.error.mustIncludeLettersNumbers");
}
break;
case AVOID_OBVIOUS_LETTERS_NUMBERS_SPECIAL:
// Must include letters, numbers and special characters
if (!StringHelper.hasDigits(credential) || !StringHelper.hasLetters(credential) || !StringHelper.hasSpecial(credential)) {
return new ValidationError("changePassword.error.mustIncludeLettersNumbersSpecial");
}
break;
}
}
// Check for obvious password
if (isObviousCredential(element, credential)) {
return new ValidationError(keyPrefix + "obvious");
}
return null;
}