@Override public List<Identity> checkForSimilarUsers(PerunSession sess, List<ApplicationFormItemData> formItems) throws PerunException { if (sess.getPerunPrincipal().getUser() != null || formItems == null) { return new ArrayList<Identity>(); } Set<RichUser> res = new HashSet<RichUser>(); List<String> attrNames = new ArrayList<String>(); attrNames.add("urn:perun:user:attribute-def:def:preferredMail"); attrNames.add("urn:perun:user:attribute-def:def:organization"); for (ApplicationFormItemData item : formItems) { String value = item.getValue(); if (item.getFormItem().getType().equals(ApplicationFormItem.Type.VALIDATED_EMAIL)) { // search by email if (value != null && !value.isEmpty()) res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, value, attrNames)); } if (Objects.equals(item.getFormItem().getPerunDestinationAttribute(), "urn:perun:user:attribute-def:core:displayName")) { // search by name if (value != null && !value.isEmpty()) res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, value, attrNames)); } } return convertToIdentities(new ArrayList<RichUser>(res)); }
perun.getUsersManager().getUserByExtSourceNameAndExtLogin(registrarSession, sess.getPerunPrincipal().getExtSourceName(), sess.getPerunPrincipal().getActor()); return new ArrayList<Identity>(); } catch (Exception ex) { for (String m : mailSearch) { if (m != null && !m.isEmpty()) res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, m, attrNames)); res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, mail, attrNames)); if (name != null && !name.isEmpty()) res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, name, attrNames)); if (name != null && !name.isEmpty()) res.addAll(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, name, attrNames));
public void updatePriorityCoefficient(PerunSession sess, Integer userId, Double rank) throws CabinetException { try { // get definition AttributeDefinition attrDef = perun.getAttributesManager().getAttributeDefinition(cabinetSession, ATTR_COEF_NAMESPACE+":"+ATTR_COEF_FRIENDLY_NAME); // Set attribute value Attribute attr = new Attribute(attrDef); DecimalFormat twoDForm = new DecimalFormat("#.##"); attr.setValue(String.valueOf(twoDForm.format(rank))); // get user User user = perun.getUsersManager().getUserById(cabinetSession, userId); // assign or update user's attribute perun.getAttributesManager().setAttribute(cabinetSession, user, attr); } catch (PerunException e) { throw new CabinetException("Failed to update priority coefficient in Perun.",ErrorCodes.PERUN_EXCEPTION, e); } }
/** * Init method, instantiate PerunSession * * @throws PerunException */ protected void initialize() throws PerunException { // gets session for a system principal "perunRegistrar" final PerunPrincipal pp = new PerunPrincipal("perunRegistrar", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL); registrarSession = perun.getPerunSession(pp, new PerunClient()); this.attrManager = perun.getAttributesManager(); this.membersManager = perun.getMembersManager(); this.usersManager = perun.getUsersManager(); this.groupsManager = perun.getGroupsManager(); }
User u = perun.getUsersManager().getUserById(cabinetSession, userId);
User u = perun.getUsersManager().getUserByExtSourceNameAndExtLogin(registrarSession, app.getExtSourceName(), app.getCreatedBy()); if (u != null) { List<RichUser> users = (email != null && !email.isEmpty()) ? perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, email, attrNames) : new ArrayList<RichUser>(); users = (email != null && !email.isEmpty()) ? perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, email, attrNames) : new ArrayList<RichUser>(); if (users != null && !users.isEmpty()) { users = (name != null && !name.isEmpty()) ? perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, name, attrNames) : new ArrayList<RichUser>(); if (users != null && !users.isEmpty()) { return convertToIdentities(perun.getUsersManager().findRichUsersWithAttributesByExactMatch(registrarSession, name, attrNames)); } else {
memberEmailDto.setMessage(messageDto.getMessageToSend()); memberEmailDto.setSubject(messageDto.getSubject()); memberEmailDto.setReceiver((String) perun.getAttributesManagerBl().getAttribute(session, perun.getUsersManager().getUserByMember(session, member), "urn:perun:user:attribute-def:def:preferredMail").getValue()); memberEmailDto.setSender(groupSender);
return perun.getUsersManager().getUserExtSources(sess, sess.getPerunPrincipal().getUser());
/** * Creates ExtSource and UserExtSource if necessary for the purpose of joining users identities. * * @param user User to add UES to * @param actor Actor to add * @param extSourceName ExtSource name to add * @param extSourceType ExtSource type to add * @param loa loa in ext source * @return created UserExtSource * @throws PerunException when anything fails */ private UserExtSource createExtSourceAndUserExtSource(User user, String actor, String extSourceName, String extSourceType, int loa) throws PerunException { ExtSource extSource = new ExtSource(extSourceName, extSourceType); try { extSource = perun.getExtSourcesManagerBl().getExtSourceByName(registrarSession, extSourceName); } catch (ExtSourceNotExistsException ex) { extSource = perun.getExtSourcesManager().createExtSource(registrarSession, extSource, null); } UserExtSource ues = new UserExtSource(); ues.setLogin(actor); ues.setLoa(loa); ues.setExtSource(extSource); return perun.getUsersManager().addUserExtSource(registrarSession, user, ues); }
this.membersManager = perun.getMembersManager(); this.groupsManager = perun.getGroupsManager(); this.usersManager = perun.getUsersManager(); this.vosManager = perun.getVosManager();