use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_eduPersonPrincipalNames method getAttributeValue.
@Override
public Attribute getAttributeValue(PerunSessionImpl sess, User user, AttributeDefinition attributeDefinition) throws InternalErrorException {
Attribute attribute = new Attribute(attributeDefinition);
List<String> idpLogins = new ArrayList<String>();
List<UserExtSource> userExtSources = sess.getPerunBl().getUsersManagerBl().getUserExtSources(sess, user);
for (UserExtSource uES : userExtSources) {
if (uES.getExtSource() != null) {
String login = uES.getLogin();
String type = uES.getExtSource().getType();
if (type != null && login != null) {
// insert only EPPN formatted data
if (type.equals(ExtSourcesManager.EXTSOURCE_IDP) && login.matches("[^@]+@[^@]+")) {
idpLogins.add(login);
}
}
}
}
attribute = new Attribute(attributeDefinition);
attribute.setValue(idpLogins);
return attribute;
}
use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getUserExtSourceAttributeByIdWhenAttributeNotExists.
@Test(expected = AttributeNotExistsException.class)
public void getUserExtSourceAttributeByIdWhenAttributeNotExists() throws Exception {
System.out.println(CLASS_NAME + "getUserExtSourceAttributeByIdWhenAttributeNotExists");
UserExtSource ues = setUpUserExtSourceTest();
attributesManager.getAttributeById(sess, ues, 0);
// shouldn't find attribute
}
use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getUserExtSourceAttribute.
@Test
public void getUserExtSourceAttribute() throws Exception {
System.out.println(CLASS_NAME + "getUserExtSourceAttribute");
UserExtSource ues = setUpUserExtSourceTest();
attributes = setUpUserExtSourceAttribute();
attributesManager.setAttributes(sess, ues, attributes);
Attribute retAttr = attributesManager.getAttribute(sess, ues, "urn:perun:ues:attribute-def:opt:userExtSource-test-attribute");
assertNotNull("unable to get opt user external source attribute ", retAttr);
assertEquals("returned opt attr value is not correct", retAttr.getValue(), attributes.get(0).getValue());
}
use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method getUserExtSourceAttributeById.
@Test
public void getUserExtSourceAttributeById() throws Exception {
System.out.println(CLASS_NAME + "getUserExtSourceAttributeById");
UserExtSource ues = setUpUserExtSourceTest();
attributes = setUpUserExtSourceAttribute();
attributesManager.setAttributes(sess, ues, attributes);
int id = attributes.get(0).getId();
Attribute retAttr = attributesManager.getAttributeById(sess, ues, id);
assertNotNull("unable to get userExtSource attribute by id", retAttr);
assertEquals("returned attribute is not same as stored", retAttr, attributes.get(0));
}
use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.
the class AttributesManagerEntryIntegrationTest method setUserExtSourceAttributeWhenWrongAttrAssignment.
@Test(expected = WrongAttributeAssignmentException.class)
public void setUserExtSourceAttributeWhenWrongAttrAssignment() throws Exception {
System.out.println(CLASS_NAME + "setUserExtSourceAttributeWhenWrongAttrAssignment");
UserExtSource ues = setUpUserExtSourceTest();
attributes = setUpVoAttribute();
attributesManager.setAttribute(sess, ues, attributes.get(0));
// shouldn't add vo attribute into userExtSource
}
Aggregations