use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.
the class UserServiceImpl method getUserAsBean.
@Override
public UserBean getUserAsBean(User user) {
UserBean bean = new UserBean();
bean.setUserId(Integer.toString(user.getId()));
UserRole anonymous = _authoritiesService.getAnonymousRole();
boolean isAnonymous = user.getRoles().contains(anonymous);
bean.setAnonymous(isAnonymous);
UserRole admin = _authoritiesService.getAdministratorRole();
boolean isAdmin = user.getRoles().contains(admin);
bean.setAdmin(isAdmin);
List<UserIndexBean> indices = new ArrayList<UserIndexBean>();
bean.setIndices(indices);
for (UserIndex index : user.getUserIndices()) {
UserIndexKey key = index.getId();
UserIndexBean indexBean = new UserIndexBean();
indexBean.setType(key.getType());
indexBean.setValue(key.getValue());
indices.add(indexBean);
}
_userPropertiesService.getUserAsBean(user, bean);
return bean;
}
use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.
the class IndexedUserAuthenticationProcessorFilter method obtainUsername.
/* during authentication, if you are trying to retrieve the username
and the user isDisabled in the properties, it will return null
Without the username, the user can not log in
*/
@Override
protected String obtainUsername(HttpServletRequest request) {
String username = super.obtainUsername(request);
if (username != null) {
username = username.trim();
if (username.length() > 0) {
username = obtainUserIndexType(request) + "_" + username;
}
}
UserIndex userIndex = _userService.getUserIndexForUsername(username);
UserBean bean = _userService.getUserAsBean(userIndex.getUser());
if (bean == null | bean.isDisabled()) {
return null;
}
return username;
}
use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.
the class ApiKeyAction method searchAPIKey.
public String searchAPIKey() {
// Check if key already exists
UserIndexKey userKey = new UserIndexKey(UserIndexTypes.API_KEY, key);
UserIndex userIndexForId = userService.getUserIndexForId(userKey);
if (userIndexForId == null) {
addActionMessage("Key '" + key + "' does not exist");
} else {
User user = userIndexForId.getUser();
UserBean bean = userService.getUserAsBean(user);
minApiReqInt = bean.getMinApiRequestInterval();
contactName = bean.getContactName();
contactCompany = bean.getContactCompany();
contactEmail = bean.getContactEmail();
contactDetails = bean.getContactDetails();
addActionMessage("Key '" + key + "' found");
}
return SUCCESS;
}
use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.
the class UserManagementServiceImpl method buildUserDetail.
private UserDetail buildUserDetail(User user) {
UserDetail userDetail = new UserDetail();
userDetail.setId(user.getId());
for (UserIndex userIndex : user.getUserIndices()) {
userDetail.setUsername(userIndex.getId().getValue());
}
for (UserRole role : user.getRoles()) {
// There should be only one role
userDetail.setRole(role.getName());
}
UserBean bean = userService.getUserAsBean(user);
userDetail.setDisabled(bean.isDisabled());
return userDetail;
}
use of org.onebusaway.users.client.model.UserBean in project onebusaway-application-modules by camsys.
the class IndexTemplate method buildTemplate.
@Override
public void buildTemplate(ActionContext context) {
ValueStack stack = context.getValueStack();
UserBean user = (UserBean) stack.findValue("currentUser");
if (user.getDefaultLocationName() != null) {
addMessage(Messages.SETTINGS_YOUR_DEFAULT_SEARCH_LOCATION_IS_CURRENTLY);
addText(_locationPronunciation.modify(user.getDefaultLocationName()));
}
addMessage(Messages.INDEX_ACTION_SET_DEFAULT_SEARCH_LOCATION);
addAction("1", "/settings/askForDefaultSearchLocation");
if (user != null) {
if (user.isRememberPreferencesEnabled())
addMessage(Messages.PREFERENCES_DO_NOT_REMEMBER);
else
addMessage(Messages.PREFERENCES_DO_REMEMBER);
addAction("2", "/settings/setRememberPreferences", "enabled", !user.isRememberPreferencesEnabled());
}
addMessage(Messages.HOW_TO_GO_BACK);
addAction("\\*", "/back");
addMessage(Messages.TO_REPEAT);
addAction("[#23456789*]", "/repeat");
}
Aggregations