use of com.liferay.portal.model.Company in project liferay-ide by liferay.
the class WebServerServlet method _getUser.
private static User _getUser(HttpServletRequest request) throws Exception {
HttpSession session = request.getSession();
if (PortalSessionThreadLocal.getHttpSession() == null) {
PortalSessionThreadLocal.setHttpSession(session);
}
User user = PortalUtil.getUser(request);
if (user != null) {
return user;
}
String userIdString = (String) session.getAttribute("j_username");
String password = (String) session.getAttribute("j_password");
if ((userIdString != null) && (password != null)) {
long userId = GetterUtil.getLong(userIdString);
user = UserLocalServiceUtil.getUser(userId);
} else {
long companyId = PortalUtil.getCompanyId(request);
Company company = CompanyLocalServiceUtil.getCompany(companyId);
user = company.getDefaultUser();
}
return user;
}
use of com.liferay.portal.model.Company in project liferay-ide by liferay.
the class UserLocalServiceImpl method encryptUserId.
/**
* Encrypts the primary key of the user. Used when encrypting the user's
* credentials for storage in an automatic login cookie.
*
* @param name the primary key of the user
* @return the user's encrypted primary key
* @throws PortalException if a user with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public String encryptUserId(String name) throws PortalException, SystemException {
long userId = GetterUtil.getLong(name);
User user = userPersistence.findByPrimaryKey(userId);
Company company = companyPersistence.findByPrimaryKey(user.getCompanyId());
try {
return Encryptor.encrypt(company.getKeyObj(), name);
} catch (EncryptorException ee) {
throw new SystemException(ee);
}
}
use of com.liferay.portal.model.Company in project liferay-ide by liferay.
the class UserLocalServiceImpl method updateAsset.
/**
* Updates the user's asset with the new asset categories and tag names,
* removing and adding asset categories and tag names as necessary.
*
* @param userId the primary key of the user
* @param user ID the primary key of the user
* @param assetCategoryIds the primary key's of the new asset categories
* @param assetTagNames the new asset tag names
* @throws PortalException if a user with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public void updateAsset(long userId, User user, long[] assetCategoryIds, String[] assetTagNames) throws PortalException, SystemException {
User owner = userPersistence.findByPrimaryKey(userId);
Company company = companyPersistence.findByPrimaryKey(owner.getCompanyId());
Group companyGroup = company.getGroup();
assetEntryLocalService.updateEntry(userId, companyGroup.getGroupId(), user.getCreateDate(), user.getModifiedDate(), User.class.getName(), user.getUserId(), user.getUuid(), 0, assetCategoryIds, assetTagNames, false, null, null, null, null, user.getFullName(), null, null, null, null, 0, 0, null, false);
}
use of com.liferay.portal.model.Company 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;
}
use of com.liferay.portal.model.Company in project liferay-ide by liferay.
the class AddGoogleDocsFileEntryTypeAction method doRun.
protected void doRun(long companyId) throws PortalException, SystemException {
Company company = CompanyLocalServiceUtil.getCompanyById(companyId);
if (!hasGoogleDocsFileEntryType(company.getGroupId())) {
long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);
addGoogleDocsFileEntryType(defaultUserId, company.getGroupId());
}
}
Aggregations