class urn_perun_user_attribute_def_def_preferredEduPersonPrincipalName extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi {

	@Override
	public void checkAttributeSemantics(PerunSessionImpl perunSession, User user, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException {

		String value = attribute.valueAsString();
		try {
			Attribute eppns = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, user, A_U_eduPersonPrincipalNames);
			if (eppns.getValue() != null) {
				List<String> values = eppns.valueAsList();
				if (!values.contains(value)) {
					// value is not allowed
					throw new WrongReferenceAttributeValueException(attribute, eppns, user, null, user, null, "Value '"+value+"' is not allowed. Please use one of allowed.");
				}
			} else {
				// available EPPNs are null, only allowed value is null.
				if (value != null) throw new WrongReferenceAttributeValueException(attribute, eppns, user, null, user, null, "Value '"+value+"' is not allowed. Please use one of allowed.");
			}
		} catch (AttributeNotExistsException ex) {
			throw new ConsistencyErrorException("Can't check attribute value because source attribute " + A_U_eduPersonPrincipalNames + " not exist!", ex);
		}

	}

}