public class EndUserRegistrationFormValidator extends Object
Modifier and Type | Field and Description |
---|---|
static Logger |
logger
Logger.
|
protected static String |
USERNAMEREGEX
Allowed usernames regular expression, allowed only A-Z, a-z,0-9.
|
Constructor and Description |
---|
EndUserRegistrationFormValidator() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isValid(String username,
String password,
String email,
String givenName,
String familyName)
Check the validity of required parameters.
|
static boolean |
isValid(String username,
String password,
String email,
String givenName,
String familyName,
Date birthDate,
String addressCountry,
String postalCode,
String streetAddress,
String addressLocality,
String addressRegion,
String telephone,
String userURL,
String gender,
String organization,
String organizationURL,
Long recyclebinuserid)
Check the validity of all possible parameters.
|
static void |
validate(Date birthDate,
String addressCountry,
String postalCode,
String streetAddress,
String addressLocality,
String addressRegion,
String telephone,
String userURL,
String gender,
String organization,
String organizationURL,
Long recyclebinuserid)
Validate the parameters passed and throw
IllegalArgumentException in
case of any error. |
static void |
validate(String email,
String givenName,
String familyName,
Date birthDate,
String addressCountry,
String postalCode,
String streetAddress,
String addressLocality)
Validate the parameters passed and throw
IllegalArgumentException in
case of any error. |
static void |
validate(String username,
String password,
String email,
String givenName,
String familyName)
Validate the parameters passed and throw
IllegalArgumentException in
case of any error. |
static void |
validateCredentials(String username,
String password)
Validate the parameters passed and throw
IllegalArgumentException in
case of any error.CAUTION: You cannot validate password without username, as one of the requirements is for the password to be different from the username. |
static void |
validateEmail(String email)
Validate the parameters passed and throw
IllegalArgumentException in
case of any error. |
static void |
validateFamilyName(String familyName)
Validate user's last name.
|
static void |
validateGivenName(String givenName)
Validate user's first name.
|
static void |
validateHTTPURL(String url)
Validate the parameters passed and throw
MalformedURLException in
case of any error. |
public static final Logger logger
protected static final String USERNAMEREGEX
public static boolean isValid(String username, String password, String email, String givenName, String familyName)
username
- user name. Required. At least 8 characters
of length, allowed only A-Z, a-z, 0-9.password
- password. Required. At least 8 characters
of length, not equal to username.email
- e-mail. Required. Accepts only valid email
addresses according to RFC822, RFC5322. Extra conditions
that need to be met for ICT Platform: Local domains not
allowed, e.g. user@localhost, user@localhost.localdomain,
user@somehost.localdomain, IP addresses not allowed, e.g.
user@127.0.0.1, user@10.0.1.1, user@8.8.8.8,
user@147.102.5.97, user@192.168.1.245, Number of characters
in top level domain must not less than 2 or more than 6,
e.g. username@yahoo.c, username@yahoo.corporate.givenName
- first name. Required. At least 2
characters of length, allowed first, last name regular
expression, At least 2 and not more than 256 characters of
length, allows any character except numbers(0-9) and these
(<>, {}, [], !, @, #, $, %, ^, &, *, +, \, |, /, ?,
`, ~)
.familyName
- last name. Required. At least 2 characters
of length, allowed first, last name regular expression, At
least 2 and not more than 256 characters of length, allows
any character except numbers(0-9) and these (<>, {},
[], !, @, #, $, %, ^, &, *, +, \, |, /, ?, `, ~)
.true
if all parameters are valid, false
otherwise.public static boolean isValid(String username, String password, String email, String givenName, String familyName, Date birthDate, String addressCountry, String postalCode, String streetAddress, String addressLocality, String addressRegion, String telephone, String userURL, String gender, String organization, String organizationURL, Long recyclebinuserid)
username
- user name. Required. At least 8
characters of length, allowed only A-Z, a-z,0-9.password
- password. Required. At least 8
characters of length, not equal to username.email
- e-mail. Required. Accepts only valid
email addresses according to RFC822, RFC5322. Extra
conditions that need to be met for ICT Platform:
Local domains not allowed, e.g. user@localhost,
user@localhost.localdomain,
user@somehost.localdomain, IP addresses not allowed,
e.g. user@127.0.0.1, user@10.0.1.1, user@8.8.8.8,
user@147.102.5.97, user@192.168.1.245, Number of
characters in top level domain must not less than 2
or more than 6, e.g. username@yahoo.c,
username@yahoo.corporate.givenName
- first name. Required. At least 2
characters of length, allowed first, last name
regular expression, At least 2 and not more than 256
characters of length, allows any character except
numbers(0-9) and these (<>, {}, [], !, @, #, $, %, ^,
&, *, +, \, |, /, ?, `, ~)
.familyName
- last name. Required. At least 2
characters of length, allowed first, last name
regular expression, At least 2 and not more than 256
characters of length, allows any character except
numbers(0-9) and these (<>, {}, [], !, @, #, $, %, ^,
&, *, +, \, |, /, ?, `, ~)
.birthDate
- Date of birth. Optional. Must
represent a Date of the past, at least 5 years old.addressCountry
- Country code. Optional. Country 2
letter ISO 639 alpha-2 codepostalCode
- Postal code of address area.
Optional. Cannot be an empty string.streetAddress
- Street address (street name, number, city, area).
Optional. Cannot be an empty string.addressLocality
- The locality/city in which the street address is
located. Optional. Cannot be an
empty string.addressRegion
- The region in which the city belongs.
Optional. Cannot be an empty string.telephone
- Telephone number. Optional. At least
4 characters of length, allowed only + as first
character,0-9.userURL
- User's profile URL. Optional. Valid
HTTP, HTTPs URL.gender
- Gender. Optional. Free text.organization
- A user's affiliated organization, e.g. Company,
University, Club, Team, etc.
Optional. Free Text.organizationURL
- User's organization URL. Optional.
Valid HTTP, HTTPs URL.recyclebinuserid
- Intelligent Bin User code as an 11 digit integer.
Optional. ZIP code is first 5 digits
(e.g. 16004), 6 last digits are sequential (e.g.
000001). Minimum = 0, Maximum = 99999999999.true
if all parameters are valid, false
otherwise.public static void validate(String username, String password, String email, String givenName, String familyName) throws IllegalArgumentException
IllegalArgumentException
in
case of any error.username
- user name. At least 8 characters of length, allowed only
A-Z, a-z, 0-9.password
- password. At least 8 characters of length, not equal to
username.email
- e-mail.givenName
- first name. Allowed first, last name regular expression, At
least 2 and not more than 256 characters of length, allows
any character except numbers(0-9) and these (<>, {}, [],
!, @, #, $, %, ^, &, *, +, \, |, /, ?, `, ~)
.familyName
- last name. Allowed first, last name regular expression, At
least 2 and not more than 256 characters of length, allows
any character except numbers(0-9) and these (<>, {}, [],
!, @, #, $, %, ^, &, *, +, \, |, /, ?, `, ~)
.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.public static void validate(Date birthDate, String addressCountry, String postalCode, String streetAddress, String addressLocality, String addressRegion, String telephone, String userURL, String gender, String organization, String organizationURL, Long recyclebinuserid) throws IllegalArgumentException
IllegalArgumentException
in
case of any error.birthDate
- birthday date.addressCountry
- 2-letter country code, e.g. GR.postalCode
- Postal code number.streetAddress
- Full street address, name, number, town.addressLocality
- City name.addressRegion
- Address region.telephone
- telephone number.userURL
- user profile URL.gender
- gender.organization
- affiliated organization name.organizationURL
- affiliated organization URL.recyclebinuserid
- recycle bin system user ID.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.public static void validate(String email, String givenName, String familyName, Date birthDate, String addressCountry, String postalCode, String streetAddress, String addressLocality) throws IllegalArgumentException
IllegalArgumentException
in
case of any error.email
- e-mail.givenName
- first name.familyName
- last name.birthDate
- birthday date.addressCountry
- 2-letter country code, e.g. GR.postalCode
- Postal code number.streetAddress
- Full street address, name, number, town.addressLocality
- City name.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.public static void validateHTTPURL(String url) throws MalformedURLException
MalformedURLException
in
case of any error.url
- HTTP(s) URL. MUST NOT BE null
MalformedURLException
- thrown if any of the required input parameters
is not valid.public static void validateCredentials(String username, String password) throws IllegalArgumentException
IllegalArgumentException
in
case of any error.username
- user name. At least 8 characters of length, allowed only A-Z,
a-z, 0-9.password
- password. At least 8 characters of length, not equal to
username.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.public static void validateEmail(String email) throws IllegalArgumentException
IllegalArgumentException
in
case of any error.email
- Email address.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.public static void validateGivenName(String givenName) throws IllegalArgumentException
(<>, {}, [], !, @, #, $, %, ^, &, *, +, \, |,
/, ?, `, ~)
.givenName
- first name.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.public static void validateFamilyName(String familyName) throws IllegalArgumentException
(<>, {}, [], !, @, #, $, %, ^, &, *, +, \, |,
/, ?, `, ~)
.familyName
- last name.IllegalArgumentException
- thrown if any of the required input
parameters is not valid.Copyright © 2020. All rights reserved.