use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class ResourceAttributeProcessor method processVirtualAttributeChanged.
public void processVirtualAttributeChanged(String msg, MessageBeans beans) {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
if (beans.getAttribute() == null || beans.getResource() == null) {
return;
}
try {
Attribute virtAttr = perun.getAttributesManagerBl().getAttribute(ldapcManager.getPerunSession(), beans.getResource(), beans.getAttribute().getName());
log.debug("Changing virtual attribute {} for resource {}", virtAttr, beans.getResource());
perunResource.modifyEntry(beans.getResource(), virtAttr);
} catch (InternalErrorException | AttributeNotExistsException | WrongAttributeAssignmentException | NamingException e) {
log.error("Error changing virtual attribute:", e);
}
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class VirtualAttributeEventProcessor method processAllGroupAttributesRemoval.
public void processAllGroupAttributesRemoval(String msg, MessageBeans beans) {
// ensure we have the correct beans available
if (beans.getGroup() == null) {
return;
}
try {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
Collection<PerunVirtualAttribute<User>> attrDefs = dependencyManager.getAllAttributeDependants();
log.debug("Processing group {} all attribute removal, affected attributes {}", beans.getGroup(), attrDefs);
if (attrDefs != null) {
for (User user : perun.getGroupsManagerBl().getGroupUsers(ldapcManager.getPerunSession(), beans.getGroup())) {
/* get attribute value for each dependent attribute */
Collection<Pair<PerunAttribute<User>, AttributeDefinition>> userAttrs = this.getAttributeValues(perun, user, attrDefs);
log.debug("Modifying user {} entry with the new values {}", user.getId(), userAttrs);
perunUser.modifyEntry(user, userAttrs);
}
}
} catch (InternalErrorException e) {
log.error("Error processing group {} attributes removal: {}", beans.getGroup(), e.getMessage());
}
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class AbstractSynchronizer method fillPerunAttributeNames.
protected List<String> fillPerunAttributeNames(List<String> attrNames) {
PerunBl perun = (PerunBl) ldapcManager.getPerunBl();
List<String> result = new ArrayList<String>();
for (String name : attrNames) {
if (name.endsWith(":")) {
result.addAll(perun.getAttributesManagerBl().getAllSimilarAttributeNames(ldapcManager.getPerunSession(), name));
} else {
result.add(name);
}
}
return result;
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class EgiuiPasswordManagerModule method validatePassword.
@Override
public void validatePassword(PerunSession sess, String userLogin, User user) throws InvalidLoginException {
if (user == null) {
user = ((PerunBl) sess.getPerun()).getModulesUtilsBl().getUserByLoginInNamespace(sess, userLogin, actualLoginNamespace);
}
if (user == null) {
log.warn("No user was found by login '{}' in {} namespace.", userLogin, actualLoginNamespace);
} else {
// set extSources and extSource related attributes
try {
List<String> kerberosLogins = new ArrayList<>();
ExtSource extSource = ((PerunBl) sess.getPerun()).getExtSourcesManagerBl().getExtSourceByName(sess, "EGI");
UserExtSource ues = new UserExtSource(extSource, userLogin + "@EGI");
ues.setLoa(0);
try {
((PerunBl) sess.getPerun()).getUsersManagerBl().addUserExtSource(sess, user, ues);
} catch (UserExtSourceExistsException ex) {
// this is OK
}
// Store also Kerberos logins
Attribute kerberosLoginsAttr = ((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttribute(sess, user, AttributesManager.NS_USER_ATTR_DEF + ":" + "kerberosLogins");
if (kerberosLoginsAttr != null && kerberosLoginsAttr.getValue() != null) {
kerberosLogins.addAll((List<String>) kerberosLoginsAttr.getValue());
}
if (!kerberosLogins.contains(userLogin + "@EGI") && kerberosLoginsAttr != null) {
kerberosLogins.add(userLogin + "@EGI");
kerberosLoginsAttr.setValue(kerberosLogins);
((PerunBl) sess.getPerun()).getAttributesManagerBl().setAttribute(sess, user, kerberosLoginsAttr);
}
} catch (WrongAttributeAssignmentException | AttributeNotExistsException | ExtSourceNotExistsException | WrongAttributeValueException | WrongReferenceAttributeValueException ex) {
throw new InternalErrorException(ex);
}
}
// validate password
super.validatePassword(sess, userLogin, user);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class EinfraservicesPasswordManagerModule method validatePassword.
@Override
public void validatePassword(PerunSession sess, String userLogin, User user) throws InvalidLoginException {
if (user == null) {
user = ((PerunBl) sess.getPerun()).getModulesUtilsBl().getUserByLoginInNamespace(sess, userLogin, actualLoginNamespace);
}
if (user == null) {
log.warn("No user was found by login '{}' in {} namespace.", userLogin, actualLoginNamespace);
} else {
// set extSources and extSource related attributes
try {
ExtSource extSource = ((PerunBl) sess.getPerun()).getExtSourcesManagerBl().getExtSourceByName(sess, "EINFRA-SERVICES");
UserExtSource ues = new UserExtSource(extSource, userLogin + "@EINFRA-SERVICES");
ues.setLoa(0);
try {
((PerunBl) sess.getPerun()).getUsersManagerBl().addUserExtSource(sess, user, ues);
} catch (UserExtSourceExistsException ex) {
// this is OK
}
List<String> kerberosLogins = new ArrayList<>();
// Store also Kerberos logins
Attribute kerberosLoginsAttr = ((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttribute(sess, user, AttributesManager.NS_USER_ATTR_DEF + ":" + "kerberosLogins");
if (kerberosLoginsAttr != null && kerberosLoginsAttr.getValue() != null) {
kerberosLogins.addAll((List<String>) kerberosLoginsAttr.getValue());
}
if (!kerberosLogins.contains(userLogin + "@EINFRA-SERVICES") && kerberosLoginsAttr != null) {
kerberosLogins.add(userLogin + "@EINFRA-SERVICES");
kerberosLoginsAttr.setValue(kerberosLogins);
((PerunBl) sess.getPerun()).getAttributesManagerBl().setAttribute(sess, user, kerberosLoginsAttr);
}
} catch (WrongAttributeAssignmentException | AttributeNotExistsException | ExtSourceNotExistsException | WrongAttributeValueException | WrongReferenceAttributeValueException ex) {
throw new InternalErrorException(ex);
}
}
// validate password
super.validatePassword(sess, userLogin, user);
}
Aggregations