use of com.liferay.portal.model.User in project liferay-ide by liferay.
the class LiferayPersonService method getEmails.
protected List<ListField> getEmails(User user) throws Exception {
List<ListField> emails = new ArrayList<ListField>();
ListField email = new ListFieldImpl(Field.PRIMARY.toString(), user.getEmailAddress());
emails.add(email);
List<EmailAddress> emailAddresses = EmailAddressLocalServiceUtil.getEmailAddresses(user.getCompanyId(), User.class.getName(), user.getUserId());
for (EmailAddress emailAddress : emailAddresses) {
email = new ListFieldImpl(emailAddress.getType().getName(), emailAddress.getAddress());
emails.add(email);
}
return emails;
}
use of com.liferay.portal.model.User in project liferay-ide by liferay.
the class ShindigFilter method setPermissionChecker.
protected boolean setPermissionChecker(ServletRequest servletRequest) {
String companyIdString = CookieKeys.getCookie((HttpServletRequest) servletRequest, CookieKeys.COMPANY_ID);
if (Validator.isNull(companyIdString)) {
return false;
}
long companyId = GetterUtil.getLong(companyIdString);
String userUUID = StringPool.BLANK;
try {
Company company = CompanyLocalServiceUtil.fetchCompany(companyId);
if (company == null) {
return false;
}
String userUUIDString = CookieKeys.getCookie((HttpServletRequest) servletRequest, CookieKeys.USER_UUID);
if (Validator.isNull(userUUIDString)) {
return false;
}
userUUID = GetterUtil.getString(Encryptor.decrypt(company.getKeyObj(), userUUIDString));
} catch (EncryptorException ee) {
return false;
} catch (Exception e) {
_log.error(e, e);
return false;
}
if (!AuthenticatedUserUUIDStoreUtil.exists(userUUID)) {
return false;
}
String userIdString = userUUID.substring(0, userUUID.indexOf(StringPool.PERIOD));
long userId = GetterUtil.getLong(userIdString);
try {
User user = UserLocalServiceUtil.getUserById(userId);
PrincipalThreadLocal.setName(userIdString);
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
} catch (Exception e) {
_log.error(e, e);
return false;
}
return true;
}
Aggregations