use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeRemoved5.
@Test
public void resolveVirtualAttributeValueChangeRemoved5() throws Exception {
AuditEvent userRem = new AttributeRemovedForUser(o365MailsAttr, user);
List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userRem);
assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeRemoved2.
@Test
public void resolveVirtualAttributeValueChangeRemoved2() throws Exception {
AuditEvent userRem = new AttributeRemovedForUser(isMailAttr, user);
List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userRem);
assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeRemoved1.
@Test
public void resolveVirtualAttributeValueChangeRemoved1() throws Exception {
AuditEvent userRem = new AttributeRemovedForUser(preferredMailAttr, user);
List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userRem);
assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_eduPersonScopedAffiliations method resolveVirtualAttributeValueChange.
@Override
public List<AuditEvent> resolveVirtualAttributeValueChange(PerunSessionImpl perunSession, AuditEvent message) throws WrongReferenceAttributeValueException, AttributeNotExistsException, WrongAttributeAssignmentException {
// generic handling
List<AuditEvent> resolvingMessages = super.resolveVirtualAttributeValueChange(perunSession, message);
if (message instanceof AttributeSetForUser && ((AttributeSetForUser) message).getAttribute().getFriendlyName().equals(getSecondarySourceAttributeFriendlyName())) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), ((AttributeSetForUser) message).getUser()));
} else if (message instanceof AttributeRemovedForUser && ((AttributeRemovedForUser) message).getAttribute().getFriendlyName().equals(getSecondarySourceAttributeFriendlyName())) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), ((AttributeRemovedForUser) message).getUser()));
} else if (message instanceof AllAttributesRemovedForUser) {
boolean skip = false;
try {
AttributeDefinition sourceExists = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getSecondarySourceAttributeName());
User user = perunSession.getPerunBl().getUsersManagerBl().getUserById(perunSession, ((AllAttributesRemovedForUser) message).getUser().getId());
} catch (AttributeNotExistsException | UserNotExistsException ex) {
// silently skip this event, since source attribute couldn't be between deleted
// or user no longer exist
skip = true;
}
if (!skip) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), ((AllAttributesRemovedForUser) message).getUser()));
}
}
if (message instanceof AttributeSetForGroup && !VosManager.MEMBERS_GROUP.equals(((AttributeSetForGroup) message).getGroup().getName()) && ((AttributeSetForGroup) message).getAttribute().getName().equals(getTertiarySourceAttributeName())) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
// TODO - get only active group users, since expired are not affected by current group affiliations
List<User> users = perunSession.getPerunBl().getGroupsManagerBl().getGroupUsers(perunSession, ((AttributeSetForGroup) message).getGroup());
for (User user : users) {
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), user));
}
} else if (message instanceof AttributeRemovedForGroup && !VosManager.MEMBERS_GROUP.equals(((AttributeRemovedForGroup) message).getGroup().getName()) && ((AttributeRemovedForGroup) message).getAttribute().getName().equals(getTertiarySourceAttributeName())) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
// TODO - get only active group users, since expired are not affected by current group affiliations
List<User> users = perunSession.getPerunBl().getGroupsManagerBl().getGroupUsers(perunSession, ((AttributeRemovedForGroup) message).getGroup());
for (User user : users) {
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), user));
}
} else if (message instanceof AllAttributesRemovedForGroup && !VosManager.MEMBERS_GROUP.equals(((AllAttributesRemovedForGroup) message).getGroup().getName())) {
boolean skip = false;
try {
AttributeDefinition sourceExists = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getTertiarySourceAttributeName());
Group group = perunSession.getPerunBl().getGroupsManagerBl().getGroupById(perunSession, ((AllAttributesRemovedForGroup) message).getGroup().getId());
} catch (AttributeNotExistsException | GroupNotExistsException ex) {
// silently skip this event, since source attribute couldn't be between deleted
// or group no longer exist.
skip = true;
}
if (!skip) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
// TODO - get only active group users, since expired are not affected by current group affiliations
List<User> users = perunSession.getPerunBl().getGroupsManagerBl().getGroupUsers(perunSession, ((AllAttributesRemovedForGroup) message).getGroup());
for (User user : users) {
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), user));
}
}
}
return resolvingMessages;
}
use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_tcsMails_mu method resolveVirtualAttributeValueChange.
@Override
public List<AuditEvent> resolveVirtualAttributeValueChange(PerunSessionImpl perunSession, AuditEvent message) throws AttributeNotExistsException {
List<AuditEvent> resolvingMessages = new ArrayList<>();
// handle source user attributes changes
if (message instanceof AttributeSetForUser && isAffectedAttribute(((AttributeSetForUser) message).getAttribute().getFriendlyName())) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, this.getAttributeDefinition().getName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), ((AttributeSetForUser) message).getUser()));
} else if (message instanceof AttributeRemovedForUser && isAffectedAttribute(((AttributeRemovedForUser) message).getAttribute().getFriendlyName())) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, this.getAttributeDefinition().getName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), ((AttributeRemovedForUser) message).getUser()));
} else if (message instanceof AllAttributesRemovedForUser) {
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, this.getAttributeDefinition().getName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), ((AllAttributesRemovedForUser) message).getUser()));
}
return resolvingMessages;
}
Aggregations