java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
| 38 +++
java/code/src/com/redhat/rhn/frontend/action/audit/ssm/BaseSsmScheduleXccdfAction.java
| 63 +++++
java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
| 60 +++++
java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
| 106 ++++++++++
java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
| 64 ++++++
java/code/src/com/redhat/rhn/frontend/action/audit/ssm/validation/scheduleXccdfForm.xsd
| 17 +
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
| 33 +++
java/code/src/com/redhat/rhn/manager/action/ActionManager.java
| 29 ++
java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
| 57 +++++
java/code/webapp/WEB-INF/nav/ssm.xml
| 5
java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
| 32 +++
java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
| 31 ++
java/code/webapp/WEB-INF/pages/common/fragments/audit/scapcap-list.jspf
| 25 ++
java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
| 50 ++++
java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp
| 1
java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
| 41 ---
java/code/webapp/WEB-INF/pages/systems/details/packages/scheduleremote.jsp
| 1
java/code/webapp/WEB-INF/struts-config.xml
| 37 +++
18 files changed, 652 insertions(+), 38 deletions(-)
New commits:
commit f42b21d6c27a60dac838bdf80c4d67e07dfe2bfa
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Apr 24 14:38:50 2012 +0200
Promote Audit to separate tab within SSM.
diff --git a/java/code/webapp/WEB-INF/nav/ssm.xml b/java/code/webapp/WEB-INF/nav/ssm.xml
index 4c9a5c7..4e27af5 100644
--- a/java/code/webapp/WEB-INF/nav/ssm.xml
+++ b/java/code/webapp/WEB-INF/nav/ssm.xml
@@ -119,6 +119,11 @@
</rhn-tab>
</rhn-tab>
+ <rhn-tab name="Audit">
+ <rhn-tab-url>/rhn/systems/ssm/audit/ScheduleXccdf.do</rhn-tab-url>
+ <rhn-tab-url>/rhn/systems/ssm/audit/ScheduleXccdfSubmit.do</rhn-tab-url>
+ </rhn-tab>
+
<rhn-tab name="Misc">
<rhn-tab-url>/rhn/systems/ssm/misc/Index.do</rhn-tab-url>
<rhn-tab-url>/rhn/systems/ssm/HardwareRefresh.do</rhn-tab-url>
commit 25ef8e65848c247e5415660d355bbd4e6a254bce
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Fri Apr 20 14:51:10 2012 +0200
Show targeted systems when scheduling SCAP scan through SSM.
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
index f19ee34..bb750e2 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
@@ -121,4 +121,24 @@
</query>
</mode>
+<mode name="systems_in_set_and_scap_capability">
+ <query params="user_id, set_label">
+ SELECT DISTINCT s.id AS sid,
+ s.name AS name,
+ (SELECT 1
+ FROM rhnClientCapability cc
+ INNER JOIN rhnClientCapabilityName ccn ON cc.capability_name_id = ccn.id
+ WHERE cc.server_id = usp.server_id
+ AND ccn.name LIKE 'scap%'
+ ) AS scap
+ FROM rhnUserServerPerms usp
+ INNER JOIN rhnSet st ON st.user_id = usp.user_id
+ AND st.element = usp.server_id
+ INNER JOIN rhnServer s ON s.id = usp.server_id
+ WHERE st.user_id = :user_id
+ AND st.label = :set_label
+ ORDER BY name ASC
+ </query>
+</mode>
+
</datasource_modes>
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/BaseSsmScheduleXccdfAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/BaseSsmScheduleXccdfAction.java
new file mode 100644
index 0000000..f1b8e8e
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/BaseSsmScheduleXccdfAction.java
@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.audit.ssm;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts.action.DynaActionForm;
+
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
+import com.redhat.rhn.manager.audit.ScapManager;
+
+/**
+ * SSM OpenSCAP XCCDF scanning.
+ * @version $Rev$
+ */
+public abstract class BaseSsmScheduleXccdfAction
+ extends RhnAction implements Listable {
+
+ protected static final String DATE = "date";
+ protected static final String PATH = "path";
+ protected static final String PARAMS = "params";
+ protected static final String LOCALIZED_DATE = "localizedDate";
+ protected static final String READONLY = "readonly";
+ protected static final String TRUE = "true";
+ protected static final String ERROR = "error";
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext context) {
+ return ScapManager.systemsInSsmAndScapCapability(context.getLoggedInUser());
+ }
+
+ protected void setupListHelper(HttpServletRequest request) {
+ ListHelper helper = new ListHelper(this, request);
+ helper.execute();
+ request.setAttribute(ListTagHelper.PARENT_URL, request.getRequestURI());
+ }
+
+ protected void setupDatePicker(HttpServletRequest request, DynaActionForm form) {
+ getStrutsDelegate().prepopulateDatePicker(request,
+ form, DATE, DatePicker.YEAR_RANGE_POSITIVE);
+ }
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
index 4ed3fbb..37dc8f5 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
@@ -23,8 +23,6 @@ import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
-import com.redhat.rhn.common.util.DatePicker;
-import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnHelper;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
@@ -32,7 +30,7 @@ import com.redhat.rhn.frontend.struts.RhnValidationHelper;
* SSM OpenSCAP XCCDF scanning.
* @version $Rev$
*/
-public class SsmScheduleXccdfAction extends RhnAction {
+public class SsmScheduleXccdfAction extends BaseSsmScheduleXccdfAction {
/**
* {@inheritDoc}
@@ -53,15 +51,10 @@ public class SsmScheduleXccdfAction extends RhnAction {
getStrutsDelegate().saveMessages(request, errors);
}
}
- setupDefaultFormValues(request, form);
+ setupDatePicker(request, form);
+ setupListHelper(request);
return getStrutsDelegate().forwardParams(
mapping.findForward(RhnHelper.DEFAULT_FORWARD),
request.getParameterMap());
}
-
- private void setupDefaultFormValues(HttpServletRequest request,
- DynaActionForm form) {
- getStrutsDelegate().prepopulateDatePicker(request,
- form, "date", DatePicker.YEAR_RANGE_POSITIVE);
- }
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
index f61f697..28ca5fe 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
@@ -30,7 +30,6 @@ import org.apache.struts.action.DynaActionForm;
import com.redhat.rhn.common.util.DatePicker;
import com.redhat.rhn.domain.action.scap.ScapAction;
import com.redhat.rhn.frontend.struts.RequestContext;
-import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnHelper;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
import com.redhat.rhn.frontend.struts.StrutsDelegate;
@@ -42,12 +41,7 @@ import com.redhat.rhn.manager.audit.ScapManager;
* This action dispatches the second submit and commits the action.
* @version $Rev$
*/
-public class SsmScheduleXccdfConfirmAction extends RhnAction {
-
- private static final String PATH = "path";
- private static final String PARAMS = "params";
- private static final String DATE = "date";
- private static final String ERROR = "error";
+public class SsmScheduleXccdfConfirmAction extends BaseSsmScheduleXccdfAction {
/**
* {@inheritDoc}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
index 365b738..c899c5b 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
@@ -26,7 +26,6 @@ import org.apache.struts.action.DynaActionForm;
import com.redhat.rhn.common.localization.LocalizationService;
import com.redhat.rhn.common.util.DatePicker;
-import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnHelper;
import com.redhat.rhn.frontend.struts.StrutsDelegate;
@@ -34,14 +33,7 @@ import com.redhat.rhn.frontend.struts.StrutsDelegate;
* SSM OpenSCAP XCCDF scanning.
* @version $Rev$
*/
-public class SsmScheduleXccdfSubmitAction extends RhnAction {
-
- private static final String PATH = "path";
- private static final String PARAMS = "params";
- private static final String DATE = "date";
- private static final String LOCALIZED_DATE = "localizedDate";
- private static final String READONLY = "readonly";
- private static final String TRUE = "true";
+public class SsmScheduleXccdfSubmitAction extends BaseSsmScheduleXccdfAction {
/**
* {@inheritDoc}
@@ -61,8 +53,9 @@ public class SsmScheduleXccdfSubmitAction extends RhnAction {
request.setAttribute(LOCALIZED_DATE,
LocalizationService.getInstance().formatDate(earliest));
request.setAttribute(READONLY, TRUE);
- strutsDelegate.prepopulateDatePicker(request,
- form, DATE, DatePicker.YEAR_RANGE_POSITIVE);
+
+ setupDatePicker(request, form);
+ setupListHelper(request);
return strutsDelegate.forwardParams(
mapping.findForward(RhnHelper.DEFAULT_FORWARD),
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 3a3a4c6..e82b561 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -11841,6 +11841,18 @@ the <strong>Red Hat Enterprise Linux System
Administration Guide.</stro
</group>
<group>
+ <context-group>
+ <context context-type="sourcefile">Page for a new SCAP scan
schedule for SSM</context>
+ </context-group>
+ <trans-unit id="ssm.audit.xccdf.targetedsystems">
+ <source>Targeted Systems</source>
+ </trans-unit>
+ <trans-unit id="ssm.audit.xccdf.capability">
+ <source>OpenSCAP Scan Capability</source>
+ </trans-unit>
+ </group>
+
+ <group>
<context-group name="ctx">
<context context-type="sourcefile">View of SCAP scans for given
system</context>
</context-group>
diff --git a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
index 3a58600..bea4102 100644
--- a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
+++ b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
@@ -138,6 +138,20 @@ public class ScapManager extends BaseManager {
}
/**
+ * Show systems in SSM and their true/false scap capability
+ * @param scheduler user requesting the systems
+ * @return the list of systems in SSM
+ */
+ public static DataResult systemsInSsmAndScapCapability(User scheduler) {
+ SelectMode m = ModeFactory.getMode("scap_queries",
+ "systems_in_set_and_scap_capability");
+ HashMap params = new HashMap();
+ params.put("user_id", scheduler.getId());
+ params.put("set_label", RhnSetDecl.SYSTEMS.getLabel());
+ return m.execute(params);
+ }
+
+ /**
* Schedule scap.xccdf_eval action for systems in user's SSM.
* @param scheduler user which commits the schedule
* @param path path to xccdf document on systems file system
diff --git a/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
index b8b89fd..c975313 100644
--- a/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
+++ b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
@@ -1,5 +1,6 @@
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core"
prefix="c"%>
<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn"%>
+<%@ taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl"
%>
<%@ taglib
uri="http://struts.apache.org/tags-bean"
prefix="bean"%>
<%@ taglib
uri="http://struts.apache.org/tags-html"
prefix="html"%>
@@ -15,7 +16,16 @@
<%@ include
file="/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf" %>
+ <div align="right">
+ </hr>
+ <html:submit property="schedule_button">
+ <bean:message key="system.audit.confirmschedulexccdf.jsp.button"/>
+ </html:submit>
+ </div>
</html:form>
+
+<%@ include file="/WEB-INF/pages/common/fragments/audit/scapcap-list.jspf"
%>
+
</div>
</body>
diff --git a/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
index e5741b7..e1565c5 100644
--- a/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
+++ b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
@@ -1,5 +1,6 @@
<%@ taglib
uri="http://java.sun.com/jsp/jstl/core"
prefix="c"%>
<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn"%>
+<%@ taglib
uri="http://rhn.redhat.com/tags/list" prefix="rl"
%>
<%@ taglib
uri="http://struts.apache.org/tags-bean"
prefix="bean"%>
<%@ taglib
uri="http://struts.apache.org/tags-html"
prefix="html"%>
@@ -14,10 +15,17 @@
<html:form method="post"
action="/systems/ssm/audit/ScheduleXccdf.do">
<%@ include
file="/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf" %>
-
+ <rhn:tooltip><bean:message
key="system.audit.schedulexccdf.jsp.tooltip"/></rhn:tooltip>
+ <div align="right">
+ </hr>
+ <html:submit property="schedule_button">
+ <bean:message key="system.audit.schedulexccdf.jsp.button"/>
+ </html:submit>
+ </div>
</html:form>
+
+<%@ include file="/WEB-INF/pages/common/fragments/audit/scapcap-list.jspf"
%>
</div>
-<rhn:tooltip><bean:message
key="system.audit.schedulexccdf.jsp.tooltip"/></rhn:tooltip>
</body>
</html>
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/scapcap-list.jspf
b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scapcap-list.jspf
new file mode 100644
index 0000000..7fc31e8
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/scapcap-list.jspf
@@ -0,0 +1,25 @@
+<rl:listset name="systemListSet" legend="system">
+ <rhn:csrf/>
+ <rhn:submitted/>
+ <h2><bean:message
key="ssm.audit.xccdf.targetedsystems"/></h2>
+ <rl:list emptykey="nosystems.message">
+
+ <rl:column headerkey="systemlist.jsp.system"
styleclass="first-column">
+ <c:out escapeXml="false"
+ value="<a
href=\"/rhn/systems/details/audit/ListScap.do?sid=${current.sid}\">"/>
+ <c:out value="${current.name}"/>
+ <c:out escapeXml="false" value="</a>"/>
+ </rl:column>
+
+ <rl:column headerkey="ssm.audit.xccdf.capability"
styleclass="last-column">
+ <c:choose>
+ <c:when test="${current.scap == 1}">
+ <bean:message key="targetsystems.jsp.yes"/>
+ </c:when>
+ <c:otherwise>
+ <bean:message key="targetsystems.jsp.no"/>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ </rl:list>
+</rl:listset>
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
b/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
index d40b829..825c5db 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
@@ -48,10 +48,3 @@
</table>
<html:hidden property="submitted" value="true" />
-
-<div align="right">
- </hr>
- <html:submit property="schedule_button">
- <bean:message key="system.audit.schedulexccdf.jsp.button"/>
- </html:submit>
-</div>
diff --git a/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
b/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
index bf3ce93..1253be0 100644
--- a/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
@@ -23,6 +23,12 @@
<%@ include
file="/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf" %>
<html:hidden property="sid" value="${param.sid}"/>
+ <div align="right">
+ </hr>
+ <html:submit property="schedule_button">
+ <bean:message key="system.audit.schedulexccdf.jsp.button"/>
+ </html:submit>
+ </div>
</html:form>
<rhn:tooltip>
<bean:message key="system.audit.schedulexccdf.jsp.tooltip"/>
commit f419e7c7684fdf81fa95797355337617783fbd3c
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Fri Apr 20 14:33:30 2012 +0200
Extract method scapCapableSystemsInSsm()
diff --git a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
index 385ea4e..3a58600 100644
--- a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
+++ b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
@@ -124,6 +124,20 @@ public class ScapManager extends BaseManager {
}
/**
+ * Show scap capable systems which are currently in SSM
+ * @param scheduler user requesting the systems
+ * @return the list of systems in SSM
+ */
+ public static DataResult scapCapableSystemsInSsm(User scheduler) {
+ SelectMode m = ModeFactory.getMode("scap_queries",
+ "scap_capable_systems_in_set");
+ HashMap params = new HashMap();
+ params.put("user_id", scheduler.getId());
+ params.put("set_label", RhnSetDecl.SYSTEMS.getLabel());
+ return m.execute(params);
+ }
+
+ /**
* Schedule scap.xccdf_eval action for systems in user's SSM.
* @param scheduler user which commits the schedule
* @param path path to xccdf document on systems file system
@@ -133,12 +147,7 @@ public class ScapManager extends BaseManager {
*/
public static ScapAction scheduleXccdfEvalInSsm(User scheduler, String path,
String parameters, Date earliest) {
- SelectMode m = ModeFactory.getMode("scap_queries",
- "scap_capable_systems_in_set");
- HashMap params = new HashMap();
- params.put("user_id", scheduler.getId());
- params.put("set_label", RhnSetDecl.SYSTEMS.getLabel());
- HashSet<Long> systemIds = idsInDataResultToSet(m.execute(params));
+ HashSet<Long> systemIds =
idsInDataResultToSet(scapCapableSystemsInSsm(scheduler));
return ActionManager.scheduleXccdfEval(
scheduler, systemIds, path, parameters, earliest);
}
commit 42511cebb36264e2212861c4bf60f73b74735a11
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Apr 19 14:29:07 2012 +0200
Handle errors during SSM schedule of SCAP scan.
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
index 4536a6a..f61f697 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
@@ -34,6 +34,7 @@ import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnHelper;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
import com.redhat.rhn.frontend.struts.StrutsDelegate;
+import com.redhat.rhn.manager.MissingEntitlementException;
import com.redhat.rhn.manager.audit.ScapManager;
/**
@@ -75,12 +76,29 @@ public class SsmScheduleXccdfConfirmAction extends RhnAction {
RequestContext context = new RequestContext(request);
StrutsDelegate strutsDelegate = getStrutsDelegate();
- ScapAction scapAction = ScapManager.scheduleXccdfEvalInSsm(
- context.getLoggedInUser(),
- (String) form.get(PATH),
- (String) form.get(PARAMS),
- getStrutsDelegate().readDatePicker(form, DATE,
- DatePicker.YEAR_RANGE_POSITIVE));
+ ActionErrors errors = new ActionErrors();
+ ScapAction scapAction = null;
+ try {
+ scapAction = ScapManager.scheduleXccdfEvalInSsm(
+ context.getLoggedInUser(),
+ (String) form.get(PATH),
+ (String) form.get(PARAMS),
+ getStrutsDelegate().readDatePicker(form, DATE,
+ DatePicker.YEAR_RANGE_POSITIVE));
+ }
+ catch (MissingEntitlementException e) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE,
+ new ActionMessage("message.entitlement.missing",
e.getMessage()));
+ }
+
+ if (scapAction == null) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE,
+ new ActionMessage("message.xccdfeval.failed"));
+ addErrors(request, errors);
+ return strutsDelegate.forwardParams(
+ mapping.findForward(ERROR),
+ request.getParameterMap());
+ }
ActionMessages msgs = new ActionMessages();
msgs.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("message.xccdfeval.ssm"));
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index f3ab967..3a3a4c6 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -6088,6 +6088,18 @@ value for this entitlement, excluding the default
organization's consumption.</s
<context
context-type="sourcefile">/rhn/schedule/ActionDetails.do</context>
</context-group>
</trans-unit>
+ <trans-unit id="message.entitlement.missing">
+ <source>One or more of the selected systems lack the {0}
entitlement.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/systems/ssm/audit/ScheduleXccdf.do</context>
+ </context-group>
+ </trans-unit>
+ <trans-unit id="message.xccdfeval.failed">
+ <source>Action was not scheduled.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/systems/ssm/audit/ScheduleXccdf.do</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="removeconfirm.jsp.runremotecommand">
<source>Add Remote Command To Package Removal</source>
<context-group name="ctx">
commit bc5a166cf8090e9af0388f0e9ec87388f16840f7
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Apr 19 11:33:04 2012 +0200
OpenSCAP integration -- schedule new scan in SSM
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
index 9e4d8eb..f19ee34 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/scap_queries.xml
@@ -103,4 +103,22 @@
</query>
</mode>
+<mode name="scap_capable_systems_in_set">
+ <query params="user_id, set_label">
+ SELECT DISTINCT usp.server_id AS id
+ FROM rhnUserServerPerms usp
+ INNER JOIN rhnSet st ON st.user_id = usp.user_id
+ AND st.element = usp.server_id
+ WHERE st.user_id = :user_id
+ AND st.label = :set_label
+ AND EXISTS (
+ SELECT 1
+ FROM rhnClientCapability cc
+ INNER JOIN rhnClientCapabilityName ccn ON cc.capability_name_id =
ccn.id
+ WHERE cc.server_id = usp.server_id
+ AND ccn.name LIKE 'scap%'
+ )
+ </query>
+</mode>
+
</datasource_modes>
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
new file mode 100644
index 0000000..4ed3fbb
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfAction.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.audit.ssm;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.struts.RhnHelper;
+import com.redhat.rhn.frontend.struts.RhnValidationHelper;
+
+/**
+ * SSM OpenSCAP XCCDF scanning.
+ * @version $Rev$
+ */
+public class SsmScheduleXccdfAction extends RhnAction {
+
+ /**
+ * {@inheritDoc}
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ DynaActionForm form = (DynaActionForm) formIn;
+
+ if (isSubmitted(form)) {
+ ActionErrors errors = RhnValidationHelper.validateDynaActionForm(this,
form);
+ if (errors.isEmpty()) {
+ return
getStrutsDelegate().forwardParams(mapping.findForward("submit"),
+ request.getParameterMap());
+ }
+ else {
+ getStrutsDelegate().saveMessages(request, errors);
+ }
+ }
+ setupDefaultFormValues(request, form);
+ return getStrutsDelegate().forwardParams(
+ mapping.findForward(RhnHelper.DEFAULT_FORWARD),
+ request.getParameterMap());
+ }
+
+ private void setupDefaultFormValues(HttpServletRequest request,
+ DynaActionForm form) {
+ getStrutsDelegate().prepopulateDatePicker(request,
+ form, "date", DatePicker.YEAR_RANGE_POSITIVE);
+ }
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
new file mode 100644
index 0000000..4536a6a
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfConfirmAction.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.audit.ssm;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.action.DynaActionForm;
+
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.domain.action.scap.ScapAction;
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.struts.RhnHelper;
+import com.redhat.rhn.frontend.struts.RhnValidationHelper;
+import com.redhat.rhn.frontend.struts.StrutsDelegate;
+import com.redhat.rhn.manager.audit.ScapManager;
+
+/**
+ * SSM OpenSCAP XCCDF scanning.
+ * This action dispatches the second submit and commits the action.
+ * @version $Rev$
+ */
+public class SsmScheduleXccdfConfirmAction extends RhnAction {
+
+ private static final String PATH = "path";
+ private static final String PARAMS = "params";
+ private static final String DATE = "date";
+ private static final String ERROR = "error";
+
+ /**
+ * {@inheritDoc}
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ StrutsDelegate strutsDelegate = getStrutsDelegate();
+ DynaActionForm form = (DynaActionForm) formIn;
+
+ if (isSubmitted(form)) {
+ ActionErrors errors = RhnValidationHelper.validateDynaActionForm(this,
form);
+ if (errors.isEmpty()) {
+ return processForm(mapping, request, form);
+ }
+ }
+
+ return strutsDelegate.forwardParams(
+ mapping.findForward(ERROR),
+ request.getParameterMap());
+ }
+
+ private ActionForward processForm(ActionMapping mapping,
+ HttpServletRequest request, DynaActionForm form) {
+ RequestContext context = new RequestContext(request);
+ StrutsDelegate strutsDelegate = getStrutsDelegate();
+
+ ScapAction scapAction = ScapManager.scheduleXccdfEvalInSsm(
+ context.getLoggedInUser(),
+ (String) form.get(PATH),
+ (String) form.get(PARAMS),
+ getStrutsDelegate().readDatePicker(form, DATE,
+ DatePicker.YEAR_RANGE_POSITIVE));
+
+ ActionMessages msgs = new ActionMessages();
+ msgs.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("message.xccdfeval.ssm"));
+ strutsDelegate.saveMessages(request, msgs);
+
+ Map paramMap = makeParamMap(request);
+ paramMap.put("aid", scapAction.getId());
+ return
strutsDelegate.forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD),
+ paramMap);
+ }
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
new file mode 100644
index 0000000..365b738
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/SsmScheduleXccdfSubmitAction.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ *
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.audit.ssm;
+
+import java.util.Date;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.DynaActionForm;
+
+import com.redhat.rhn.common.localization.LocalizationService;
+import com.redhat.rhn.common.util.DatePicker;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.struts.RhnHelper;
+import com.redhat.rhn.frontend.struts.StrutsDelegate;
+
+/**
+ * SSM OpenSCAP XCCDF scanning.
+ * @version $Rev$
+ */
+public class SsmScheduleXccdfSubmitAction extends RhnAction {
+
+ private static final String PATH = "path";
+ private static final String PARAMS = "params";
+ private static final String DATE = "date";
+ private static final String LOCALIZED_DATE = "localizedDate";
+ private static final String READONLY = "readonly";
+ private static final String TRUE = "true";
+
+ /**
+ * {@inheritDoc}
+ */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ StrutsDelegate strutsDelegate = getStrutsDelegate();
+ DynaActionForm form = (DynaActionForm) formIn;
+
+ String params = (String) form.get(PARAMS);
+ String path = (String) form.get(PATH);
+ Date earliest = strutsDelegate.readDatePicker(form, DATE,
+ DatePicker.YEAR_RANGE_POSITIVE);
+
+ request.setAttribute(LOCALIZED_DATE,
+ LocalizationService.getInstance().formatDate(earliest));
+ request.setAttribute(READONLY, TRUE);
+ strutsDelegate.prepopulateDatePicker(request,
+ form, DATE, DatePicker.YEAR_RANGE_POSITIVE);
+
+ return strutsDelegate.forwardParams(
+ mapping.findForward(RhnHelper.DEFAULT_FORWARD),
+ request.getParameterMap());
+ }
+}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/validation/scheduleXccdfForm.xsd
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/validation/scheduleXccdfForm.xsd
new file mode 100644
index 0000000..ea1264b
--- /dev/null
+++
b/java/code/src/com/redhat/rhn/frontend/action/audit/ssm/validation/scheduleXccdfForm.xsd
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+
+<schema targetNamespace="http://rhn.redhat.com"
+
xmlns="http://www.w3.org/1999/XMLSchema"
+ xmlns:rhn="http://rhn.redhat.com">
+ <attribute name="params">
+ <simpleType baseType="string">
+ <maxLength value="8192"/>
+ </simpleType>
+ </attribute>
+ <attribute name="path">
+ <simpleType baseType="string">
+ <minLength value="1"/>
+ <maxLength value="2048"/>
+ </simpleType>
+ </attribute>
+</schema>
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index 29e44ee..f3ab967 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -4581,6 +4581,9 @@ value for this entitlement, excluding the default organization's
consumption.</s
<trans-unit id="ssm.overview.misc.migrate">
<source><a
href="/rhn/systems/ssm/misc/Index.do#migrate">Migrate</a>
systems to another organization</source>
</trans-unit>
+ <trans-unit id="ssm.overview.misc.scap">
+ <source><a
href="/rhn/systems/ssm/audit/ScheduleXccdf.do">Audit</a>
systems with OpenSCAP</source>
+ </trans-unit>
</group>
<!-- SSM System List -->
@@ -6079,6 +6082,12 @@ value for this entitlement, excluding the default
organization's consumption.</s
<context
context-type="sourcefile">/rhn/systems/details/audit/ListScap.do</context>
</context-group>
</trans-unit>
+ <trans-unit id="message.xccdfeval.ssm">
+ <source>XCCDF scan has been scheduled successfully.</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/schedule/ActionDetails.do</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="removeconfirm.jsp.runremotecommand">
<source>Add Remote Command To Package Removal</source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
index 222eb18..385ea4e 100644
--- a/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
+++ b/java/code/src/com/redhat/rhn/manager/audit/ScapManager.java
@@ -15,18 +15,23 @@
package com.redhat.rhn.manager.audit;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import com.redhat.rhn.common.db.datasource.DataResult;
import com.redhat.rhn.common.db.datasource.ModeFactory;
import com.redhat.rhn.common.db.datasource.SelectMode;
+import com.redhat.rhn.domain.action.scap.ScapAction;
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.dto.XccdfIdentDto;
import com.redhat.rhn.frontend.dto.XccdfRuleResultDto;
import com.redhat.rhn.manager.BaseManager;
+import com.redhat.rhn.manager.action.ActionManager;
+import com.redhat.rhn.manager.rhnset.RhnSetDecl;
/**
* ScapManager
@@ -118,6 +123,26 @@ public class ScapManager extends BaseManager {
return m.execute(params);
}
+ /**
+ * Schedule scap.xccdf_eval action for systems in user's SSM.
+ * @param scheduler user which commits the schedule
+ * @param path path to xccdf document on systems file system
+ * @param parameters additional parameters for xccdf scan
+ * @param earliest time of earliest action occurence
+ * @return the newly created ScapAction
+ */
+ public static ScapAction scheduleXccdfEvalInSsm(User scheduler, String path,
+ String parameters, Date earliest) {
+ SelectMode m = ModeFactory.getMode("scap_queries",
+ "scap_capable_systems_in_set");
+ HashMap params = new HashMap();
+ params.put("user_id", scheduler.getId());
+ params.put("set_label", RhnSetDecl.SYSTEMS.getLabel());
+ HashSet<Long> systemIds = idsInDataResultToSet(m.execute(params));
+ return ActionManager.scheduleXccdfEval(
+ scheduler, systemIds, path, parameters, earliest);
+ }
+
private static List<Map<String, Object>> transposeView(DataResult
testResultsRaw) {
List<Map<String, Object>> resultView = new
ArrayList<Map<String, Object>>();
Map<String, Object> currResult = null;
@@ -146,4 +171,13 @@ public class ScapManager extends BaseManager {
}
return resultView;
}
+
+ private static HashSet<Long> idsInDataResultToSet(DataResult dataIn) {
+ HashSet<Long> result = new HashSet<Long>();
+ for (Map<String, Long> map : (List<Map<String, Long>>) dataIn)
{
+ result.add(map.get("id"));
+ }
+ return result;
+ }
+
}
diff --git a/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
new file mode 100644
index 0000000..b8b89fd
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp
@@ -0,0 +1,22 @@
+<%@ taglib
uri="http://java.sun.com/jsp/jstl/core"
prefix="c"%>
+<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn"%>
+<%@ taglib
uri="http://struts.apache.org/tags-bean"
prefix="bean"%>
+<%@ taglib
uri="http://struts.apache.org/tags-html"
prefix="html"%>
+
+<html:xhtml/>
+<html>
+<body>
+
+<%@ include file="/WEB-INF/pages/common/fragments/ssm/header.jspf" %>
+<h2><bean:message
key="system.audit.schedulexccdf.jsp.schedule"/></h2>
+
+<div>
+<html:form method="post"
action="/systems/ssm/audit/ScheduleXccdfConfirm.do">
+
+ <%@ include
file="/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf" %>
+
+</html:form>
+</div>
+
+</body>
+</html>
diff --git a/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
new file mode 100644
index 0000000..e5741b7
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp
@@ -0,0 +1,23 @@
+<%@ taglib
uri="http://java.sun.com/jsp/jstl/core"
prefix="c"%>
+<%@ taglib
uri="http://rhn.redhat.com/rhn" prefix="rhn"%>
+<%@ taglib
uri="http://struts.apache.org/tags-bean"
prefix="bean"%>
+<%@ taglib
uri="http://struts.apache.org/tags-html"
prefix="html"%>
+
+<html:xhtml/>
+<html>
+<body>
+
+<%@ include file="/WEB-INF/pages/common/fragments/ssm/header.jspf" %>
+<h2><bean:message
key="system.audit.schedulexccdf.jsp.schedule"/></h2>
+
+<div>
+<html:form method="post"
action="/systems/ssm/audit/ScheduleXccdf.do">
+
+ <%@ include
file="/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf" %>
+
+</html:form>
+</div>
+
+<rhn:tooltip><bean:message
key="system.audit.schedulexccdf.jsp.tooltip"/></rhn:tooltip>
+</body>
+</html>
diff --git a/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp
b/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp
index 8cf5b63..ae0dea4 100644
--- a/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp
+++ b/java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp
@@ -75,6 +75,7 @@
<bean:message key="ssm.overview.misc.entitlements"/><br />
<bean:message key="ssm.overview.misc.deletereboot"/><br />
<bean:message key="ssm.overview.misc.migrate"/><br />
+ <bean:message key="ssm.overview.misc.scap"/><br />
</p>
</td>
</tr>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 88dc052..79d59ec 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -4764,6 +4764,43 @@
path="/WEB-INF/pages/ssm/systems/misc/index.jsp" />
</action>
+ <action path="/systems/ssm/audit/ScheduleXccdf"
+ scope="request"
+ name="scheduleXccdfForm"
+ input="/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp"
+ type="com.redhat.rhn.frontend.action.audit.ssm.SsmScheduleXccdfAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <forward name="default"
+ path="/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp"/>
+ <forward name="error"
+ path="/WEB-INF/pages/audit/ssm/ssmschedulexccdf.jsp"/>
+ <forward name="submit"
+ path="/systems/ssm/audit/ScheduleXccdfSubmit.do"/>
+ </action>
+
+ <action path="/systems/ssm/audit/ScheduleXccdfSubmit"
+ scope="request"
+ name="scheduleXccdfForm"
+ input="/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp"
+
type="com.redhat.rhn.frontend.action.audit.ssm.SsmScheduleXccdfSubmitAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="postRequired" value="true"/>
+ <forward name="default"
+ path="/WEB-INF/pages/audit/ssm/ssmschedulexccdf-submit.jsp"/>
+ </action>
+
+ <action path="/systems/ssm/audit/ScheduleXccdfConfirm"
+ scope="request"
+ name="scheduleXccdfForm"
+
type="com.redhat.rhn.frontend.action.audit.ssm.SsmScheduleXccdfConfirmAction"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <set-property property="postRequired" value="true"/>
+ <forward name="default"
+ path="/schedule/InProgressSystems.do"/>
+ <forward name="error"
+ path="/systems/ssm/audit/ScheduleXccdf.do"/>
+ </action>
+
<!-- ===== END SSM ===== -->
<action path="/monitoring/config/notification/Methods"
commit 067cd8314f9912388b1d137b3f6ea696c15d580d
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Apr 19 11:18:42 2012 +0200
Extract method for scheduling xccdfEval for multiple systems.
diff --git a/java/code/src/com/redhat/rhn/manager/action/ActionManager.java
b/java/code/src/com/redhat/rhn/manager/action/ActionManager.java
index 6c10c24..d0d1781 100644
--- a/java/code/src/com/redhat/rhn/manager/action/ActionManager.java
+++ b/java/code/src/com/redhat/rhn/manager/action/ActionManager.java
@@ -1795,14 +1795,33 @@ public class ActionManager extends BaseManager {
*/
public static ScapAction scheduleXccdfEval(User scheduler, Server srvr, String path,
String parameters, Date earliestAction) {
- if (!SystemManager.hasEntitlement(srvr.getId(),
+ Set<Long> serverIds = new HashSet<Long>();
+ serverIds.add(srvr.getId());
+ return scheduleXccdfEval(scheduler, serverIds, path, parameters,
earliestAction);
+ }
+
+ /**
+ * Schedules Xccdf evaluation.
+ * @param scheduler User scheduling the action.
+ * @param serverIds Set of server identifiers for which the action affects.
+ * @param path Path for the Xccdf content.
+ * @param parameters Additional parameters for oscap tool.
+ * @param earliestAction Date of earliest action to be executed.
+ * @return scheduled Scap Action
+ */
+ public static ScapAction scheduleXccdfEval(User scheduler, Set<Long>
serverIds,
+ String path, String parameters, Date earliestAction) {
+ if (serverIds.isEmpty()) {
+ return null;
+ }
+ for (Long serverId : serverIds) {
+ if (!SystemManager.hasEntitlement(serverId,
EntitlementManager.MANAGEMENT)) {
- throw new MissingEntitlementException(
- EntitlementManager.MANAGEMENT.getHumanReadableLabel());
+ throw new MissingEntitlementException(
+ EntitlementManager.MANAGEMENT.getHumanReadableLabel());
+ }
}
- Set<Long> serverIds = new HashSet<Long>();
- serverIds.add(srvr.getId());
ScapActionDetails scapDetails = new ScapActionDetails(path, parameters);
ScapAction action = (ScapAction) scheduleAction(scheduler,
ActionFactory.TYPE_SCAP_XCCDF_EVAL,
commit ab2670becd55c9bbd69f189ed38a0998e869b82e
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Apr 19 11:33:35 2012 +0200
The fragment could be used as readonly for confirmation
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
b/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
index 029a538..d40b829 100644
--- a/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
@@ -1,3 +1,8 @@
+
+<c:if test="${empty readonly}">
+ <c:set var="readonly" value="false"/>
+</c:if>
+
<rhn:csrf/>
<table class="details">
<tr>
@@ -6,18 +11,38 @@
</tr>
<tr>
<th><bean:message
key="system.audit.schedulexccdf.jsp.arguments"/>:</th>
- <td><html:text property="params" maxlength="2048"
size="40" styleId="params"/></td>
+ <td>
+ <html:text property="params" maxlength="2048"
size="40" styleId="params"
+ readonly="${readonly}"/>
+ </td>
</tr>
<tr>
<th><bean:message
key="system.audit.schedulexccdf.jsp.path"/><span
class="required-form-field">*</span>:</th>
- <td><html:text property="path" size="40"
styleId="path"/></td>
+ <td>
+ <html:text property="path" size="40" styleId="path"
+ readonly="${readonly}"/>
+ </td>
</tr>
<tr>
<th><bean:message
key="scheduleremote.jsp.nosoonerthan"/>:</th>
<td>
- <jsp:include page="/WEB-INF/pages/common/fragments/date-picker.jsp">
- <jsp:param name="widget" value="date"/>
- </jsp:include>
+ <c:choose>
+ <c:when test="${readonly == 'true'}">
+ <c:out value="${localizedDate}"/>
+ <html:hidden property="use_date" value="true" />
+ <html:hidden property="date_year" />
+ <html:hidden property="date_month" />
+ <html:hidden property="date_day" />
+ <html:hidden property="date_hour" />
+ <html:hidden property="date_minute" />
+ <html:hidden property="date_am_pm" />
+ </c:when>
+ <c:otherwise>
+ <jsp:include page="/WEB-INF/pages/common/fragments/date-picker.jsp">
+ <jsp:param name="widget" value="date"/>
+ </jsp:include>
+ </c:otherwise>
+ </c:choose>
</td>
</tr>
</table>
commit ad4252e90127cdfdb0e0ea1a9df025a486f7a759
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Apr 12 12:27:53 2012 +0200
Refactor xccdf schedule form to jsp fragment.
diff --git a/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
b/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
new file mode 100644
index 0000000..029a538
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf
@@ -0,0 +1,32 @@
+<rhn:csrf/>
+<table class="details">
+<tr>
+ <th><bean:message
key="system.audit.schedulexccdf.jsp.command"/>:</th>
+ <td>/usr/bin/oscap xccdf eval</td>
+</tr>
+<tr>
+ <th><bean:message
key="system.audit.schedulexccdf.jsp.arguments"/>:</th>
+ <td><html:text property="params" maxlength="2048"
size="40" styleId="params"/></td>
+</tr>
+<tr>
+ <th><bean:message
key="system.audit.schedulexccdf.jsp.path"/><span
class="required-form-field">*</span>:</th>
+ <td><html:text property="path" size="40"
styleId="path"/></td>
+</tr>
+<tr>
+ <th><bean:message
key="scheduleremote.jsp.nosoonerthan"/>:</th>
+ <td>
+ <jsp:include page="/WEB-INF/pages/common/fragments/date-picker.jsp">
+ <jsp:param name="widget" value="date"/>
+ </jsp:include>
+ </td>
+</tr>
+</table>
+
+<html:hidden property="submitted" value="true" />
+
+<div align="right">
+ </hr>
+ <html:submit property="schedule_button">
+ <bean:message key="system.audit.schedulexccdf.jsp.button"/>
+ </html:submit>
+</div>
diff --git a/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
b/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
index bd56402..bf3ce93 100644
--- a/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/details/audit/schedulexccdf.jsp
@@ -19,39 +19,10 @@
</c:when>
<c:otherwise>
<html:form method="post"
action="/systems/details/audit/ScheduleXccdf.do">
- <rhn:csrf/>
- <table class="details">
- <tr>
- <th><bean:message
key="system.audit.schedulexccdf.jsp.command"/>:</th>
- <td>/usr/bin/oscap xccdf eval</td>
- </tr>
- <tr>
- <th><bean:message
key="system.audit.schedulexccdf.jsp.arguments"/>:</th>
- <td><html:text property="params" maxlength="2048"
size="40" styleId="params"/></td>
- </tr>
- <tr>
- <th><bean:message
key="system.audit.schedulexccdf.jsp.path"/><span
class="required-form-field">*</span>:</th>
- <td><html:text property="path" size="40"
styleId="path"/></td>
- </tr>
- <tr>
- <th><bean:message
key="scheduleremote.jsp.nosoonerthan"/>:</th>
- <td>
- <jsp:include page="/WEB-INF/pages/common/fragments/date-picker.jsp">
- <jsp:param name="widget" value="date"/>
- </jsp:include>
- </td>
- </tr>
- </table>
-
- <html:hidden property="sid" value="${param.sid}"/>
- <html:hidden property="submitted" value="true" />
-
- <div align="right">
- </hr>
- <html:submit property="schedule_button">
- <bean:message key="system.audit.schedulexccdf.jsp.button"/>
- </html:submit>
- </div>
+
+ <%@ include
file="/WEB-INF/pages/common/fragments/audit/schedule-xccdf.jspf" %>
+
+ <html:hidden property="sid" value="${param.sid}"/>
</html:form>
<rhn:tooltip>
<bean:message key="system.audit.schedulexccdf.jsp.tooltip"/>
commit 4f341276480bcc9ea825d006c37542cd96fc7f3d
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Thu Apr 19 13:31:41 2012 +0200
Remove redundant definitions of use_date
Not only redundancy is not nice, this actually fixes the problem
of the following unlikely scenario, when action is scheduled
for a different date compared to what is displayed on confirmation
pages.
Systems
-> (a system)
-> Software
-> Packages
-> Upgrade
-> (select a package)
-> Upgrade Packages
-> Schedule action for no sooner than
(choose a date different from now)
-> Schedule action as soon as possible
-> Add Remote Command To Package Upgrade
-> Confirm
diff --git a/java/code/webapp/WEB-INF/pages/systems/details/packages/scheduleremote.jsp
b/java/code/webapp/WEB-INF/pages/systems/details/packages/scheduleremote.jsp
index fe8f7d0..a12f605 100644
--- a/java/code/webapp/WEB-INF/pages/systems/details/packages/scheduleremote.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/details/packages/scheduleremote.jsp
@@ -49,7 +49,6 @@
</td>
</tr>
</table>
- <html:hidden property="use_date" value="true" />
<html:hidden property="session_set_label"
value="${param.session_set_label}" />
<html:hidden property="sid" value="${param.sid}" />