class urn_perun_user_attribute_def_def_IPAddresses extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi {

	@Override
	public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongAttributeValueException {
		List<String> value = attribute.valueAsList();
		if (value != null) {
			for (String address : value) {
				Matcher matcherIPv4 = IPv4_PATTERN.matcher(address);
				Matcher matcherIPv6 = IPv6_PATTERN.matcher(address);
				Matcher matcherIPv6Short = IPv6_PATTERN_SHORT.matcher(address);
				if (!matcherIPv4.matches() && !matcherIPv6.matches() && !matcherIPv6Short.matches())
					throw new WrongAttributeValueException(attribute, "IP address is not in the correct format.");
			}
		}
	}

}