@@ -0,0 +1,2255 @@
+package cz.metacentrum.perun.core.impl.modules.attributes;%0A%0Aimport cz.metacentrum.perun.core.api.Attribute;%0Aimport cz.metacentrum.perun.core.api.AttributeDefinition;%0Aimport cz.metacentrum.perun.core.api.AttributesManager;%0Aimport cz.metacentrum.perun.core.api.User;%0Aimport cz.metacentrum.perun.core.api.UserExtSource;%0Aimport cz.metacentrum.perun.core.api.exceptions.*;%0Aimport cz.metacentrum.perun.core.impl.PerunSessionImpl;%0Aimport cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleAbstract;%0Aimport cz.metacentrum.perun.core.implApi.modules.attributes.UserVirtualAttributesModuleImplApi;%0A%0Aimport java.util.List;%0A%0A/**%0A * Module for user virtual attribute loa%0A *%0A * This module return the highest value from user's UserExtSources Loas. If the attribute is null throw new WrongAttributeValueException.%0A *%0A * @author Pavel Vyskocil vyskocilpavel@muni.cz%0A */%0Apublic class urn_perun_user_attribute_def_virt_loa extends UserVirtualAttributesModuleAbstract implements UserVirtualAttributesModuleImplApi %7B%0A%0A%09public void checkAttributeValue(PerunSessionImpl sess, User user, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException %7B%0A%09%09if(attribute.getValue() != null) throw new WrongAttributeValueException(attribute, user, %22Attribute value is null.%22);%0A%09%7D%0A%0A%09public Attribute getAttributeValue(PerunSessionImpl sess, User user, AttributeDefinition attributeDefinition) throws InternalErrorException %7B%0A%0A%09%09List%3CUserExtSource%3E extSources = sess.getPerunBl().getUsersManagerBl().getActiveUserExtSources(sess, user);%0A%09%09Integer maxLoa = 0;%0A%09%09for(UserExtSource e : extSources) %7B%0A%09%09%09if(maxLoa %3C e.getLoa()) maxLoa = e.getLoa();%0A%09%09%7D%0A%09%09Attribute attribute = new Attribute(attributeDefinition);%0A%09%09attribute.setValue(maxLoa.toString());%0A%09%09return attribute;%0A%09%7D%0A%0A%09public AttributeDefinition getAttributeDefinition() %7B%0A%09%09AttributeDefinition attr = new AttributeDefinition();%0A%09%09attr.setNamespace(AttributesManager.NS_USER_ATTR_VIRT);%0A%09%09attr.setFriendlyName(%22loa%22);%0A%09%09attr.setDisplayName(%22Level of assurance%22);%0A%09%09attr.setType(String.class.getName());%0A%09%09attr.setDescription(%22The highest value of LoA from all user's userExtSources.%22);%0A%09%09return attr;%0A%09%7D%0A%0A%7D%0A

Add attribute module for loa in Perun