Skip to content
Snippets Groups Projects
Commit 583bfa33 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

VIPSNEW-168

Replaced vt-password with its successor Passay
parent 44d51afc
No related branches found
No related tags found
No related merge requests found
...@@ -132,6 +132,11 @@ ...@@ -132,6 +132,11 @@
<version>1.2.14</version> <version>1.2.14</version>
<type>jar</type> <type>jar</type>
</dependency> </dependency>
<dependency>
<groupId>org.passay</groupId>
<artifactId>passay</artifactId>
<version>1.1.0</version>
</dependency>
<dependency> <dependency>
<groupId>javax</groupId> <groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId> <artifactId>javaee-web-api</artifactId>
...@@ -158,11 +163,11 @@ ...@@ -158,11 +163,11 @@
<artifactId>google-api-client</artifactId> <artifactId>google-api-client</artifactId>
<version>1.19.1</version> <version>1.19.1</version>
</dependency> </dependency>
<dependency> <!--dependency>
<groupId>edu.vt.middleware</groupId> <groupId>edu.vt.middleware</groupId>
<artifactId>vt-password</artifactId> <artifactId>vt-password</artifactId>
<version>3.1.2</version> <version>3.1.2</version>
</dependency> </dependency-->
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
......
...@@ -24,20 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -24,20 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.ibm.icu.util.Calendar; import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.TimeZone; import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.ULocale; import com.ibm.icu.util.ULocale;
import edu.vt.middleware.password.CharacterCharacteristicsRule;
import edu.vt.middleware.password.CharacterRule;
import edu.vt.middleware.password.DigitCharacterRule;
import edu.vt.middleware.password.LengthRule;
import edu.vt.middleware.password.LowercaseCharacterRule;
import edu.vt.middleware.password.MessageResolver;
import edu.vt.middleware.password.Password;
import edu.vt.middleware.password.PasswordData;
import edu.vt.middleware.password.PasswordGenerator;
import edu.vt.middleware.password.PasswordValidator;
import edu.vt.middleware.password.Rule;
import edu.vt.middleware.password.RuleResult;
import edu.vt.middleware.password.UppercaseCharacterRule;
import edu.vt.middleware.password.WhitespaceRule;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.text.MessageFormat; import java.text.MessageFormat;
...@@ -85,6 +72,18 @@ import no.nibio.vips.logic.util.SimpleMailSender; ...@@ -85,6 +72,18 @@ import no.nibio.vips.logic.util.SimpleMailSender;
import no.nibio.vips.logic.util.StringUtils; import no.nibio.vips.logic.util.StringUtils;
import no.nibio.vips.util.MD5Encrypter; import no.nibio.vips.util.MD5Encrypter;
import no.nibio.web.forms.FormValidationException; import no.nibio.web.forms.FormValidationException;
import org.passay.CharacterCharacteristicsRule;
import org.passay.CharacterRule;
import org.passay.EnglishCharacterData;
import org.passay.LengthRule;
import org.passay.MessageResolver;
import org.passay.PasswordData;
import org.passay.PasswordGenerator;
import org.passay.PasswordValidator;
import org.passay.PropertiesMessageResolver;
import org.passay.Rule;
import org.passay.RuleResult;
import org.passay.WhitespaceRule;
/** /**
* Handles user stuff, credentials * Handles user stuff, credentials
...@@ -303,8 +302,8 @@ public class UserBean { ...@@ -303,8 +302,8 @@ public class UserBean {
// Try to load localized error messages // Try to load localized error messages
try try
{ {
props.load(this.getClass().getResourceAsStream("/no/nibio/vips/logic/i18n/vtpassword" + propertiesFileSuffix + ".properties")); props.load(this.getClass().getResourceAsStream("/no/nibio/vips/logic/i18n/passay" + propertiesFileSuffix + ".properties"));
MessageResolver resolver = new MessageResolver(props); MessageResolver resolver = new PropertiesMessageResolver(props);
validator = new PasswordValidator(resolver, this.getDefaultPasswordValidatorRuleList()); validator = new PasswordValidator(resolver, this.getDefaultPasswordValidatorRuleList());
} }
// Something went wrong when attempting to get localized error messages. Skip that. // Something went wrong when attempting to get localized error messages. Skip that.
...@@ -313,7 +312,7 @@ public class UserBean { ...@@ -313,7 +312,7 @@ public class UserBean {
validator = new PasswordValidator(this.getDefaultPasswordValidatorRuleList()); validator = new PasswordValidator(this.getDefaultPasswordValidatorRuleList());
} }
PasswordData passwordData = new PasswordData(new Password(password)); PasswordData passwordData = new PasswordData(password);
RuleResult result = validator.validate(passwordData); RuleResult result = validator.validate(passwordData);
if(result.isValid()) if(result.isValid())
{ {
...@@ -395,11 +394,11 @@ public class UserBean { ...@@ -395,11 +394,11 @@ public class UserBean {
{ {
List<CharacterRule> defaultCharacterRules = new ArrayList<>(); List<CharacterRule> defaultCharacterRules = new ArrayList<>();
// require at least 1 digit in passwords // require at least 1 digit in passwords
defaultCharacterRules.add(new DigitCharacterRule(1)); defaultCharacterRules.add(new CharacterRule(EnglishCharacterData.Digit,1));
// require at least 1 upper case char // require at least 1 upper case char
defaultCharacterRules.add(new UppercaseCharacterRule(1)); defaultCharacterRules.add(new CharacterRule(EnglishCharacterData.UpperCase, 1));
// require at least 1 lower case char // require at least 1 lower case char
defaultCharacterRules.add(new LowercaseCharacterRule(1)); defaultCharacterRules.add(new CharacterRule(EnglishCharacterData.LowerCase, 1));
return defaultCharacterRules; return defaultCharacterRules;
} }
......
# #
# Copyright (c) 2014 NIBIO <http://www.nibio.no/>. # Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
# #
# This file is part of VIPSLogic. # This file is part of VIPSLogic.
# VIPSLogic is free software: you can redistribute it and/or modify # VIPSLogic is free software: you can redistribute it and/or modify
...@@ -17,21 +17,26 @@ ...@@ -17,21 +17,26 @@
# #
# This (and and corresponding localized) property file(s) # This (and and corresponding localized) property file(s)
# Localizes the error messages given from the vt-password properties files # Localizes the error messages given from the passay properties files
# @see UserBean.isPasswordValid() and http://code.google.com/p/vt-middleware/wiki/vtpassword # @see UserBean.isPasswordValid() and http://www.passay.org/reference/
# for usage # for usage
HISTORY_VIOLATION=Password matches one of %1$s previous passwords. HISTORY_VIOLATION=Password matches one of %1$s previous passwords.
ILLEGAL_WORD=Password contains the dictionary word '%1$s'. ILLEGAL_WORD=Password contains the dictionary word '%1$s'.
ILLEGAL_WORD_REVERSED=Password contains the reversed dictionary word '%1$s'. ILLEGAL_WORD_REVERSED=Password contains the reversed dictionary word '%1$s'.
ILLEGAL_MATCH=Password matches the illegal sequence '%1$s'. ILLEGAL_MATCH=Password matches the illegal pattern '%1$s'.
ALLOWED_MATCH=Password must match pattern '%1$s'.
ILLEGAL_CHAR=Password contains the illegal character '%1$s'. ILLEGAL_CHAR=Password contains the illegal character '%1$s'.
ALLOWED_CHAR=Password contains the illegal character '%1$s'.
ILLEGAL_SEQUENCE=Password contains the illegal sequence '%1$s'. ILLEGAL_SEQUENCE=Password contains the illegal sequence '%1$s'.
ILLEGAL_USERNAME=Password contains the user id '%1$s'. ILLEGAL_USERNAME=Password contains the user id '%1$s'.
ILLEGAL_USERNAME_REVERSED=Password contains the user id '%1$s' in reverse. ILLEGAL_USERNAME_REVERSED=Password contains the user id '%1$s' in reverse.
ILLEGAL_WHITESPACE=Password cannot contain whitespace characters. ILLEGAL_WHITESPACE=Password cannot contain whitespace characters.
INSUFFICIENT_CHARACTERS=Password must contain at least %1$s %2$s characters. INSUFFICIENT_UPPERCASE=Password must contain at least %1$s uppercase characters.
INSUFFICIENT_CHARACTERISTICS=Password matches %1$s of %2$s character rules, but %3$s are required. INSUFFICIENT_LOWERCASE=Password must contain at least %1$s lowercase characters.
INSUFFICIENT_ALPHABETICAL=Password must contain at least %1$s alphabetical characters.
INSUFFICIENT_DIGIT=Password must contain at least %1$s digit characters.
INSUFFICIENT_SPECIAL=Password must contain at least %1$s special characters.
INSUFFICIENT_CHARACTERISTICS=Password matches %1$s of %3$s character rules, but %2$s are required.
SOURCE_VIOLATION=Password cannot be the same as your %1$s password. SOURCE_VIOLATION=Password cannot be the same as your %1$s password.
TOO_LONG=Password must be no more than %2$s characters in length. TOO_LONG=Password must be no more than %2$s characters in length.
TOO_SHORT=Password must be at least %1$s characters in length. TOO_SHORT=Password must be at least %1$s characters in length.
\ No newline at end of file
# #
# Copyright (c) 2014 NIBIO <http://www.nibio.no/>. # Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
# #
# This file is part of VIPSLogic. # This file is part of VIPSLogic.
# VIPSLogic is free software: you can redistribute it and/or modify # VIPSLogic is free software: you can redistribute it and/or modify
...@@ -17,21 +17,26 @@ ...@@ -17,21 +17,26 @@
# #
# This (and and corresponding localized) property file(s) # This (and and corresponding localized) property file(s)
# Localizes the error messages given from the vt-password properties files # Localizes the error messages given from the passay properties files
# @see UserBean.isPasswordValid() and http://code.google.com/p/vt-middleware/wiki/vtpassword # @see UserBean.isPasswordValid() and http://www.passay.org/reference/
# for usage # for usage
HISTORY_VIOLATION=Passordet er det samme som et av %1$s forrige passord. HISTORY_VIOLATION=Passordet er det samme som %1$s tidligere passord.
ILLEGAL_WORD=Passordet inneholder det ordlisteoppf\u00f8rte ordet '%1$s'. ILLEGAL_WORD=Passordet inneholder ordet '%1$s'.
ILLEGAL_WORD_REVERSED=Passordet inneholder det ordlisteoppf\u00f8rte ordet '%1$s' baklengs. ILLEGAL_WORD_REVERSED=Passordet inneholder ordet '%1$s' baklengs.
ILLEGAL_MATCH=Passordet er den ulovlige sekvensen '%1$s'. ILLEGAL_MATCH=Passordet matcher det ulovlige m\u00f8nsteret '%1$s'.
ALLOWED_MATCH=Passordet m\u00e5 matche m\u00f8nsteret '%1$s'.
ILLEGAL_CHAR=Passordet inneholder det ulovlige tegnet '%1$s'. ILLEGAL_CHAR=Passordet inneholder det ulovlige tegnet '%1$s'.
ALLOWED_CHAR=Passordet inneholder det ulovlige tegnet '%1$s'.
ILLEGAL_SEQUENCE=Passordet inneholder den ulovlige sekvensen '%1$s'. ILLEGAL_SEQUENCE=Passordet inneholder den ulovlige sekvensen '%1$s'.
ILLEGAL_USERNAME=Passordet inneholder brukerid '%1$s'. ILLEGAL_USERNAME=Passordet inneholder bruker-iden '%1$s'.
ILLEGAL_USERNAME_REVERSED=Passordet inneholder brukerid '%1$s' baklengs. ILLEGAL_USERNAME_REVERSED=Passordet inneholder bruker-iden '%1$s' baklengs.
ILLEGAL_WHITESPACE=Passordet kan ikke inneholde blanke tegn. ILLEGAL_WHITESPACE=Passordet kan ikke inneholder mellomrom.
INSUFFICIENT_CHARACTERS=Passordet m\u00e5 ha minst %1$s %2$s-tegn. INSUFFICIENT_UPPERCASE=Passordet m\u00e5 inneholdet minst %1$s STORE BOKSTAV(ER).
INSUFFICIENT_CHARACTERISTICS=Passordet stemmer med %1$s av %2$s tegnsettregler, men %3$s kreves. INSUFFICIENT_LOWERCASE=Passordet m\u00e5 inneholde minst %1$s sm\u00e5 bokstav(er).
SOURCE_VIOLATION=Passordet kan ikke v\u00e6re det samme som ditt %1$s passord. INSUFFICIENT_ALPHABETICAL=Passordet m\u00e5 inneholde minst %1$s bokstav.
INSUFFICIENT_DIGIT=Passordet m\u00e5 inneholde minst %1$s tall.
INSUFFICIENT_SPECIAL=Passordet m\u00e5 inneholde minst %1$s spesialtegn.
INSUFFICIENT_CHARACTERISTICS=Passordet matcher %1$s av %3$s krav, men %2$s kreves.
SOURCE_VIOLATION=Passordet kan ikke v\u00e6re det samme som ditt %1$s-passord.
TOO_LONG=Passordet kan ikke v\u00e6re lenger enn %2$s tegn. TOO_LONG=Passordet kan ikke v\u00e6re lenger enn %2$s tegn.
TOO_SHORT=Passordet m\u00e5 v\u00e6re minst %1$s tegn langt. TOO_SHORT=Passordet m\u00e5 v\u00e6re minst %1$s tegn langt.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment