Example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getUserByEmailAddress

List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil getUserByEmailAddress

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service UserLocalServiceUtil getUserByEmailAddress.

Prototype

public static com.liferay.portal.kernel.model.User getUserByEmailAddress(long companyId, String emailAddress)
        throws com.liferay.portal.kernel.exception.PortalException 

Source Link

Document

Returns the user with the email address.

Usage

From source file:blade.authfailure.LogAuthFailure.java

License:Apache License

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap,
        Map<String, String[]> parameterMap) throws AuthException {

    try {/*from   w ww.j a va  2 s.c  o m*/
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
        int failures = user.getFailedLoginAttempts();

        _log.info("onFailureByEmailAddress: " + emailAddress + " has failed to login " + failures + " times");
    } catch (PortalException e) {
    }
}

From source file:blade.authfailure.LogMaxFailures.java

License:Apache License

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap,
        Map<String, String[]> parameterMap) throws AuthException {

    try {//  ww w .j  a  v a 2  s  .  c  o m
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
        boolean lockout = user.isLockout();

        _log.info(
                "onFailureByEmailAddress: " + emailAddress + " is " + (lockout ? "" : "not") + " locked out.");
    } catch (PortalException e) {
    }
}

From source file:com.liferay.blade.samples.authfailure.LogAuthFailure.java

License:Apache License

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap,
        Map<String, String[]> parameterMap) throws AuthException {

    try {/*  www  .ja  va2  s  .c  o m*/
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);

        int failures = user.getFailedLoginAttempts();

        if (_log.isInfoEnabled()) {
            _log.info(
                    "onFailureByEmailAddress: " + emailAddress + " has failed to login " + failures + " times");
        }
    } catch (PortalException pe) {
    }
}

From source file:com.liferay.blade.samples.authfailure.LogMaxFailures.java

License:Apache License

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap,
        Map<String, String[]> parameterMap) throws AuthException {

    try {/*  www.ja v a 2s.  c o  m*/
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);

        boolean lockout = user.isLockout();

        if (_log.isInfoEnabled()) {
            _log.info("onFailureByEmailAddress: " + emailAddress + " is " + (lockout ? "" : "not")
                    + " locked out.");
        }
    } catch (PortalException pe) {
    }
}

From source file:com.liferay.document.library.repository.cmis.internal.model.CMISModel.java

License:Open Source License

protected User getUser(String createdBy) {
    User user = null;//ww  w .j  a v  a2  s.  co m

    try {
        Company company = CompanyLocalServiceUtil.getCompany(getCompanyId());

        String authType = company.getAuthType();

        if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
            user = UserLocalServiceUtil.getUser(GetterUtil.getLong(createdBy));
        } else if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
            user = UserLocalServiceUtil.getUserByEmailAddress(getCompanyId(), createdBy);
        } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
            user = UserLocalServiceUtil.getUserByScreenName(getCompanyId(), createdBy);
        }
    } catch (Exception e) {
    }

    if (user == null) {
        try {
            user = UserLocalServiceUtil.getDefaultUser(getCompanyId());
        } catch (Exception e) {
        }
    }

    return user;
}

From source file:com.liferay.document.library.repository.external.model.ExtRepositoryModelAdapter.java

License:Open Source License

protected User getUser(String extRepositoryUserName) {
    User user = null;/*  ww w  .j  ava  2 s . c o  m*/

    if (Validator.isNotNull(extRepositoryUserName)) {
        String liferayLogin = _extRepositoryAdapter.getLiferayLogin(extRepositoryUserName);

        try {
            String authType = _extRepositoryAdapter.getAuthType();

            if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
                user = UserLocalServiceUtil.getUser(GetterUtil.getLong(liferayLogin));
            } else if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
                user = UserLocalServiceUtil.getUserByEmailAddress(getCompanyId(), liferayLogin);
            } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
                user = UserLocalServiceUtil.getUserByScreenName(getCompanyId(), liferayLogin);
            }
        } catch (Exception e) {
        }
    }

    if (user == null) {
        try {
            user = UserLocalServiceUtil.getDefaultUser(getCompanyId());
        } catch (Exception e) {
        }
    }

    return user;
}

From source file:com.liferay.exportimport.test.util.model.util.DummyFolderTestUtil.java

License:Open Source License

public static DummyFolder createDummyFolder(long groupId) throws Exception {
    DummyFolder dummyFolder = new DummyFolder();

    dummyFolder.setCompanyId(TestPropsValues.getCompanyId());
    dummyFolder.setGroupId(groupId);/*w w  w  . j ava  2  s.  com*/
    dummyFolder.setLastPublishDate(null);

    User user = UserLocalServiceUtil.getUserByEmailAddress(TestPropsValues.getCompanyId(), "test@liferay.com");

    dummyFolder.setUserId(user.getUserId());
    dummyFolder.setUserName(user.getScreenName());
    dummyFolder.setUserUuid(user.getUserUuid());

    return dummyFolder;
}

