Search in sources :

Example 6 with User

use of com.liferay.portal.kernel.model.User in project liferay-blade-samples by liferay.

the class UsersRestService method getUsers.

@GET
@Path("/list")
@Produces("text/plain")
public String getUsers() {
    StringBuilder result = new StringBuilder();
    for (User user : _userLocalService.getUsers(-1, -1)) {
        result.append(user.getFullName());
        result.append(",\n");
    }
    return result.toString();
}
Also used : User(com.liferay.portal.kernel.model.User) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 7 with User

use of com.liferay.portal.kernel.model.User in project liferay-blade-samples by liferay.

the class LogAuthFailure method onFailureByEmailAddress.

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
    try {
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
        int failures = user.getFailedLoginAttempts();
        _log.log(LogService.LOG_INFO, "onFailureByEmailAddress: " + emailAddress + " has failed to login " + failures + " times");
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 8 with User

use of com.liferay.portal.kernel.model.User in project liferay-blade-samples by liferay.

the class LogMaxFailures method onFailureByEmailAddress.

@Override
public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
    try {
        User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
        boolean lockout = user.isLockout();
        _log.log(LogService.LOG_INFO, "onFailureByEmailAddress: " + emailAddress + " is " + (lockout ? "" : "not") + " locked out.");
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 9 with User

use of com.liferay.portal.kernel.model.User in project liferay-blade-samples by liferay.

the class LogMaxFailures method onFailureByUserId.

@Override
public void onFailureByUserId(long companyId, long userId, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException {
    try {
        User user = UserLocalServiceUtil.getUserById(userId);
        boolean lockout = user.isLockout();
        _log.log(LogService.LOG_INFO, "onFailureById: userId " + userId + " is " + (lockout ? "" : "not") + " locked out.");
    } catch (PortalException pe) {
        _log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
    }
}
Also used : User(com.liferay.portal.kernel.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException)

Example 10 with User

use of com.liferay.portal.kernel.model.User in project liferay-blade-samples by liferay.

the class BladeAutoLogin method doLogin.

@Override
protected String[] doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String[] credentials = null;
    long companyId = PortalUtil.getCompanyId(request);
    User autoLoginUser = null;
    try {
        autoLoginUser = _userLocalService.getUserByEmailAddress(companyId, "auto.login@liferay.com");
    } catch (Exception e) {
    }
    if (autoLoginUser != null) {
        credentials = new String[3];
        credentials[0] = Long.toString(autoLoginUser.getUserId());
        credentials[1] = autoLoginUser.getPassword();
        credentials[2] = Boolean.toString(true);
    }
    _log.log(LogService.LOG_INFO, "Logged in as" + autoLoginUser.getFullName() + "by Blade Auto Login");
    return credentials;
}
Also used : User(com.liferay.portal.kernel.model.User)

Aggregations

User (com.liferay.portal.kernel.model.User)13 PortalException (com.liferay.portal.kernel.exception.PortalException)9 JSONArray (com.liferay.portal.kernel.json.JSONArray)3 JSONException (com.liferay.portal.kernel.json.JSONException)3 JSONObject (com.liferay.portal.kernel.json.JSONObject)3 Role (com.liferay.portal.kernel.model.Role)3 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)3 BufferedReader (java.io.BufferedReader)3 File (java.io.File)3 FileReader (java.io.FileReader)3 IOException (java.io.IOException)3 ThemeDisplay (com.liferay.portal.kernel.theme.ThemeDisplay)2 Organization (com.liferay.portal.kernel.model.Organization)1 UserGroup (com.liferay.portal.kernel.model.UserGroup)1 LinkedList (java.util.LinkedList)1 ApplicationPath (javax.ws.rs.ApplicationPath)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1