/**
* Copyright (C) 2011 JTalks.org Team
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.jtalks.jcommune.web.dto;
import org.jtalks.common.model.entity.User;
import org.jtalks.jcommune.model.entity.JCUser;
import org.jtalks.jcommune.model.validation.annotations.Matches;
import org.jtalks.jcommune.web.validation.annotations.*;
import javax.validation.constraints.Size;
/**
* This dto used for transferring data in edit {@link org.jtalks.jcommune.model.entity.JCUser} operation.
* To get more info see
* {@link org.jtalks.jcommune.web.controller.UserProfileController#saveEditedSecurity(EditUserProfileDto,
* org.springframework.validation.BindingResult, javax.servlet.http.HttpServletResponse)}.
*
* @author Osadchuck Eugeny
* @author Andrey Pogorelov
*/
@Matches(field = "newUserPassword", verifyField = "newUserPasswordConfirm", message = "{password_not_matches}")
@ChangedPassword
public class UserSecurityDto {
private long userId;
private String currentUserPassword;
@Size(min = User.PASSWORD_MIN_LENGTH, max = User.PASSWORD_MAX_LENGTH,
message = "{length.constraint}")
private String newUserPassword;
private String newUserPasswordConfirm;
/**
* Form info population only, please do not call it explicitly
*/
public UserSecurityDto() {
}
/**
* Constructor which fills dto fields from user.
*
* @param user copying source
*/
public UserSecurityDto(JCUser user) {
this.userId = user.getId();
}
/**
* Get the primary id of the user.
*
* @return the id
*/
public long getUserId() {
return userId;
}
/**
* Set the primary id of the user.
*
* @param userId the id
*/
public void setUserId(long userId) {
this.userId = userId;
}
/**
* @return - current user password
*/
public String getCurrentUserPassword() {
return currentUserPassword;
}
/**
* Set current user password
*
* @param currentUserPassword - current user password
*/
public void setCurrentUserPassword(String currentUserPassword) {
this.currentUserPassword = currentUserPassword;
}
/**
* @return - new user password
*/
public String getNewUserPassword() {
return newUserPassword;
}
/**
* Set new user password
*
* @param newUserPassword - new user password
*/
public void setNewUserPassword(String newUserPassword) {
this.newUserPassword = newUserPassword;
}
/**
* @return - new user password confirmation
*/
public String getNewUserPasswordConfirm() {
return newUserPasswordConfirm;
}
/**
* Set new user password confirmation.
*
* @param newUserPasswordConfirm - new user password confirmation
*/
public void setNewUserPasswordConfirm(String newUserPasswordConfirm) {
this.newUserPasswordConfirm = newUserPasswordConfirm;
}
}