001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.portlet.CustomUserAttributes;
020 import com.liferay.portal.kernel.portlet.UserAttributes;
021 import com.liferay.portal.kernel.security.RandomUtil;
022
023 import java.util.Map;
024
025
035 public class DefaultCustomUserAttributes implements CustomUserAttributes {
036
037 @Override
038 public Object clone() {
039 return new DefaultCustomUserAttributes();
040 }
041
042 @Override
043 public String getValue(String name, Map<String, String> userInfo) {
044 if (name == null) {
045 return null;
046 }
047
048 if (_log.isDebugEnabled()) {
049 String companyId = userInfo.get(UserAttributes.LIFERAY_COMPANY_ID);
050 String userId = userInfo.get(UserAttributes.LIFERAY_USER_ID);
051
052 _log.debug("Company id " + companyId);
053 _log.debug("User id " + userId);
054 }
055
056 if (name.equals("user.name.random")) {
057 String[] names = new String[] {"Aaa", "Bbb", "Ccc"};
058
059 return names[RandomUtil.nextInt(3)];
060 }
061 else {
062 return null;
063 }
064 }
065
066 private static final Log _log = LogFactoryUtil.getLog(
067 DefaultCustomUserAttributes.class);
068
069 }