add password policy for white-spaces
This commit is contained in:
		
							parent
							
								
									80a7821452
								
							
						
					
					
						commit
						409fddc2e8
					
				@ -27,6 +27,7 @@ import org.passay.PasswordData;
 | 
			
		||||
import org.passay.PasswordValidator;
 | 
			
		||||
import org.passay.Rule;
 | 
			
		||||
import org.passay.RuleResult;
 | 
			
		||||
import org.passay.WhitespaceRule;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.cache.annotation.CacheEvict;
 | 
			
		||||
import org.springframework.cache.annotation.Cacheable;
 | 
			
		||||
@ -174,6 +175,9 @@ public class DefaultSystemSecurityService implements SystemSecurityService {
 | 
			
		||||
        if (isPositiveInteger(passwordPolicy.getMinimumSpecialCharacters())) {
 | 
			
		||||
            passwordRules.add(new CharacterRule(EnglishCharacterData.Special, passwordPolicy.getMinimumSpecialCharacters()));
 | 
			
		||||
        }
 | 
			
		||||
        if (!passwordPolicy.getAllowWhitespaces()) {
 | 
			
		||||
            passwordRules.add(new WhitespaceRule());
 | 
			
		||||
        }
 | 
			
		||||
        PasswordValidator validator = new PasswordValidator(passwordRules);
 | 
			
		||||
        PasswordData passwordData = new PasswordData(password);
 | 
			
		||||
        RuleResult result = validator.validate(passwordData);
 | 
			
		||||
 | 
			
		||||
@ -35,6 +35,8 @@ public class UserPasswordPolicy implements Serializable {
 | 
			
		||||
    private Integer minimumDigits;
 | 
			
		||||
    @ApiModelProperty(position = 1, value = "Minimum number of special in the password." )
 | 
			
		||||
    private Integer minimumSpecialCharacters;
 | 
			
		||||
    @ApiModelProperty(position = 1, value = "Allow white-spaces")
 | 
			
		||||
    private Boolean allowWhitespaces;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(position = 1, value = "Password expiration period (days). Force expiration of the password." )
 | 
			
		||||
    private Integer passwordExpirationPeriodDays;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user