public int getUserId() { if (this.user == null) { return -1; } return this.user.getId(); }
@Override public String toString() { return getClass().getSimpleName() + ":[id='" + getId() + "', titleBefore='" + titleBefore + "', firstName='" + firstName + "', lastName='" + lastName + "', middleName='" + middleName + "', titleAfter='" + titleAfter + "', serviceAccount='" + serviceUser + "', sponsoredAccount='" + sponsoredUser + "']"; }
/** * VOOTPerson represents person encoded according to the OpenSocial Social Data Specification using in VOOT protocol. * * @param user user * @param emails email adressrs of user */ public VOOTPerson(User user, Email[] emails){ this.id = Integer.toString(user.getId()); this.displayName = user.getDisplayName(); this.emails = emails; }
@Override public List<Application> getApplicationsForUser(User user) { try { // sort by ID which respect latest applications return jdbc.query(APP_SELECT + " where user_id=? order by a.id desc", APP_MAPPER, user.getId()); } catch (EmptyResultDataAccessException ex) { return new ArrayList<Application>(); } }
public UserContactsRemovedForFacility(User user, ContactGroup contactGroup) { this.user = user; this.contactGroup = contactGroup; this.message = formatMessage("User (%d) successfully removed from contact groups %s.", user.getId(), contactGroup); }
public void updateUser(User user, ModificationItem[] modificationItems) { this.updateUserWithUserId(String.valueOf(user.getId()), modificationItems); }
public void deleteUser(User user) throws InternalErrorException { try { ldapTemplate.unbind(getUserDN(String.valueOf(user.getId()))); log.debug("Entry deleted from LDAP: User {}.", user); } catch (NameNotFoundException e) { throw new InternalErrorException(e); } }
public boolean userPasswordExists(User user) { Object o = ldapTemplate.lookup(getUserDN(String.valueOf(user.getId())), new UserAttributesContextMapper()); Attributes attrs = null; if(o != null) attrs = (Attributes) o; if(attrs != null) { Attribute a = attrs.get(EventProcessorImpl.ldapAttrUserPassword); if(a != null) return true; } return false; }
public boolean userExist(User user) { Object o = null; try { o = ldapTemplate.lookup(getUserDN(String.valueOf(user.getId())), new UserPerunUserIdContextMapper()); } catch (NameNotFoundException ex) { return false; } return true; }
public Attributes getAllUsersAttributes(User user) { Object o = ldapTemplate.lookup(getUserDN(String.valueOf(user.getId())), new UserAttributesContextMapper()); Attributes attrs = null; if(o != null) attrs = (Attributes) o; return attrs; }
public static List<Attribute> getLogins(RpcCaller rpcCaller, User user) throws PrivilegeException, InternalErrorException, UserNotExistsException { Map<String, Object> params = new HashMap<String, Object>(); params.put("user", user.getId()); try { return rpcCaller.call("attributesManager", "getLogins", params).readList(Attribute.class); } catch (UserNotExistsException e) { throw e; } catch (PrivilegeException e) { throw e; } catch (InternalErrorException e) { throw e; } catch (PerunException e) { throw new ConsistencyErrorException(e); } }
public static List<Resource> getAllowedResources(RpcCaller rpcCaller, User user) throws InternalErrorException, UserNotExistsException, PrivilegeException { Map<String, Object> params = new HashMap<String, Object>(); params.put("user", user.getId()); try { return rpcCaller.call("usersManager", "getAllowedResources", params).readList(Resource.class); } catch (UserNotExistsException e) { throw e; } catch (PrivilegeException e) { throw e; } catch (InternalErrorException e) { throw e; } catch (PerunException e) { throw new ConsistencyErrorException(e); } } }
public static Member getMemberByUser(RpcCaller rpcCaller, Vo vo, User user) throws PrivilegeException, InternalErrorException, MemberNotExistsException, UserNotExistsException, VoNotExistsException { Map<String, Object> params = new HashMap<String, Object>(); params.put("vo", vo.getId()); params.put("user", user.getId()); try { return rpcCaller.call("membersManager", "getMemberByUser", params).read(Member.class); } catch (VoNotExistsException e) { throw e; } catch (UserNotExistsException e) { throw e; } catch (MemberNotExistsException e) { throw e; } catch (PrivilegeException e) { throw e; } catch (InternalErrorException e) { throw e; } catch (PerunException e) { throw new ConsistencyErrorException(e); } }
public boolean userAttributeExist(User user, String ldapAttributeName) throws InternalErrorException { if(ldapAttributeName == null) throw new InternalErrorException("ldapAttributeName can't be null."); Object o = null; try { setLdapAttributeName(ldapAttributeName); o = ldapTemplate.lookup(getUserDN(String.valueOf(user.getId())), new AttributeContextMapper()); } catch (NameNotFoundException ex) { return false; } if(o == null) return false; return true; }
private UserSCIM mapPerunUserToScimUser(User perunUser) { Long userId = new Long(perunUser.getId()); UserSCIM result = new UserSCIM(); EmailSCIM email = getEmail(perunUser); if (email != null) { List emails = new ArrayList<>(); emails.add(email); result.setEmails(emails); } result.setId(userId); result.setUserName(userId.toString()); result.setName(perunUser.getDisplayName()); result.setDisplayName(perunUser.getDisplayName()); List<String> schemas = new ArrayList<>(); schemas.add(URN_USER); result.setSchemas(schemas); return result; }
private EmailSCIM getEmail(User perunUser) { Attribute preferredEmailAttribute = new Attribute(); EmailSCIM email = new EmailSCIM(); try { preferredEmailAttribute = perunBl.getAttributesManagerBl().getAttribute(session, perunUser, AttributesManager.NS_USER_ATTR_DEF + ":preferredMail"); if (preferredEmailAttribute.getValue() != null) { email.setValue(preferredEmailAttribute.getValue().toString()); email.setPrimary(true); email.setType("preferred email"); return email; } } catch (InternalErrorException | WrongAttributeAssignmentException ex) { log.error("Internal exception occured while getting preferred email of user " + perunUser.getId(), ex); } catch (AttributeNotExistsException ex) { log.error("Attribute preferredMail doesn't exist for user " + perunUser.getId(), ex); } return null; } }
@Override public void deleteAuthorship(PerunSession sess, Authorship authorship) throws InternalErrorException, CabinetException, PrivilegeException { if (!AuthzResolver.isAuthorized(sess, Role.PERUNADMIN) && !authorship.getCreatedBy().equalsIgnoreCase(sess.getPerunPrincipal().getActor()) && !authorship.getUserId().equals(sess.getPerunPrincipal().getUser().getId()) && authorship.getCreatedByUid() != sess.getPerunPrincipal().getUserId()) { throw new PrivilegeException("You are not allowed to delete authorships you didn't created or which doesn't concern you."); } getAuthorshipManagerBl().deleteAuthorship(sess, authorship); }
public void updateApplicationUser(PerunSession sess, Application app) throws InternalErrorException { jdbc.update("update application set user_id=?, modified_at=" + Compatibility.getSysdate() + ", modified_by=? where id=?", (app.getUser() != null) ? app.getUser().getId() : null, sess.getPerunPrincipal().getActor(), app.getId()); }
@Override public String serializeToString() { return this.getClass().getSimpleName() + ":[" + "id=<" + getId() + ">" + ", titleBefore=<" + (getTitleBefore() == null ? "\\0" : BeansUtils.createEscaping(getTitleBefore())) + ">" + ", firstName=<" + (getFirstName() == null ? "\\0" : BeansUtils.createEscaping(getFirstName())) + ">" + ", lastName=<" + (getLastName() == null ? "\\0" : BeansUtils.createEscaping(getLastName())) + ">" + ", middleName=<" + (getMiddleName() == null ? "\\0" : BeansUtils.createEscaping(getMiddleName())) + ">" + ", titleAfter=<" + (getTitleAfter() == null ? "\\0" : BeansUtils.createEscaping(getTitleAfter())) + ">" + ", serviceAccount=<" + isServiceUser() + ">" + ", sponsoredAccount=<" + isSponsoredUser() + ">" + ']'; }
public RichUser(User user, List<UserExtSource> userExtSources) { super(user.getId(), user.getFirstName(), user.getLastName(), user.getMiddleName(), user.getTitleBefore(), user.getTitleAfter(), user.getCreatedAt(), user.getCreatedBy(), user.getModifiedAt(), user.getModifiedBy(), user.isServiceUser(), user.isSponsoredUser(), user.getCreatedByUid(), user.getModifiedByUid()); this.userExtSources = userExtSources; this.userAttributes = null; }