Example usage for com.liferay.portal.kernel.service PasswordPolicyLocalServiceUtil updatePasswordPolicy

List of usage examples for com.liferay.portal.kernel.service PasswordPolicyLocalServiceUtil updatePasswordPolicy

Introduction

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

Prototype

public static com.liferay.portal.kernel.model.PasswordPolicy updatePasswordPolicy(
        com.liferay.portal.kernel.model.PasswordPolicy passwordPolicy) 

Source Link

Document

Updates the password policy in the database or adds it if it does not yet exist.

Usage

From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java

License:Open Source License

protected User addUser(ActionRequest actionRequest, ActionResponse actionResponse, String password)
        throws SystemException, PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Company company = themeDisplay.getCompany();

    String authType = company.getAuthType();

    boolean autoPassword = false;
    String password1 = null;//from   ww  w  . j  a va2 s. c o  m
    String password2 = null;
    boolean autoScreenName = !authType.equals(CompanyConstants.AUTH_TYPE_SN);
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    long facebookId = 0;
    String openId = StringPool.BLANK;
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String middleName = StringPool.BLANK;
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    int prefixId = 0;
    int suffixId = 0;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    int birthdayMonth = 1;
    int birthdayDay = 1;
    int birthdayYear = 1970;
    String jobTitle = StringPool.BLANK;
    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;
    boolean sendEmail = true;

    ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);

    password1 = password;
    password2 = password;

    User user = UserServiceUtil.addUser(company.getCompanyId(), autoPassword, password1, password2,
            autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName,
            middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
            groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    long userId = user.getUserId();

    user = UserLocalServiceUtil.updatePasswordReset(userId, false);

    PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil.getPasswordPolicyByUserId(userId);
    passwordPolicy.setChangeRequired(false);
    PasswordPolicyLocalServiceUtil.updatePasswordPolicy(passwordPolicy);

    if (_USERS_REMINDER_QUERIES_ENABLED) {
        user = UserLocalServiceUtil.updateReminderQuery(userId, StringPool.DASH, UUID.randomUUID().toString());
    }

    user = UserLocalServiceUtil.updateAgreedToTermsOfUse(userId, true);

    return user;
}