From source file:it.sysdata.base.service.impl.UserHelperLocalServiceImpl.java

License:Open Source License

public User updateUserInfo(String emailAddress, String password, String firstName, String lastName,
        ServiceContext serviceContext) throws PortalException, SystemException {

    User user = UserLocalServiceUtil.getUserByEmailAddress(serviceContext.getCompanyId(), emailAddress);

    long userId = user.getUserId();
    String oldPassword = password;
    String newPassword1 = password;
    String newPassword2 = password;
    boolean passwordReset = false;

    String reminderQueryQuestion = null;
    String reminderQueryAnswer = null;
    String screenName = user.getScreenName();

    long facebookId = user.getFacebookId();
    String openId = user.getOpenId();
    String languageId = user.getLanguageId();
    String timeZoneId = user.getTimeZoneId();
    String greeting = user.getGreeting();
    String comments = null;/*from   w w w.  j a  v  a 2s .c  om*/
    String middleName = user.getMiddleName();

    int prefixId = 0;
    int suffixId = 0;
    boolean male = user.getMale();
    int birthdayMonth = 0;
    int birthdayDay = 0;
    int birthdayYear = 0;

    String smsSn = null;
    String aimSn = null;
    String facebookSn = null;
    String icqSn = null;
    String jabberSn = null;
    String msnSn = null;
    String mySpaceSn = null;
    String skypeSn = null;
    String twitterSn = null;
    String ymSn = null;
    String jobTitle = user.getJobTitle();

    long[] groupIds = user.getGroupIds();
    long[] organizationIds = user.getOrganizationIds();
    long[] roleIds = user.getRoleIds();
    List<UserGroupRole> userGroupRoles = null;
    long[] userGroupIds = user.getUserGroupIds();

    return UserLocalServiceUtil.updateUser(userId, oldPassword, newPassword1, newPassword2, passwordReset,
            reminderQueryQuestion, reminderQueryAnswer, screenName, emailAddress, facebookId, openId, true,
            null, languageId, timeZoneId, greeting, comments, firstName, middleName, lastName, prefixId,
            suffixId, male, birthdayMonth, birthdayDay, birthdayYear, smsSn, facebookSn, jabberSn, skypeSn,
            twitterSn, jobTitle, groupIds, organizationIds, roleIds, userGroupRoles, userGroupIds,
            serviceContext);
}

From source file:it.sysdata.base.service.impl.UserHelper_1_1ServiceImpl.java

License:Open Source License

@Override
@AccessControlled(guestAccessEnabled = true)
@JSONWebService(value = "send-new-password", method = "POST")
public User sendNewPassword(String emailAddress) throws PortalException, SystemException {

    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    String adminEmailFromName = PrefsPropsUtil.getString(serviceContext.getCompanyId(),
            PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String adminEmailFromAddress = PrefsPropsUtil.getString(serviceContext.getCompanyId(),
            PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

    String adminEmailPasswordResetSubject = PrefsPropsUtil.getContent(serviceContext.getCompanyId(),
            PropsKeys.ADMIN_EMAIL_PASSWORD_RESET_SUBJECT);
    String adminEmailPasswordResetBody = PrefsPropsUtil.getContent(serviceContext.getCompanyId(),
            PropsKeys.ADMIN_EMAIL_PASSWORD_RESET_BODY);

    UserLocalServiceUtil.sendPassword(serviceContext.getCompanyId(), emailAddress, adminEmailFromName,
            adminEmailFromAddress, adminEmailPasswordResetSubject, adminEmailPasswordResetBody, serviceContext);

    User user = UserLocalServiceUtil.getUserByEmailAddress(serviceContext.getCompanyId(), emailAddress);

    return user;/*from   w  w  w  . j  a va2s.com*/
}

From source file:it.sysdata.base.service.impl.UserHelper_1_1ServiceImpl.java

License:Open Source License

@Override
public User updateUserInfo(String emailAddress, String password, String firstName, String lastName)
        throws PortalException, SystemException {

    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    User realUser = UserLocalServiceUtil.getUserByEmailAddress(serviceContext.getCompanyId(), emailAddress);

    if (realUser.getUserId() != getUserId()) {

        throw new SecurityException();
    }/*from  www .  j a v a  2 s  .  c om*/

    return userHelperLocalService.updateUserInfo(emailAddress, password, firstName, lastName, serviceContext);
}