📄 cmsuser.java
字号:
*/
public String getCountry() {
return (String)getAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_COUNTRY);
}
/**
* Returns <code>true</code> if this user is disabled.<p>
*
* @return <code>true</code> if this user is disabled
*
* @deprecated use {@link CmsPrincipal#isEnabled()} instead
*/
public boolean getDisabled() {
return !isEnabled();
}
/**
* Returns the email address of this user.<p>
*
* @return the email address of this user
*/
public String getEmail() {
return m_email;
}
/**
* Returns the firstname of this user.<p>
*
* @return the firstname of this user
*/
public String getFirstname() {
return m_firstname;
}
/**
* Returns the "full" name of the this user in the format <code>"{firstname} {lastname} ({username})"</code>.<p>
*
* @return the "full" name this user
*/
public String getFullName() {
StringBuffer buf = new StringBuffer();
String first = getFirstname();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(first)) {
buf.append(first);
buf.append(" ");
}
String last = getLastname();
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(last)) {
buf.append(last);
buf.append(" ");
}
buf.append("(");
buf.append(getName());
buf.append(")");
return buf.toString();
}
/**
* Returns the time of the last login of this user.<p>
*
* @return the time of the last login of this user
*/
public long getLastlogin() {
return m_lastlogin;
}
/**
* Returns the lastname of this user.<p>
*
* @return the lastname of this user
*/
public String getLastname() {
return m_lastname;
}
/**
* Returns the encrypted user password.<p>
*
* @return the encrypted user password
*/
public String getPassword() {
return m_password;
}
/**
* Returns the type of this user.<p>
*
* Possible options are
* <code>{@link #USER_TYPE_SYSTEMUSER}</code> for a "system user",
* or <code>{@link #USER_TYPE_WEBUSER}</code> for a "web user".<p>
*
* @return the type of this user
*/
public int getType() {
return m_type;
}
/**
* Returns the zip code information of this user.<p>
*
* This informaion is stored in the "additional information" storage map
* using the key <code>{@link CmsUserSettings#ADDITIONAL_INFO_ZIPCODE}</code>.<p>
*
* @return the zip code information of this user
*/
public String getZipcode() {
return (String)getAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_ZIPCODE);
}
/**
* @see org.opencms.security.I_CmsPrincipal#isGroup()
*/
public boolean isGroup() {
return false;
}
/**
* Returns <code>true</code> if this user is the default guest user.<p>
*
* @return true if this user is the default guest user
*/
public boolean isGuestUser() {
return OpenCms.getDefaultUsers().getUserGuest().equals(getName());
}
/**
* Returns <code>true</code> if this user is a "system user".<p>
*
* @return true if this user is a "system user"
*/
public boolean isSystemUser() {
return isSystemUser(m_type);
}
/**
* Returns <code>true</code> if this user was touched.<p>
*
* @return boolean true if this user was touched
*/
public boolean isTouched() {
return m_isTouched;
}
/**
* @see org.opencms.security.I_CmsPrincipal#isUser()
*/
public boolean isUser() {
return true;
}
/**
* Returns <code>true</code> if this user is a "web user".<p>
*
* @return true if this user is a "web user"
*/
public boolean isWebUser() {
return isWebUser(m_type);
}
/**
* Sets this users complete "additional information" storage map to the given value.<p>
*
* @param additionalInfo the complete "additional information" map to set
*
* @see #getAdditionalInfo()
*/
public void setAdditionalInfo(Map additionalInfo) {
m_additionalInfo = additionalInfo;
}
/**
* Stores a value in this users "additional information" storage map with the gicen access key.<p>
*
* @param key the key to store the value under
* @param value the value to store in the users "additional information" storage map
*
* @see #getAdditionalInfo()
*/
public void setAdditionalInfo(String key, Object value) {
m_additionalInfo.put(key, value);
}
/**
* Sets the address line of this user.<p>
*
* @param address the address line to set
*/
public void setAddress(String address) {
m_address = address;
}
/**
* Sets the city information of this user.<p>
*
* @param city the city information to set
*/
public void setCity(String city) {
setAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_CITY, city);
}
/**
* Sets the country information of this user.<p>
*
* @param country the city information to set
*/
public void setCountry(String country) {
setAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_COUNTRY, country);
}
/**
* Disables this user.<p>
*
* @deprecated use {@link CmsPrincipal#setEnabled(boolean)} instead
*/
public void setDisabled() {
setEnabled(false);
}
/**
* Sets the email address of this user.<p>
*
* @param email the email address to set
*/
public void setEmail(String email) {
checkEmail(email);
m_email = email;
}
/**
* Enables this user.<p>
*
* @deprecated use {@link CmsPrincipal#setEnabled(boolean)} instead
*/
public void setEnabled() {
setEnabled(true);
}
/**
* Sets the first name of this user.<p>
*
* @param firstname the name to set
*/
public void setFirstname(String firstname) {
if (CmsStringUtil.isEmptyOrWhitespaceOnly(firstname)) {
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_FIRSTNAME_EMPTY_0));
}
m_firstname = firstname;
}
/**
* Sets the last login timestamp of this user.<p>
*
* @param value the last login timestamp to set
*/
public void setLastlogin(long value) {
m_isTouched = true;
m_lastlogin = value;
}
/**
* Sets the last name of this user.<p>
*
* @param lastname the name to set
*/
public void setLastname(String lastname) {
if (CmsStringUtil.isEmptyOrWhitespaceOnly(lastname)) {
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_LASTNAME_EMPTY_0));
}
m_lastname = lastname;
}
/**
* Sets the password of this user.<p>
*
* @param value the password to set
*/
public void setPassword(String value) {
try {
OpenCms.getPasswordHandler().validatePassword(value);
} catch (CmsSecurityException e) {
throw new CmsIllegalArgumentException(e.getMessageContainer());
}
m_password = value;
}
/**
* Sets the zip code information of this user.<p>
*
* @param zipcode the zip code information to set
*/
public void setZipcode(String zipcode) {
checkZipCode(zipcode);
zipcode = zipcode.toUpperCase();
setAdditionalInfo(CmsUserSettings.ADDITIONAL_INFO_ZIPCODE, zipcode);
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
StringBuffer result = new StringBuffer();
result.append("[User]");
result.append(" name:");
result.append(m_name);
result.append(" id:");
result.append(m_id);
result.append(" flags:");
result.append(getFlags());
result.append(" type:");
result.append(getType());
result.append(" description:");
result.append(m_description);
return result.toString();
}
/**
* Sets the "touched" status of this user to <code>true</code>.<p>
*/
public void touch() {
m_isTouched = true;
}
/**
* Sets the type of this user.<p>
*
* Possible options are
* <code>{@link #USER_TYPE_SYSTEMUSER}</code> for a "system user",
* or <code>{@link #USER_TYPE_WEBUSER}</code> for a "web user".<p>
*
* @param value the type to set
*/
protected void setType(int value) {
m_type = value;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -