use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.
the class FilterFavoriteServiceIT method createFavoriteObject.
private static OnmsFilterFavorite createFavoriteObject(String user, String filterName, String filterCriteria, Page page) {
OnmsFilterFavorite favorite = new OnmsFilterFavorite();
favorite.setName(filterName);
favorite.setFilter(filterCriteria);
favorite.setPage(page);
favorite.setUsername(user);
return favorite;
}
use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.
the class FilterFavoriteServiceIT method verifyXSSPreventionOnRead.
// Due to NMS-9670 there may already be malicious data in the table, verify that we convert that correctly as well
@Test
public void verifyXSSPreventionOnRead() throws FilterFavoriteService.FilterFavoriteException {
for (Page page : Page.values()) {
final OnmsFilterFavorite filterToCreate = createFavoriteObject("ulf", "XSS Read Test " + page.name(), "filter=severity%3D6<script>alert(123);</script>", page);
int filterId = service.getFilterFavoriteDao().save(filterToCreate);
final OnmsFilterFavorite filterRead = service.getFavorite(filterId, "ulf");
Assert.assertEquals("filter=severity=6<script>alert(123);</script>", filterRead.getFilter());
}
}
use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.
the class AlarmFilterController method createFavorite.
public ModelAndView createFavorite(HttpServletRequest request, HttpServletResponse response) throws Exception {
String error = null;
try {
OnmsFilterFavorite favorite = favoriteService.createFavorite(request.getRemoteUser(), request.getParameter("favoriteName"), FilterUtil.toFilterURL(request.getParameterValues("filter")), OnmsFilterFavorite.Page.ALARM);
if (favorite != null) {
// success
ModelAndView successView = list(request, favorite);
// AlertTag.addAlertToRequest(successView, "Favorite was created successfully", AlertType.SUCCESS);
return successView;
}
error = "An error occured while creating the favorite";
} catch (FilterFavoriteService.FilterFavoriteException ex) {
error = ex.getMessage();
}
ModelAndView errorView = list(request, (OnmsFilterFavorite) null);
AlertTag.addAlertToRequest(errorView, error, AlertType.ERROR);
return errorView;
}
use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.
the class EventController method createFavorite.
public ModelAndView createFavorite(HttpServletRequest request, HttpServletResponse response) throws Exception {
String error = null;
try {
OnmsFilterFavorite favorite = favoriteService.createFavorite(request.getRemoteUser(), request.getParameter("favoriteName"), FilterUtil.toFilterURL(request.getParameterValues("filter")), OnmsFilterFavorite.Page.EVENT);
if (favorite != null) {
// success
ModelAndView successView = list(request, favorite);
// AlertTag.addAlertToRequest(successView, "Favorite was created successfully", AlertType.SUCCESS);
return successView;
}
error = "An error occured while creating the favorite";
} catch (FilterFavoriteService.FilterFavoriteException ex) {
error = ex.getMessage();
}
ModelAndView errorView = list(request, (OnmsFilterFavorite) null);
AlertTag.addAlertToRequest(errorView, error, AlertType.ERROR);
return errorView;
}
use of org.opennms.netmgt.model.OnmsFilterFavorite in project opennms by OpenNMS.
the class FilterFavoriteService method createFavorite.
public OnmsFilterFavorite createFavorite(String userName, String favoriteName, String filterString, OnmsFilterFavorite.Page page) throws FilterFavoriteException {
// Validate input
validate(userName, favoriteName, filterString, page);
// Create filter
OnmsFilterFavorite filter = new OnmsFilterFavorite();
filter.setUsername(userName);
filter.setFilter(filterString);
filter.setName(favoriteName);
filter.setPage(page);
sanitizeFavorite(filter);
favoriteDao.save(filter);
return filter;
}
Aggregations