etc/m2/settings-bugfixes.xml | 54 + modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml | 22 modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java | 37 + modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java | 56 + modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java | 128 ++++ modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java | 2 modules/enterprise/gui/installer-war/pom.xml | 17 modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java | 54 + modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java | 23 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java | 27 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java | 87 +++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsForm.java | 139 ++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java | 148 +++++ modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java | 54 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveResourceGroupsForm.java | 21 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RoleAdminPortalAction.java | 18 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java | 11 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java | 13 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java | 3 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java | 7 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java | 21 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java | 8 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/AttrConstants.java | 12 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/ParamConstants.java | 6 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java | 3 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java | 33 + modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertHistoryUIBean.java | 1 modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties | 8 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml | 58 -- modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml | 50 + modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/admin-def.xml | 4 modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/events-def.xml | 8 modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp | 27 modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp | 30 + modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp | 39 + modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinition.jsp | 6 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp | 4 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp | 2 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp | 6 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp | 4 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp | 4 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp | 4 modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp | 2 modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/fileUpload.xhtml | 39 + modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml | 2 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml | 7 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml | 8 modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml | 230 ++++---- modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/file-upload.xhtml | 49 - modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/inventory/create-file-upload.xhtml | 52 - modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml | 2 modules/enterprise/server/container-lib/pom.xml | 7 modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java | 144 +++++ modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat | 121 ++++ modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh | 165 +++++ modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml | 22 modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej | 9 modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej | 13 modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej | 9 modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej | 9 modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml | 3 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java | 5 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java | 5 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java | 3 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java | 1 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java | 102 +++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java | 9 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java | 44 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java | 6 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoDetails.java | 13 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoGroupDetails.java | 10 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java | 281 ++++++++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java | 48 + modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java | 32 - modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java | 25 modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java | 2 modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java | 38 + modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 3 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java | 13 modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/DeploymentUtility.java | 2 modules/plugins/pom.xml | 18 pom.xml | 12 84 files changed, 2450 insertions(+), 378 deletions(-)
New commits: commit 6bc7cb38fcfa35bd5175e50eda94f02d44130a71 Merge: 2417946... 883be24... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:44:00 2010 -0400
Merge branch 'gwt-jay' into gwt
commit 883be246e15d72714fd72050405dfc60d861af41 Merge: c08d04c... 16f3c0a... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:43:33 2010 -0400
Merge branch 'master' into gwt-jay
commit 24179466a0ccf6b8d442a4c321eabac814f4bc40 Merge: 5848b67... c08d04c... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:41:39 2010 -0400
Merge branch 'gwt-jay' into gwt
commit 5848b67876495c2483f5c8f9f7088fbb4d49aede Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:41:28 2010 -0400
LT commit
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml index dfe7cd8..fd72919 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml @@ -1,125 +1,125 @@ -<?xml version="1.0"?> - -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:a4j="http://richfaces.org/a4j" - xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E - -<ui:composition template="/rhq/resource/layout/main.xhtml"> - - <ui:param name="pageTitle" value="Upload New Package"/> - <ui:param name="selectedTabName" value="Content.New"/> - <ui:define name="content"> - - <rich:panel id="fileUploadPanel"> - <f:facet name="header"> - <h:outputText value="Package File"/> - </f:facet> - - <h:panelGrid columns="1" width="100%" rendered="${ResourceUIBean.permissions.content}"> - rich:panel - <input type="button" - class="buttonmed" - value="UPLOAD FILE..." - onclick="javascript:open('/rhq/resource/content/file-upload.xhtml', 'uploadwin', 'titlebar=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=160,width=450')"/> - <rich:spacer width="5" /> - <h:outputText rendered="#{UploadNewPackageUIBean.fileUploaded}" - value="File Uploaded: #{UploadNewPackageUIBean.fileItem.fileName}"/> - </rich:panel> - </h:panelGrid> - - <h:outputText rendered="#{!ResourceUIBean.permissions.content}" - value="You do not have permissions to upload content"/> - - </rich:panel> - - <h:form id="uploadForm"> - <input type="hidden" name="id" value="${param.id}"/> - - <rich:panel rendered="#{CreateNewPackageUIBean.needRequestPackageDetails}"> - - <f:facet name="header">New Package Details</f:facet> - - <input type="hidden" name="newPackage" value="true"/> - - <table> - <tr> - <td align="right"><b>Name*</b></td> - <td align="left"><h:inputText value="#{CreateNewPackageUIBean.packageName}"/></td> - </tr> - <tr> - <td align="right"><b>Version*</b></td> - <td align="left"><h:inputText value="#{CreateNewPackageUIBean.version}"/></td> - </tr> - <tr> - <td align="right"><b>Architecture*</b></td> - <td align="left"> - <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedArchitectureId}"> - <f:selectItems value="#{CreateNewPackageUIBean.architectures}" /> - </h:selectOneMenu> - </td> - </tr> - <tr> - <td align="right"><b>Type*</b></td> - <td align="left"> - <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedPackageTypeId}"> - <f:selectItems value="#{CreateNewPackageUIBean.packageTypes}" /> - </h:selectOneMenu> - </td> - </tr> - </table> - - <div class="note-panel"><span class="required-marker-text">*</span><span> denotes a required field.</span></div> - - </rich:panel> - - rich:panel - +<?xml version="1.0"?> + +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E + +<ui:composition template="/rhq/resource/layout/main.xhtml"> + + <ui:param name="pageTitle" value="Upload New Package"/> + <ui:param name="selectedTabName" value="Content.New"/> + <ui:define name="content"> + + <rich:panel id="fileUploadPanel"> + <f:facet name="header"> + <h:outputText value="Package File"/> + </f:facet> + + <h:panelGrid columns="1" width="100%" rendered="${ResourceUIBean.permissions.content}"> + rich:panel + <input type="button" + class="buttonmed" + value="UPLOAD FILE..." + onclick="javascript:open('/rhq/resource/content/file-upload.xhtml', 'uploadwin', 'titlebar=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=160,width=450')"/> + <rich:spacer width="5" /> + <h:outputText rendered="#{UploadNewPackageUIBean.fileUploaded}" + value="File Uploaded: #{UploadNewPackageUIBean.fileItem.fileName}"/> + </rich:panel> + </h:panelGrid> + + <h:outputText rendered="#{!ResourceUIBean.permissions.content}" + value="You do not have permissions to upload content"/> + + </rich:panel> + + <h:form id="uploadForm"> + <input type="hidden" name="id" value="${param.id}"/> + + <rich:panel rendered="#{CreateNewPackageUIBean.needRequestPackageDetails}"> + + <f:facet name="header">New Package Details</f:facet> + + <input type="hidden" name="newPackage" value="true"/> + + <table> + <tr> + <td align="right"><b>Name*</b></td> + <td align="left"><h:inputText value="#{CreateNewPackageUIBean.packageName}"/></td> + </tr> + <tr> + <td align="right"><b>Version*</b></td> + <td align="left"><h:inputText value="#{CreateNewPackageUIBean.version}"/></td> + </tr> + <tr> + <td align="right"><b>Architecture*</b></td> + <td align="left"> + <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedArchitectureId}"> + <f:selectItems value="#{CreateNewPackageUIBean.architectures}" /> + </h:selectOneMenu> + </td> + </tr> + <tr> + <td align="right"><b>Type*</b></td> + <td align="left"> + <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedPackageTypeId}"> + <f:selectItems value="#{CreateNewPackageUIBean.packageTypes}" /> + </h:selectOneMenu> + </td> + </tr> + </table> + + <div class="note-panel"><span class="required-marker-text">*</span><span> denotes a required field.</span></div> + + </rich:panel> + + rich:panel + <f:facet name="header">Repository</f:facet> - + <p>Select one of the following options describing in which repository the new package should be created.</p> - + <input type="radio" name="repoOption" value="subscribed">Currently Subscribed Repository</input> - <rich:spacer width="5"/> + <rich:spacer width="5"/> <h:selectOneMenu value="#{CreateNewPackageUIBean.subscribedRepoId}"> <f:selectItems value="#{CreateNewPackageUIBean.subscribedRepos}" /> - </h:selectOneMenu> - <br/> + </h:selectOneMenu> + <br/> <input type="radio" name="repoOption" value="unsubscribed">Existing Repository</input> - <rich:spacer width="5"/> + <rich:spacer width="5"/> <h:selectOneMenu value="#{CreateNewPackageUIBean.unsubscribedRepoId}"> <f:selectItems value="#{CreateNewPackageUIBean.unsubscribedRepos}" /> - </h:selectOneMenu> - <br/> + </h:selectOneMenu> + <br/> <input type="radio" name="repoOption" value="new">New Repository</input> <rich:spacer width="5"/><h:inputText value="#{CreateNewPackageUIBean.newRepoName}"/> - - </rich:panel> - - <h:panelGrid id="buttonGrid" columns="2" styleClass="buttons-table" columnClasses="button-cell"> - - <h:commandButton style="margin-top: 10px;" value="CONTINUE" - action="#{CreateNewPackageUIBean.createPackage}" styleClass="buttonmed" - rendered="#{UploadNewPackageUIBean.fileUploaded}"/> - <h:commandButton style="margin-top: 10px;" value="CONTINUE" - disabled="true" styleClass="buttonmed-disabled" - rendered="#{!UploadNewPackageUIBean.fileUploaded}"/> - - <h:commandButton style="margin-top: 10px;" value="CANCEL" - action="#{CreateNewPackageUIBean.cancel}" styleClass="buttonmed"/> - - </h:panelGrid> - - </h:form> - - </ui:define> -</ui:composition> - -</html> + + </rich:panel> + + <h:panelGrid id="buttonGrid" columns="2" styleClass="buttons-table" columnClasses="button-cell"> + + <h:commandButton style="margin-top: 10px;" value="CONTINUE" + action="#{CreateNewPackageUIBean.createPackage}" styleClass="buttonmed" + rendered="#{UploadNewPackageUIBean.fileUploaded}"/> + <h:commandButton style="margin-top: 10px;" value="CONTINUE" + disabled="true" styleClass="buttonmed-disabled" + rendered="#{!UploadNewPackageUIBean.fileUploaded}"/> + + <h:commandButton style="margin-top: 10px;" value="CANCEL" + action="#{CreateNewPackageUIBean.cancel}" styleClass="buttonmed"/> + + </h:panelGrid> + + </h:form> + + </ui:define> +</ui:composition> + +</html>
commit c08d04c186c2346d097a93fdaf42d4a8de18e9bd Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:37:19 2010 -0400
Avoid Exception by ensuring param is passed. Protect against spaces in java exe path.
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat index 223c581..147e602 100644 --- a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat +++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat @@ -48,6 +48,15 @@ if "%RHQ_SERVER_DEBUG%" == "false" ( )
rem ---------------------------------------------------------------------- +rem Ensure password parameter is present +rem ---------------------------------------------------------------------- + +if /i "%1"=="" ( + echo Usage: %0 { plainTextPassword } + goto :done +) + +rem ---------------------------------------------------------------------- rem Change directory so the current directory is the Server home. rem ----------------------------------------------------------------------
@@ -86,7 +95,7 @@ if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" ( )
set _JB_DIR=%RHQ_SERVER_HOME%\jbossas -%RHQ_SERVER_JAVA_EXE_FILE_PATH% -cp %_JB_DIR%\lib\jboss-common.jar;%_JB_DIR%\lib\jboss-jmx.jar;%_JB_DIR%\server\default\lib\jbosssx.jar;%_JB_DIR%\server\default\lib\jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule %1 +"%RHQ_SERVER_JAVA_EXE_FILE_PATH%" -cp %_JB_DIR%\lib\jboss-common.jar;%_JB_DIR%\lib\jboss-jmx.jar;%_JB_DIR%\server\default\lib\jbosssx.jar;%_JB_DIR%\server\default\lib\jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule %1
goto :done
commit c8911e339f9c2a3723f16c59bb4a00ece8d15773 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:29:49 2010 -0400
give the server side bundle plugins their own profile to ensure they don't get omitted by -P!misc-plugins.
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml index 76ee0ee..6e999e2 100644 --- a/modules/plugins/pom.xml +++ b/modules/plugins/pom.xml @@ -111,6 +111,20 @@ </profile>
<profile> + <id>bundle-plugins</id> + <activation> + <property> + <name>java.home</name> + </property> + </activation> + + <modules> + <module>filetemplate-bundle</module> + <module>ant-bundle</module> + </modules> + </profile> + + <profile> <id>linux-plugins</id> <activation> <property> @@ -159,10 +173,6 @@ <module>perftest</module> <module>snmptrapd</module> <module>twitter</module> - - <!-- bundle plugins --> - <module>filetemplate-bundle</module> - <module>ant-bundle</module> </modules> </profile>
commit 2a9ef1e3581dff3c45da41fb19aa0ef7f1bfbc26 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 13:28:27 2010 -0400
fix import of PersistenceUtility
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java index 848a067..1bc9188 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java @@ -31,7 +31,7 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.stat.QueryStatistics; import org.hibernate.stat.Statistics;
-import org.rhq.core.domain.util.PersistenceUtility; +import org.rhq.core.server.PersistenceUtility;
/** * @author Joseph Marques
commit 16f3c0a4c268e8f8add9bf16f3bfdd49bd3fe71e Author: Ian P. Springer <ips@jetengine.(none)> Date: Wed Mar 31 12:47:39 2010 -0400
encrypt default DB password (cherry picked from commit 918c94ef5b633a025e96a503b55c4ef46536d948)
diff --git a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml index b9f4181..a7e313a 100644 --- a/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml +++ b/modules/enterprise/server/container/src/main/scripts/rhq-container.build.xml @@ -9,7 +9,8 @@ <property name="default.rhq.server.database.driver-class" value="org.postgresql.Driver" /> <property name="default.rhq.server.database.xa-datasource-class" value="org.postgresql.xa.PGXADataSource" /> <property name="default.rhq.server.database.user-name" value="rhqadmin" /> - <property name="default.rhq.server.database.password" value="rhqadmin" /> + <!-- NOTE: The below value is "rhqadmin" encrypted. --> + <property name="default.rhq.server.database.password" value="1eeb2f255e832171df8592078de921bc" /> <property name="default.rhq.server.database.type-mapping" value="PostgreSQL" /> <!-- these are needed for the PostgreSQL XADataSource setup --> <property name="default.rhq.server.database.server-name" value="127.0.0.1" />
commit 5c2344cfba3cd95f40d8f4f6fd4f0a2762d7778b Author: Heiko W. Rupp hwr@redhat.com Date: Wed Mar 31 17:32:58 2010 +0200
Revert navigation to the struts-based alert-configuration
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java index d35ed67..f134028 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/action/resource/common/monitor/alerts/config/PortalAction.java @@ -68,6 +68,11 @@ public class PortalAction extends ResourceController { keyMethodMap.setProperty("editConditions", "editDefinitionConditions"); keyMethodMap.setProperty("editControlAction", "editDefinitionControlAction");
+ keyMethodMap.setProperty("viewRoles", "viewDefinitionRoles"); + keyMethodMap.setProperty("viewUsers", "viewDefinitionUsers"); + + keyMethodMap.setProperty("addRoles", "addRolesDefinitions"); + keyMethodMap.setProperty("addUsers", "addUsersDefinitions"); }
@Override @@ -168,6 +173,34 @@ public class PortalAction extends ResourceController { }
+ + public ActionForward viewDefinitionRoles(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + setResource(request); + Portal portal = Portal.createPortal(); + setTitle(request, portal, "alert.config.platform.props.ViewDef.roles.Title"); + portal.addPortlet(new Portlet(".events.config.view.roles"), 1); + + // JW - this shouldn't be a dialog ... portal.setDialog(true); + request.setAttribute(Constants.PORTAL_KEY, portal); + + return null; + } + + public ActionForward viewDefinitionUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + setResource(request); + Portal portal = Portal.createPortal(); + setTitle(request, portal, "alert.config.platform.props.ViewDef.users.Title"); + portal.addPortlet(new Portlet(".events.config.view.users"), 1); + + // JW - this shouldn't be a dialog ... portal.setDialog(true); + request.setAttribute(Constants.PORTAL_KEY, portal); + + return null; + } + + public ActionForward monitorConfigureAlerts(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { setResource(request); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml index d18f2d4..a4a323e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml @@ -31,7 +31,7 @@ <form-bean name="AddRoleResourceGroupsForm" type="org.rhq.enterprise.gui.admin.role.AddResourceGroupsForm"/> <form-bean name="AddRoleLdapGroupsForm" - type="org.rhq.enterprise.gui.admin.role.AddLdapGroupsForm"/> + type="org.rhq.enterprise.gui.admin.role.AddLdapGroupsForm"/> <form-bean name="RemoveRoleResourceGroupsForm" type="org.rhq.enterprise.gui.admin.role.RemoveResourceGroupsForm"/> <!-- / --> @@ -573,7 +573,7 @@ <forward name="failure" path="/admin/role/RoleAdmin.do?mode=addLdapGroups"/> <forward name="success" path="/admin/role/RoleAdmin.do?mode=view"/> </action> - + <action path="/admin/role/RemoveLdapGroups" type="org.rhq.enterprise.gui.admin.role.RemoveLdapGroupsAction" name="RemoveRoleResourceGroupsForm" @@ -581,13 +581,13 @@ input="/admin/role/RoleAdmin.do?mode=view"> <forward name="failure" path="/admin/role/RoleAdmin.do?mode=view"/> <forward name="success" path="/admin/role/RoleAdmin.do?mode=view"/> - </action> + </action> +
- <!-- / -->
<action path="/admin/role/ChangeOwnerFormPrepare" @@ -2693,10 +2693,9 @@ <forward name="reset" path="/alerts/Config.do?mode=new" redirect="true"/> <forward name="failure" path="/alerts/Config.do?mode=new"/> + <forward name="success" path="/alerts/Config.do?mode=viewRoles"/> <forward name="add" path="/alerts/Config.do?mode=new"/> <forward name="remove" path="/alerts/Config.do?mode=new"/> - - <forward name="success" path="/rhq/resource/alert/viewAlert.xhtml" redirect="true" /> </action>
<action path="/alerts/EditPropertiesFormPrepare" @@ -2729,13 +2728,12 @@ name="EditAlertDefinitionConditionsForm" scope="request" input="/alerts/Config.do?mode=editConditions"> + <forward name="cancel" path="/alerts/Config.do?mode=viewRoles" redirect="true"/> <forward name="reset" path="/alerts/Config.do?mode=editConditions" redirect="true"/> + <forward name="success" path="/alerts/Config.do?mode=viewRoles" redirect="true"/> <forward name="failure" path="/alerts/Config.do?mode=editConditions"/> <forward name="add" path="/alerts/Config.do?mode=editConditions"/> <forward name="remove" path="/alerts/Config.do?mode=editConditions"/> - - <forward name="cancel" path="/rhq/resource/alert/viewAlert.xhtml" redirect="true" /> - <forward name="success" path="/rhq/resource/alert/viewAlert.xhtml" redirect="true" /> </action>
<action path="/alerts/EditControlActionFormPrepare" diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/events-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/events-def.xml index 53e1545..50286c0 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/events-def.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/events-def.xml @@ -107,6 +107,14 @@ path="/resource/common/monitor/alerts/ViewAlertNotificationsList.jsp"/>
+ <definition name=".events.alert.view.notifications.roles" + path="/resource/common/monitor/alerts/ViewAlertNotificationsRoles.jsp" + controllerUrl="/alerts/ViewNotificationsRoles.do"/> + + <definition name=".events.alert.view.notifications.users" + path="/resource/common/monitor/alerts/ViewAlertNotificationsUsers.jsp" + controllerUrl="/alerts/ViewNotificationsUsers.do"/> + <definition name=".events.alert.view.controlaction" path="/resource/common/monitor/alerts/config/ViewDefinitionControlAction.jsp" controllerUrl="/alerts/ViewControlAction.do"/> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinition.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinition.jsp index 3032dee..04b79f5 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinition.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/alerts/config/ViewDefinition.jsp @@ -18,12 +18,12 @@
<tiles:insert definition=".events.config.view.conditionsbox"/>
-<tiles:insert definition=".events.config.view.notifications"/> +<%--<tiles:insert definition=".events.config.view.notifications"/>--%>
-<tiles:insert definition=".events.config.view.controlactionbox"/> +<%--<tiles:insert definition=".events.config.view.controlactionbox"/>--%>
<tiles:insert definition=".events.config.view.nav"/>
-<a href="/rhq/resource/alert/notif/listAlertSender.xhtml?id=${param.id}&ad=${param.ad}">To Alert sender plugins</a> +<%--<a href="/rhq/resource/alert/notif/listAlertSender.xhtml?id=${param.id}&ad=${param.ad}">To Alert sender plugins</a>--%>
<tiles:insert definition=".page.footer"/> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml index 8f369b7..9565c0c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml @@ -64,7 +64,8 @@ </onc:sortableColumnHeader> </f:facet>
- <h:outputLink value="/rhq/resource/alert/viewAlert.xhtml"> + <h:outputLink value="/alerts/Config.do"> + <f:param name="mode" value="viewRoles"/> <f:param name="id" value="#{Resource.id}"/> <f:param name="ad" value="#{item.id}"/> <h:outputText value="#{item.name}" />
commit 613b7b2d8b09c5b3202b7bf7fc3460f5b76ffcde Merge: 788f917... 722cd2d... Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 10:36:16 2010 -0400
Merge branch 'master' into gwt-jay
commit 788f9174965433412e1f83155f941615f977b67c Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 31 10:36:08 2010 -0400
LT commit
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml index dfe7cd8..fd72919 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml @@ -1,125 +1,125 @@ -<?xml version="1.0"?> - -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:a4j="http://richfaces.org/a4j" - xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E - -<ui:composition template="/rhq/resource/layout/main.xhtml"> - - <ui:param name="pageTitle" value="Upload New Package"/> - <ui:param name="selectedTabName" value="Content.New"/> - <ui:define name="content"> - - <rich:panel id="fileUploadPanel"> - <f:facet name="header"> - <h:outputText value="Package File"/> - </f:facet> - - <h:panelGrid columns="1" width="100%" rendered="${ResourceUIBean.permissions.content}"> - rich:panel - <input type="button" - class="buttonmed" - value="UPLOAD FILE..." - onclick="javascript:open('/rhq/resource/content/file-upload.xhtml', 'uploadwin', 'titlebar=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=160,width=450')"/> - <rich:spacer width="5" /> - <h:outputText rendered="#{UploadNewPackageUIBean.fileUploaded}" - value="File Uploaded: #{UploadNewPackageUIBean.fileItem.fileName}"/> - </rich:panel> - </h:panelGrid> - - <h:outputText rendered="#{!ResourceUIBean.permissions.content}" - value="You do not have permissions to upload content"/> - - </rich:panel> - - <h:form id="uploadForm"> - <input type="hidden" name="id" value="${param.id}"/> - - <rich:panel rendered="#{CreateNewPackageUIBean.needRequestPackageDetails}"> - - <f:facet name="header">New Package Details</f:facet> - - <input type="hidden" name="newPackage" value="true"/> - - <table> - <tr> - <td align="right"><b>Name*</b></td> - <td align="left"><h:inputText value="#{CreateNewPackageUIBean.packageName}"/></td> - </tr> - <tr> - <td align="right"><b>Version*</b></td> - <td align="left"><h:inputText value="#{CreateNewPackageUIBean.version}"/></td> - </tr> - <tr> - <td align="right"><b>Architecture*</b></td> - <td align="left"> - <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedArchitectureId}"> - <f:selectItems value="#{CreateNewPackageUIBean.architectures}" /> - </h:selectOneMenu> - </td> - </tr> - <tr> - <td align="right"><b>Type*</b></td> - <td align="left"> - <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedPackageTypeId}"> - <f:selectItems value="#{CreateNewPackageUIBean.packageTypes}" /> - </h:selectOneMenu> - </td> - </tr> - </table> - - <div class="note-panel"><span class="required-marker-text">*</span><span> denotes a required field.</span></div> - - </rich:panel> - - rich:panel - +<?xml version="1.0"?> + +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E + +<ui:composition template="/rhq/resource/layout/main.xhtml"> + + <ui:param name="pageTitle" value="Upload New Package"/> + <ui:param name="selectedTabName" value="Content.New"/> + <ui:define name="content"> + + <rich:panel id="fileUploadPanel"> + <f:facet name="header"> + <h:outputText value="Package File"/> + </f:facet> + + <h:panelGrid columns="1" width="100%" rendered="${ResourceUIBean.permissions.content}"> + rich:panel + <input type="button" + class="buttonmed" + value="UPLOAD FILE..." + onclick="javascript:open('/rhq/resource/content/file-upload.xhtml', 'uploadwin', 'titlebar=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=160,width=450')"/> + <rich:spacer width="5" /> + <h:outputText rendered="#{UploadNewPackageUIBean.fileUploaded}" + value="File Uploaded: #{UploadNewPackageUIBean.fileItem.fileName}"/> + </rich:panel> + </h:panelGrid> + + <h:outputText rendered="#{!ResourceUIBean.permissions.content}" + value="You do not have permissions to upload content"/> + + </rich:panel> + + <h:form id="uploadForm"> + <input type="hidden" name="id" value="${param.id}"/> + + <rich:panel rendered="#{CreateNewPackageUIBean.needRequestPackageDetails}"> + + <f:facet name="header">New Package Details</f:facet> + + <input type="hidden" name="newPackage" value="true"/> + + <table> + <tr> + <td align="right"><b>Name*</b></td> + <td align="left"><h:inputText value="#{CreateNewPackageUIBean.packageName}"/></td> + </tr> + <tr> + <td align="right"><b>Version*</b></td> + <td align="left"><h:inputText value="#{CreateNewPackageUIBean.version}"/></td> + </tr> + <tr> + <td align="right"><b>Architecture*</b></td> + <td align="left"> + <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedArchitectureId}"> + <f:selectItems value="#{CreateNewPackageUIBean.architectures}" /> + </h:selectOneMenu> + </td> + </tr> + <tr> + <td align="right"><b>Type*</b></td> + <td align="left"> + <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedPackageTypeId}"> + <f:selectItems value="#{CreateNewPackageUIBean.packageTypes}" /> + </h:selectOneMenu> + </td> + </tr> + </table> + + <div class="note-panel"><span class="required-marker-text">*</span><span> denotes a required field.</span></div> + + </rich:panel> + + rich:panel + <f:facet name="header">Repository</f:facet> - + <p>Select one of the following options describing in which repository the new package should be created.</p> - + <input type="radio" name="repoOption" value="subscribed">Currently Subscribed Repository</input> - <rich:spacer width="5"/> + <rich:spacer width="5"/> <h:selectOneMenu value="#{CreateNewPackageUIBean.subscribedRepoId}"> <f:selectItems value="#{CreateNewPackageUIBean.subscribedRepos}" /> - </h:selectOneMenu> - <br/> + </h:selectOneMenu> + <br/> <input type="radio" name="repoOption" value="unsubscribed">Existing Repository</input> - <rich:spacer width="5"/> + <rich:spacer width="5"/> <h:selectOneMenu value="#{CreateNewPackageUIBean.unsubscribedRepoId}"> <f:selectItems value="#{CreateNewPackageUIBean.unsubscribedRepos}" /> - </h:selectOneMenu> - <br/> + </h:selectOneMenu> + <br/> <input type="radio" name="repoOption" value="new">New Repository</input> <rich:spacer width="5"/><h:inputText value="#{CreateNewPackageUIBean.newRepoName}"/> - - </rich:panel> - - <h:panelGrid id="buttonGrid" columns="2" styleClass="buttons-table" columnClasses="button-cell"> - - <h:commandButton style="margin-top: 10px;" value="CONTINUE" - action="#{CreateNewPackageUIBean.createPackage}" styleClass="buttonmed" - rendered="#{UploadNewPackageUIBean.fileUploaded}"/> - <h:commandButton style="margin-top: 10px;" value="CONTINUE" - disabled="true" styleClass="buttonmed-disabled" - rendered="#{!UploadNewPackageUIBean.fileUploaded}"/> - - <h:commandButton style="margin-top: 10px;" value="CANCEL" - action="#{CreateNewPackageUIBean.cancel}" styleClass="buttonmed"/> - - </h:panelGrid> - - </h:form> - - </ui:define> -</ui:composition> - -</html> + + </rich:panel> + + <h:panelGrid id="buttonGrid" columns="2" styleClass="buttons-table" columnClasses="button-cell"> + + <h:commandButton style="margin-top: 10px;" value="CONTINUE" + action="#{CreateNewPackageUIBean.createPackage}" styleClass="buttonmed" + rendered="#{UploadNewPackageUIBean.fileUploaded}"/> + <h:commandButton style="margin-top: 10px;" value="CONTINUE" + disabled="true" styleClass="buttonmed-disabled" + rendered="#{!UploadNewPackageUIBean.fileUploaded}"/> + + <h:commandButton style="margin-top: 10px;" value="CANCEL" + action="#{CreateNewPackageUIBean.cancel}" styleClass="buttonmed"/> + + </h:panelGrid> + + </h:form> + + </ui:define> +</ui:composition> + +</html>
commit 722cd2d5bef232d55e3f4c44cf822cd5e3612531 Merge: cffa6ea... 1282e2d... Author: Ian P. Springer <ips@jetengine.(none)> Date: Tue Mar 30 10:39:26 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 1282e2df1d35f8d6b3febeb1d03e8e6c007c9e5d Author: Heiko W. Rupp hwr@redhat.com Date: Tue Mar 30 14:20:50 2010 +0200
Revert navigation to the struts-based alert-configuration
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml index a9dd7b4..a28536b 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-navigation/alert-navigation.xml @@ -17,19 +17,19 @@
<navigation-case> <from-outcome>createNewAlertDefinition</from-outcome> - <to-view-id>/rhq/resource/alert/newAlert.xhtml?id=#{param.id}</to-view-id> + <to-view-id>/alerts/Config.do?id=#{param.id}&mode=new</to-view-id> <redirect/> </navigation-case> - + <navigation-case> - <!-- sorting rule --> + <!-- sorting rule --> <from-outcome>sort</from-outcome> <to-view-id>/rhq/resource/alert/listAlertDefinitions.xhtml?id=#{param.id}</to-view-id> <redirect/> - </navigation-case> - + </navigation-case> + </navigation-rule> - + <!-- Alert Templates List --> <navigation-rule> <from-view-id>/rhq/admin/listAlertTemplates.xhtml</from-view-id> @@ -46,16 +46,16 @@ <to-view-id>/alerts/Config.do?type=#{param.type}&mode=new</to-view-id> <redirect/> </navigation-case> - + <navigation-case> - <!-- sorting rule --> + <!-- sorting rule --> <from-outcome>sort</from-outcome> <to-view-id>/rhq/admin/listAlertTemplates.xhtml?type=#{param.type}</to-view-id> <redirect/> - </navigation-case> - + </navigation-case> + </navigation-rule> - + <!-- Alert History List --> <navigation-rule> <from-view-id>/rhq/resource/alert/listAlertHistory.xhtml</from-view-id> @@ -73,14 +73,14 @@ <to-view-id>/rhq/resource/alert/listAlertHistory.xhtml?id=#{param.id}</to-view-id> <redirect/> </navigation-case> - + <navigation-case> - <!-- sorting rule --> + <!-- sorting rule --> <from-outcome>sort</from-outcome> <to-view-id>/rhq/resource/alert/listAlertHistory.xhtml?id=#{param.id}</to-view-id> <redirect/> - </navigation-case> - + </navigation-case> + </navigation-rule>
<navigation-rule> @@ -89,7 +89,7 @@ <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/rhq/resource/alert/viewAlert.xhtml?ad=#{alertDefinition.id}&nid=#{alertNotificationsUIBean.activeNotification.id}</to-view-id> - + <redirect /> </navigation-case>
@@ -119,30 +119,4 @@
</navigation-rule>
- <navigation-rule> - <from-view-id>/rhq/resource/alert/listConditions.xhtml</from-view-id> - - <navigation-case> - <from-outcome>success</from-outcome> - <to-view-id>/rhq/resource/alert/viewAlert.xhtml?ad=#{alertDefinition.id}</to-view-id> - - <redirect /> - </navigation-case> - - </navigation-rule> - - <navigation-rule> - <from-view-id>/rhq/resource/alert/newAlert.xhtml</from-view-id> - - <navigation-case> - <from-outcome>success</from-outcome> - <to-view-id>/rhq/resource/alert/viewAlert.xhtml?ad=#{alertDefinition.id}</to-view-id> - - <redirect /> - </navigation-case> - - </navigation-rule> - - - </faces-config> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml index ef13121..8f369b7 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/listAlertDefinitions.xhtml @@ -108,8 +108,10 @@ <h:outputText styleClass="headerText" value="Parent" /> </f:facet>
- <h:outputLink value="http://localhost:7080/rhq/resource/alert/viewAlert.xhtml" rendered="#{item.parentId ne 0}"> + <h:outputLink value="/alerts/Config.do" rendered="#{item.parentId ne 0}"> + <f:param name="mode" value="viewRoles"/> <f:param name="type" value="#{item.resource.resourceType.id}"/> + <f:param name="from" value="#{item.id}"/> <f:param name="ad" value="#{item.parentId}"/> <h:outputText value="View Template" /> </h:outputLink>
commit cffa6eace4a2139bc89db5a23be3b657dbc708a1 Author: Ian P. Springer <ips@jetengine.(none)> Date: Mon Mar 29 11:31:53 2010 -0400
fix getServerRoot() so that if server root from httpd command line is a relative path, it will be resolved relative to the httpd process's cwd, not the cwd of the Agent process (see https://bugzilla.redhat.com/show_bug.cgi?id=536328) (cherry picked from commit 237ee88dbecd6809cefea82865bbe0b1d3b5582d)
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java index b87b3d6..95c2bfc 100644 --- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java +++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheServerDiscoveryComponent.java @@ -20,7 +20,6 @@ package org.rhq.plugins.apache;
import java.io.File; import java.io.IOException; -import java.net.InetAddress; import java.net.URI; import java.util.HashSet; import java.util.List; @@ -35,7 +34,6 @@ import org.jetbrains.annotations.Nullable; import org.rhq.augeas.AugeasProxy; import org.rhq.augeas.node.AugeasNode; import org.rhq.augeas.tree.AugeasTree; -import org.rhq.augeas.tree.AugeasTreeException; import org.rhq.augeas.util.Glob; import org.rhq.augeas.util.GlobFilter; import org.rhq.core.domain.configuration.Configuration; @@ -49,6 +47,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.pluginapi.inventory.ManualAddFacet; import org.rhq.core.pluginapi.util.FileUtils; import org.rhq.core.system.ProcessInfo; +import org.rhq.core.system.SystemInfoException; import org.rhq.plugins.apache.augeas.AugeasConfigurationApache; import org.rhq.plugins.apache.augeas.AugeasTreeBuilderApache; import org.rhq.plugins.apache.util.ApacheBinaryInfo; @@ -293,24 +292,51 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen
@Nullable private String getServerRoot(@NotNull ApacheBinaryInfo binaryInfo, @NotNull ProcessInfo processInfo) { + // First see if -d was specified on the httpd command line. String[] cmdLine = processInfo.getCommandLine(); String root = getCommandLineOption(cmdLine, "-d");
+ // If not, extract the path from the httpd binary. if (root == null) { root = binaryInfo.getRoot(); }
- if (root != null) { - root = FileUtils.getCanonicalPath(root); + if (root == null) { + // We have failed to determine the server root :( + return null; + } + + // If the path is relative, convert it to an absolute path, resolving it relative to the cwd of the httpd process. + File rootFile = new File(root); + if (!rootFile.isAbsolute()) { + String currentWorkingDir; + try { + currentWorkingDir = processInfo.getCurrentWorkingDirectory(); + } catch (Exception e) { + log.error("Unable to determine current working directory of Apache process [" + processInfo + + "], which is needed to determine the server root of the Apache instance.", e); + return null; + } + if (currentWorkingDir == null) { + log.error("Unable to determine current working directory of Apache process [" + processInfo + + "], which is needed to determine the server root of the Apache instance."); + return null; + } else { + rootFile = new File(currentWorkingDir, root); + root = rootFile.getPath(); + } }
+ // And finally canonicalize the path, but using our own getCanonicalPath() method, which preserves symlinks. + root = FileUtils.getCanonicalPath(root); + return root; }
@Nullable private File getServerConfigFile(ApacheBinaryInfo binaryInfo, ProcessInfo processInfo, String serverRoot) { - String[] cmdLine = processInfo.getCommandLine(); // First see if -f was specified on the httpd command line. + String[] cmdLine = processInfo.getCommandLine(); String serverConfigFile = getCommandLineOption(cmdLine, "-f");
// If not, extract the path from the httpd binary. @@ -330,7 +356,7 @@ public class ApacheServerDiscoveryComponent implements ResourceDiscoveryComponen serverConfigFile = file.getPath(); }
- // And now canonicalize the path, but using our own getCanonicalPath() method, which preserves symlinks. + // And finally canonicalize the path, but using our own getCanonicalPath() method, which preserves symlinks. serverConfigFile = FileUtils.getCanonicalPath(serverConfigFile);
return new File(serverConfigFile);
commit b0140c202e7cad66ebb0dcd779501797a6bd6390 Author: Heiko W. Rupp hwr@redhat.com Date: Mon Mar 29 14:16:28 2010 +0200
Fix definition of _JB_DIR variable
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat index 3b85102..223c581 100644 --- a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat +++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat @@ -85,7 +85,7 @@ if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" ( exit /B 1 )
-set _JB_DIR = %RHQ_SERVER_HOME%\jbossas +set _JB_DIR=%RHQ_SERVER_HOME%\jbossas %RHQ_SERVER_JAVA_EXE_FILE_PATH% -cp %_JB_DIR%\lib\jboss-common.jar;%_JB_DIR%\lib\jboss-jmx.jar;%_JB_DIR%\server\default\lib\jbosssx.jar;%_JB_DIR%\server\default\lib\jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule %1
commit 1e8fb58daad6cf30d410480714e8b3fe93e41551 Author: Heiko W. Rupp hwr@redhat.com Date: Fri Mar 26 14:29:48 2010 +0100
Fix an omission and clean up
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java index 3b47e95..6f6235a 100644 --- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java +++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java @@ -768,19 +768,13 @@ public class ConfigurationBean { Class clazz = SecureIdentityLoginModule.class; Method m = clazz.getDeclaredMethod("encode",String.class); m.setAccessible(true); - String res = (String) m.invoke(lm,"rhqadmin"); + String res = (String) m.invoke(lm,password); return res; } catch (Exception e) { throw new Exception("Encoding db password failed: " , e); } }
- private boolean isWindows() { - String osName = System.getProperty("os.name").toLowerCase(Locale.US); - - return osName.indexOf("windows") > -1; - } - private Properties getConfigurationAsProperties(List<PropertyItemWithValue> config) { Properties props = new Properties();
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java index 5af10d0..425dc01 100644 --- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java +++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java @@ -529,7 +529,7 @@ public class ServerInformation { return deployDirectory; }
- protected File getBinDirectory() { + private File getBinDirectory() { if (binDirectory == null) { MBeanServer mbs = getMBeanServer(); ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig");
commit a32db89465af384df8d30b3667f4f545d9893105 Merge: 9f3981b... 002b86a... Author: Heiko W. Rupp hwr@redhat.com Date: Fri Mar 26 13:50:03 2010 +0100
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 9f3981b21e128316ff39cbd5fe54e998e9002af4 Author: Heiko W. Rupp hwr@redhat.com Date: Fri Mar 26 13:49:55 2010 +0100
First cut of a Windows script to generate the passwords.
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat new file mode 100644 index 0000000..3b85102 --- /dev/null +++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.bat @@ -0,0 +1,112 @@ +@echo off + +rem =========================================================================== +rem RHQ Server Windows Generate db password script +rem +rem This file is used to execute the generate a new encrypted db password. +rem +rem This script is customizable by setting the following environment variables: +rem +rem RHQ_SERVER_DEBUG - If this is defined, the script will emit debug +rem messages. +rem If not set or set to "false", debug is turned off. +rem +rem RHQ_SERVER_HOME - Defines where the Server's home install directory is. +rem If not defined, it will be assumed to be the parent +rem directory of the directory where this script lives. +rem +rem RHQ_SERVER_JAVA_HOME - The location of the JRE that the Server will +rem use. This will be ignored if +rem RHQ_SERVER_JAVA_EXE_FILE_PATH is set. +rem If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are +rem not set, the Server's embedded JRE will be used. +rem +rem RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java +rem executable to use. If this is set, +rem RHQ_SERVER_JAVA_HOME is ignored. +rem If this is not set, then +rem %RHQ_SERVER_JAVA_HOME%\bin\java.exe +rem is used. If this and +rem RHQ_SERVER_JAVA_HOME are not set, the +rem Server's embedded JRE will be used. +rem +rem +rem Note that you cannot define custom Java VM parameters or command line +rem arguments to pass to the RHQ Server run.sh. If you wish to pass in +rem specific arguments, modify the rhq-server-wrapper.conf file. +rem +rem If the embedded JRE is to be used but is not available, the fallback +rem JRE to be used will be determined by the JAVA_HOME environment variable. +rem +rem =========================================================================== + +setlocal + +rem if debug variable is set, it is assumed to be on, unless its value is false +if "%RHQ_SERVER_DEBUG%" == "false" ( + set RHQ_SERVER_DEBUG= +) + +rem ---------------------------------------------------------------------- +rem Change directory so the current directory is the Server home. +rem ---------------------------------------------------------------------- + +set RHQ_SERVER_BIN_DIR_PATH=%~dp0 + +if not defined RHQ_SERVER_HOME ( + cd "%RHQ_SERVER_BIN_DIR_PATH%.." +) else ( + cd "%RHQ_SERVER_HOME%" || ( + echo Cannot go to the RHQ_SERVER_HOME directory: %RHQ_SERVER_HOME% + exit /B 1 + ) +) + +set RHQ_SERVER_HOME=%CD% + +if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_HOME: %RHQ_SERVER_HOME% + +rem ---------------------------------------------------------------------- +rem Find the Java executable and verify we have a VM available. +rem ---------------------------------------------------------------------- + +if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH ( + if not defined RHQ_SERVER_JAVA_HOME call :prepare_embedded_jre +) + +if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe + +if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME% +if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH% + +if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" ( + echo There is no JVM available. + echo Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately. + exit /B 1 +) + +set _JB_DIR = %RHQ_SERVER_HOME%\jbossas +%RHQ_SERVER_JAVA_EXE_FILE_PATH% -cp %_JB_DIR%\lib\jboss-common.jar;%_JB_DIR%\lib\jboss-jmx.jar;%_JB_DIR%\server\default\lib\jbosssx.jar;%_JB_DIR%\server\default\lib\jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule %1 + + +goto :done + +rem ---------------------------------------------------------------------- +rem CALL subroutine that prepares to use the embedded JRE +rem ---------------------------------------------------------------------- + +:prepare_embedded_jre +set RHQ_SERVER_JAVA_HOME=%RHQ_SERVER_HOME%\jre +if defined RHQ_SERVER_DEBUG echo Using the embedded JRE +if not exist "%RHQ_SERVER_JAVA_HOME%" ( + if defined RHQ_SERVER_DEBUG echo No embedded JRE found - will try to use JAVA_HOME: %JAVA_HOME% + set RHQ_SERVER_JAVA_HOME=%JAVA_HOME% +) +goto :eof + +rem ---------------------------------------------------------------------- +rem CALL subroutine that exits this script normally +rem ---------------------------------------------------------------------- + +:done +endlocal
commit 73626e4146d1acf382dca898748227475755afec Author: Heiko W. Rupp hwr@redhat.com Date: Fri Mar 26 13:42:37 2010 +0100
Fix comments
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh index c515e4c..d3fd715 100755 --- a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh +++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh @@ -6,20 +6,12 @@ # processname: java
# ============================================================================= -# RHQ Server UNIX Startup Script +# RHQ Server UNIX Generate db password script # -# This file is used to execute the RHQ Server on a UNIX platform as part of -# the platform's bootup sequence or as a foreground console process. -# Run this script without any command line options for the syntax help. +# This file is used to execute the generate a new encrypted db password. # # This script is customizable by setting the following environment variables: # -# Note that if this script is to be used as an init.d script, you must set -# RHQ_SERVER_HOME so this script knows where to find the Server installation. -# -# RHQ_SERVER_DEBUG - If this is defined, the script will emit debug -# messages. If this is not defined or set to "false" -# debug messages are not emitted. # # RHQ_SERVER_HOME - Defines where the server's home install directory is. # If not defined, it will be assumed to be the parent @@ -40,44 +32,9 @@ # RHQ_SERVER_JAVA_HOME are not set, the # Server's embedded JRE will be used. # -# RHQ_SERVER_JAVA_OPTS - Java VM command line options to be -# passed into the Server's VM. If this is not defined -# this script will pass in a default set of options. -# If this is set, it completely overrides the -# Server's defaults. If you only want to add options -# to the Server's defaults, then you will want to -# use RHQ_SERVER_ADDITIONAL_JAVA_OPTS instead. -# -# RHQ_SERVER_ADDITIONAL_JAVA_OPTS - additional Java VM command line options -# to be passed into the Server's VM. This -# is added to RHQ_SERVER_JAVA_OPTS; it -# is mainly used to augment the Server's -# default set of options. This can be -# left unset if it is not needed. -# -# RHQ_SERVER_CMDLINE_OPTS - If this is defined, these are the command line -# arguments that will be passed to the RHQ Server -# JBossAS run.sh. If you only want to add options -# to the Server's defaults, then you will want to -# use RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS instead. -# -# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS - additional command line arguments to -# be passed to the RHQ Server JBossAS -# run.sh. This is added to -# RHQ_SERVER_CMDLINE_OPTS; it is mainly -# used to augment the Server's default -# set of options. This can be left unset -# if it is not needed. -# -# RHQ_SERVER_PIDFILE_DIR - a full path to a writable directory where this -# script can write its pidfile to. -# If not defined, this defaults to the Server's -# bin directory. -# # If the embedded JRE is to be used but is not available, the fallback # JRE to be used will be determined by the JAVA_HOME environment variable. # -# This script calls run.sh when starting the underlying JBossAS server. # =============================================================================
# ---------------------------------------------------------------------- @@ -88,11 +45,6 @@ # RHQ_SERVER_DEBUG=true # JAVA_HOME=/path/to/java/installation # RHQ_SERVER_JAVA_EXE_FILE_PATH=/path/directly/to/java/executable -# RHQ_SERVER_JAVA_OPTS=VM options -# RHQ_SERVER_ADDITIONAL_JAVA_OPTS=additional VM options -# RHQ_SERVER_CMDLINE_OPTS=run.sh options -# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS=additional run.sh options - # ---------------------------------------------------------------------- # Make sure we unset any lingering JBossAS environment variables that # were set in the user's environment. This might happen if the user
commit ec5d610a0c9849073bba5547bd2464e0a7004796 Author: Heiko W. Rupp hwr@redhat.com Date: Fri Mar 26 12:34:23 2010 +0100
BZ 535601 - Optimize the generate password script
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh index 6c170b3..c515e4c 100755 --- a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh +++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh @@ -1,9 +1,213 @@ #!/bin/sh
-# the sleep is important to prevent a race condition when called from the installer -sleep 2 +# chkconfig: 2345 92 26 +# description: Starts and stops the RHQ Server +# +# processname: java
-# We stand in $RHQ/bin when called from the installer -cd ../jbossas/ +# ============================================================================= +# RHQ Server UNIX Startup Script +# +# This file is used to execute the RHQ Server on a UNIX platform as part of +# the platform's bootup sequence or as a foreground console process. +# Run this script without any command line options for the syntax help. +# +# This script is customizable by setting the following environment variables: +# +# Note that if this script is to be used as an init.d script, you must set +# RHQ_SERVER_HOME so this script knows where to find the Server installation. +# +# RHQ_SERVER_DEBUG - If this is defined, the script will emit debug +# messages. If this is not defined or set to "false" +# debug messages are not emitted. +# +# RHQ_SERVER_HOME - Defines where the server's home install directory is. +# If not defined, it will be assumed to be the parent +# directory of the directory where this script lives. +# +# RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will +# use. This will be ignored if +# RHQ_SERVER_JAVA_EXE_FILE_PATH is set. +# If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are +# not set, the Server's embedded JRE will be used. +# +# RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java +# executable to use. If this is set, +# RHQ_SERVER_JAVA_HOME is ignored. +# If this is not set, then +# $RHQ_SERVER_JAVA_HOME/bin/java +# is used. If this and +# RHQ_SERVER_JAVA_HOME are not set, the +# Server's embedded JRE will be used. +# +# RHQ_SERVER_JAVA_OPTS - Java VM command line options to be +# passed into the Server's VM. If this is not defined +# this script will pass in a default set of options. +# If this is set, it completely overrides the +# Server's defaults. If you only want to add options +# to the Server's defaults, then you will want to +# use RHQ_SERVER_ADDITIONAL_JAVA_OPTS instead. +# +# RHQ_SERVER_ADDITIONAL_JAVA_OPTS - additional Java VM command line options +# to be passed into the Server's VM. This +# is added to RHQ_SERVER_JAVA_OPTS; it +# is mainly used to augment the Server's +# default set of options. This can be +# left unset if it is not needed. +# +# RHQ_SERVER_CMDLINE_OPTS - If this is defined, these are the command line +# arguments that will be passed to the RHQ Server +# JBossAS run.sh. If you only want to add options +# to the Server's defaults, then you will want to +# use RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS instead. +# +# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS - additional command line arguments to +# be passed to the RHQ Server JBossAS +# run.sh. This is added to +# RHQ_SERVER_CMDLINE_OPTS; it is mainly +# used to augment the Server's default +# set of options. This can be left unset +# if it is not needed. +# +# RHQ_SERVER_PIDFILE_DIR - a full path to a writable directory where this +# script can write its pidfile to. +# If not defined, this defaults to the Server's +# bin directory. +# +# If the embedded JRE is to be used but is not available, the fallback +# JRE to be used will be determined by the JAVA_HOME environment variable. +# +# This script calls run.sh when starting the underlying JBossAS server. +# =============================================================================
-java -cp lib/jboss-common.jar:lib/jboss-jmx.jar:server/default/lib/jbosssx.jar:server/default/lib/jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule $* +# ---------------------------------------------------------------------- +# Environment variables you can set to customize the launch of the RHQ Server. +# ---------------------------------------------------------------------- + +# RHQ_SERVER_HOME=/path/to/server/home +# RHQ_SERVER_DEBUG=true +# JAVA_HOME=/path/to/java/installation +# RHQ_SERVER_JAVA_EXE_FILE_PATH=/path/directly/to/java/executable +# RHQ_SERVER_JAVA_OPTS=VM options +# RHQ_SERVER_ADDITIONAL_JAVA_OPTS=additional VM options +# RHQ_SERVER_CMDLINE_OPTS=run.sh options +# RHQ_SERVER_ADDITIONAL_CMDLINE_OPTS=additional run.sh options + +# ---------------------------------------------------------------------- +# Make sure we unset any lingering JBossAS environment variables that +# were set in the user's environment. This might happen if the user +# has an external JBossAS configured. +# ---------------------------------------------------------------------- + +unset JBOSS_HOME +unset RUN_CONF +unset JAVAC_JAR +unset JBOSS_CLASSPATH + +# ---------------------------------------------------------------------- +# Dumps a message iff debug mode is enabled +# ---------------------------------------------------------------------- + +debug_msg () +{ + # if debug variable is set, it is assumed to be on, unless its value is false + if [ "x$RHQ_SERVER_DEBUG" != "x" ]; then + if [ "$RHQ_SERVER_DEBUG" != "false" ]; then + echo $1 + fi + fi +} + + +# ---------------------------------------------------------------------- +# Determine what specific platform we are running on. +# Set some platform-specific variables. +# ---------------------------------------------------------------------- + +case "`uname`" in + CYGWIN*) _CYGWIN=true + ;; + Darwin*) _DARWIN=true + ;; + SunOS*) _SOLARIS=true + ;; + AIX*) _AIX=true + ;; +esac + +# ---------------------------------------------------------------------- +# Determine the RHQ Server installation directory. +# If RHQ_SERVER_HOME is not defined, we will assume we are running +# directly from the server installation's bin directory. +# ---------------------------------------------------------------------- + +if [ -z "$RHQ_SERVER_HOME" ]; then + _DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"` + RHQ_SERVER_HOME=`dirname "$_DOLLARZERO"`/.. +else + if [ ! -d "$RHQ_SERVER_HOME" ]; then + echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid directory" + echo "RHQ_SERVER_HOME: $RHQ_SERVER_HOME" + exit 1 + fi +fi + +cd "$RHQ_SERVER_HOME" +RHQ_SERVER_HOME=`pwd` + +debug_msg "RHQ_SERVER_HOME: $RHQ_SERVER_HOME" + +if [ ! -f "${RHQ_SERVER_HOME}/jbossas/bin/run.jar" ]; then + echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid RHQ Server" + echo "Missing ${RHQ_SERVER_HOME}/jbossas/bin/run.jar" + exit 1 +fi + +# ---------------------------------------------------------------------- +# if we are on a Mac and JAVA_HOME is not set, then set it to /usr +# as this is the default location. +# ---------------------------------------------------------------------- +if [ -z "$JAVA_HOME" ]; then + if [ -n "$_DARWIN" ]; then + debug_msg "Running on Mac OS X, setting JAVA_HOME to /usr" + JAVA_HOME=/usr + fi +fi + + +# ---------------------------------------------------------------------- +# Find the Java executable and verify we have a VM available +# ---------------------------------------------------------------------- + +if [ -z "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then + if [ -z "$RHQ_SERVER_JAVA_HOME" ]; then + RHQ_SERVER_JAVA_HOME="${RHQ_SERVER_HOME}/jre" + debug_msg "Using the embedded JRE" + if [ ! -d "$RHQ_SERVER_JAVA_HOME" ]; then + debug_msg "No embedded JRE found - will try to use JAVA_HOME: $JAVA_HOME" + RHQ_SERVER_JAVA_HOME="$JAVA_HOME" + fi + fi + debug_msg "RHQ_SERVER_JAVA_HOME: $RHQ_SERVER_JAVA_HOME" + RHQ_SERVER_JAVA_EXE_FILE_PATH="${RHQ_SERVER_JAVA_HOME}/bin/java" +fi +debug_msg "RHQ_SERVER_JAVA_EXE_FILE_PATH: $RHQ_SERVER_JAVA_EXE_FILE_PATH" + +if [ ! -f "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then + echo "There is no JVM available." + echo "Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately." + exit 1 +fi + +# run.sh will use JAVA as the full java command +JAVA="$RHQ_SERVER_JAVA_EXE_FILE_PATH" +export JAVA + +if [ $# == 0 ] +then + echo "Usage generate-db-password <password>" + exit 1 +fi + +_JB_DIR=${RHQ_SERVER_HOME}/jbossas +$JAVA -cp $_JB_DIR/lib/jboss-common.jar:$_JB_DIR/lib/jboss-jmx.jar:$_JB_DIR/server/default/lib/jbosssx.jar:$_JB_DIR/server/default/lib/jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule $*
commit 1cda39acf128b40df403e212469c8f683875d11e Author: Heiko W. Rupp hwr@redhat.com Date: Fri Mar 26 12:15:11 2010 +0100
BZ 535601 - encrypt the db password by default when installing the server.
diff --git a/modules/enterprise/gui/installer-war/pom.xml b/modules/enterprise/gui/installer-war/pom.xml index 6c9121b..b500fb1 100644 --- a/modules/enterprise/gui/installer-war/pom.xml +++ b/modules/enterprise/gui/installer-war/pom.xml @@ -25,7 +25,7 @@ <war.dir>${basedir}/target/${final.name}</war.dir>
<!-- plugin versions --> - <jetty-jspc-maven-plugin.version>7.0.1.v20091125</jetty-jspc-maven-plugin.version> + <jetty-jspc-maven-plugin.version>7.0.1.v20091125</jetty-jspc-maven-plugin.version>
<product.shortName>RHQ</product.shortName> <product.name>RHQ</product.name> @@ -90,6 +90,21 @@ </dependency>
<dependency> + <groupId>jboss</groupId> + <artifactId>jbosssx</artifactId> + <version>4.2.3.GA</version> + <scope>provided</scope> <!-- by JBossAS --> + </dependency> + + <dependency> + <groupId>jboss.jbossas.core-libs</groupId> + <artifactId>jboss-jca</artifactId> + <version>4.2.2.GA</version> + <scope>provided</scope> <!-- by JBossAS --> + </dependency> + + + <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java index bca6381..3b47e95 100644 --- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java +++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ConfigurationBean.java @@ -18,6 +18,12 @@ */ package org.rhq.enterprise.installer;
+import java.io.BufferedInputStream; +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.InetAddress; import java.sql.Connection; import java.sql.Statement; @@ -36,14 +42,16 @@ import mazz.i18n.Msg; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
+import org.jboss.resource.security.SecureIdentityLoginModule; + import org.rhq.core.db.DatabaseTypeFactory; import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.enterprise.installer.i18n.InstallerI18NResourceKeys;
/** - * Responisible for taking the settings the user selects in the installer window and saves them + * Responsible for taking the settings the user selects in the installer window and saves them * as the server's initial configuration. - * + * * @author John Mazzitelli * @author Jay Shaughnessy */ @@ -195,7 +203,7 @@ public class ConfigurationBean { * so the caller will not see any of the hidden properties in the returned list. * * @return current server settings, minus database related settings and hidden settings. - * + * * @see #getDatabaseConfiguration() * @see #getConfiguration() */ @@ -218,7 +226,7 @@ public class ConfigurationBean { * Loads in the server's current configuration and returns only the database related properties. * * @return current database settings - * + * * @see #getNonDatabaseConfiguration() * @see #getConfiguration() */ @@ -240,7 +248,7 @@ public class ConfigurationBean { * Checks to see if the server has been preconfigured and should be auto-installed. If <code>true</code> * is returned, the installer webapp should not be needed to install the server and the installer should * immediately begin the installation process. - * + * * @return <code>true</code> if auto-install should occur; <code>false</code> means the user needs to use * the installer GUI before the installation can begin */ @@ -475,7 +483,7 @@ public class ConfigurationBean { path = path.replace('\', '/'); // in case we are on windows, we still want forward slashes return path; } catch (Exception e) { - throw new RuntimeException(e); // this should never happen unless the file system is out of wack + throw new RuntimeException(e); // this should never happen unless the file system is out of wack } }
@@ -722,6 +730,17 @@ public class ConfigurationBean { // Ensure the install server info is up to date and stored in the DB serverInfo.storeServer(configurationAsProperties, haServer);
+ // encode database password and set updated properties + String pass = configurationAsProperties.getProperty(ServerProperties.PROP_DATABASE_PASSWORD); + pass = encryptPassword(pass); + configurationAsProperties.setProperty(ServerProperties.PROP_DATABASE_PASSWORD,pass); + + serverInfo.setServerProperties(configurationAsProperties); + + // We have changed the password of the database connection, so we need to + // tell the login config about it + serverInfo.restartLoginConfig(); + // build a keystore whose cert has a CN of this server's public endpoint address serverInfo.createKeystore(haServer);
@@ -739,6 +758,29 @@ public class ConfigurationBean { return StartPageResults.SUCCESS; }
+ private String encryptPassword(String password) throws Exception { + + // We need to do some mumbo jumbo, as the interesting method is private + // in SecureIdentityLoginModule + + try { + SecureIdentityLoginModule lm = new SecureIdentityLoginModule(); + Class clazz = SecureIdentityLoginModule.class; + Method m = clazz.getDeclaredMethod("encode",String.class); + m.setAccessible(true); + String res = (String) m.invoke(lm,"rhqadmin"); + return res; + } catch (Exception e) { + throw new Exception("Encoding db password failed: " , e); + } + } + + private boolean isWindows() { + String osName = System.getProperty("os.name").toLowerCase(Locale.US); + + return osName.indexOf("windows") > -1; + } + private Properties getConfigurationAsProperties(List<PropertyItemWithValue> config) { Properties props = new Properties();
@@ -839,7 +881,7 @@ public class ConfigurationBean {
this.haServerName = serverName;
- // try pulling info from the database for this server name + // try pulling info from the database for this server name if (isRegisteredServers()) { Properties configurationAsProperties = getConfigurationAsProperties(configuration); setHaServer(serverInfo.getServerDetail(configurationAsProperties, serverName)); @@ -881,10 +923,10 @@ public class ConfigurationBean { /** * This method will set the HA Server information based solely on the server configuration * properties. It does not rely on any database access. - * + * * This is used by the auto-installation process - see {@link AutoInstallServlet}. * - * @throws Exception + * @throws Exception */ public void setHaServerFromPropertiesOnly() throws Exception {
diff --git a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java index 0896ace..5af10d0 100644 --- a/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java +++ b/modules/enterprise/gui/installer-war/src/main/java/org/rhq/enterprise/installer/ServerInformation.java @@ -49,6 +49,8 @@ import org.apache.tools.ant.helper.ProjectHelper2;
import org.jboss.mx.util.MBeanServerLocator; import org.jboss.mx.util.ObjectNameFactory; +import org.jboss.security.auth.login.XMLLoginConfig; +import org.jboss.security.auth.login.XMLLoginConfigMBean; import org.jboss.system.server.ServerConfig;
import org.rhq.core.db.DatabaseType; @@ -128,7 +130,7 @@ public class ServerInformation {
/** * Call this when you need to confirm that the database is supported. - * + * * @param props set of properties where the connection information is found * * @throws Exception if the database is not supported @@ -208,7 +210,7 @@ public class ServerInformation { * data/tables and recreated.</p> * * @param props - * + * * @throws Exception if failed to create the new schema for some reason */ public void createNewDatabaseSchema(Properties props) throws Exception { @@ -246,7 +248,7 @@ public class ServerInformation { * occur.</p> * * @param props - * + * * @throws Exception if the upgrade failed for some reason */ public void upgradeExistingDatabaseSchema(Properties props) throws Exception { @@ -527,7 +529,7 @@ public class ServerInformation { return deployDirectory; }
- private File getBinDirectory() { + protected File getBinDirectory() { if (binDirectory == null) { MBeanServer mbs = getMBeanServer(); ObjectName name = ObjectNameFactory.create("jboss.system:type=ServerConfig"); @@ -788,8 +790,8 @@ public class ServerInformation { * Clean up messages in the JMS message table. Make sure you call this when no other Servers * are communicating with the database, otherwise, its possible in-flight messages will get lost * or go into a bad state. - * - * @param props + * + * @param props */ public void cleanJmsTables(Properties props) {
@@ -818,6 +820,17 @@ public class ServerInformation { } }
+ public void restartLoginConfig() throws Exception { + + MBeanServer mbs = getMBeanServer(); + ObjectName name = ObjectNameFactory.create("jboss.security:service=XMLLoginConfig"); + Object mbean = MBeanServerInvocationHandler.newProxyInstance(mbs, name,XMLLoginConfigMBean.class,false); + + XMLLoginConfigMBean conf = (XMLLoginConfigMBean) mbean; + conf.stop(); + conf.start(); + } + public static class Server { public static final String DEFAULT_AFFINITY_GROUP = ""; public static final int DEFAULT_ENDPOINT_PORT = 7080; diff --git a/modules/enterprise/server/container-lib/pom.xml b/modules/enterprise/server/container-lib/pom.xml index cd58ba5..2c98817 100644 --- a/modules/enterprise/server/container-lib/pom.xml +++ b/modules/enterprise/server/container-lib/pom.xml @@ -40,6 +40,13 @@ <scope>provided</scope> <!-- by JBossAS --> </dependency>
+ <dependency> + <groupId>jboss</groupId> + <artifactId>jbosssx</artifactId> + <version>4.2.3.GA</version> + <scope>provided</scope> <!-- by JBossAS --> + </dependency> + </dependencies>
<profiles> diff --git a/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java b/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java index 72083b5..3c87183 100644 --- a/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java +++ b/modules/enterprise/server/container-lib/src/main/java/org/rhq/jbossatx/jta/recovery/AppServerJDBCXARecovery.java @@ -23,11 +23,22 @@ import java.beans.PropertyEditorManager; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.lang.reflect.Method; +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.sql.Connection; import java.sql.SQLException; import java.util.Iterator; import java.util.Properties; - +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.SecretKeySpec; import javax.management.InstanceNotFoundException; import javax.management.MBeanException; import javax.management.MBeanServerConnection; @@ -42,12 +53,14 @@ import javax.transaction.xa.XAResource; import com.arjuna.ats.jta.recovery.XAResourceRecovery;
import org.jboss.logging.Logger; +import org.jboss.security.SecurityAssociation; +import org.jboss.security.SimplePrincipal;
/** * This is an enhanced version of JBossTM's AppServerJDBCXARecovery implementation. * The only thing this implementation does differently is it becomes tolerant of * the times when the data source is not yet deployed. - * + * * This provides recovery for compliant JDBC drivers accessed via datasources deployed in JBossAS 4.2 * It is not meant to be db driver specific. * @@ -100,6 +113,8 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery { if (parameter == null) return false;
+ retrieveData(parameter, _DELIMITER); + // don't create the datasource yet, we'll do it lazily. Just keep its id. _dataSourceId = parameter;
@@ -150,6 +165,13 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery { MBeanServerConnection server = (MBeanServerConnection) context.lookup("jmx/invoker/RMIAdaptor"); ObjectName objectName = new ObjectName("jboss.jca:name=" + _dataSourceId + ",service=ManagedConnectionFactory"); + + if(_username !=null && _password !=null) + { + SecurityAssociation.setPrincipal(new SimplePrincipal(_username)); + SecurityAssociation.setCredential(_password); + } + String className = (String) server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] { "XADataSourceClass" }, new String[] { "java.lang.String" }); log.debug("AppServerJDBCXARecovery datasource classname = " + className); @@ -158,6 +180,29 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery { // debug disabled due to security paranoia - it may log datasource password in cleartext. // log.debug("AppServerJDBCXARecovery.result="+properties);
+ ObjectName txCmObjectName = new ObjectName("jboss.jca:name=" +_dataSourceId + ",service=XATxCM"); + String securityDomainName = (String) server.getAttribute(txCmObjectName, "SecurityDomainJndiName"); + log.debug("Security domain name associated with JCA ConnectionManager jboss.jca:name=" +_dataSourceId + ",service=XATxCM"+" is:"+securityDomainName); + + if(securityDomainName != null && !securityDomainName.equals("")) + { + ObjectName _objectName = new ObjectName("jboss.security:service=XMLLoginConfig"); + String config = (String)server.invoke(_objectName, "displayAppConfig", new Object[] {securityDomainName}, new String[] {"java.lang.String"}); + String loginModuleClass = getValueForLoginModuleClass(config); + _dbUsername = getValueForKey(config, _USERNAME); + String _encryptedPassword = getValueForKey(config, _PASSWORD); + if (loginModuleClass.trim().equals("org.jboss.resource.security.SecureIdentityLoginModule")) + { + _dbPassword = new String (decode(_encryptedPassword)); + } + else if (loginModuleClass.trim().equals("org.jboss.resource.security.JaasSecurityDomainIdentityLoginModule")) + { + String jaasSecurityDomain = getValueForKey(config, "jaasSecurityDomain"); + _dbPassword = new String (decodePBE(server, _encryptedPassword, jaasSecurityDomain)); + } + _encrypted = true; + } + try { _dataSource = getXADataSource(className, properties); _supportsIsValidMethod = true; // assume it does; we'll lazily check the first time we try to connect @@ -230,7 +275,15 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery { } }
- _connection = _dataSource.getXAConnection(); + // Check if the password is encrypted, the criteria should be the existence of <security-domain>EncryptDBPassword</security-domain> + // in the -ds.xml file. + + if(!_encrypted) { + _connection = _dataSource.getXAConnection(); + } + else { + _connection = _dataSource.getXAConnection(_dbUsername, _dbPassword); + } _connection.addConnectionEventListener(_connectionEventListener); log.debug("Created new XAConnection"); } @@ -305,13 +358,98 @@ public class AppServerJDBCXARecovery implements XAResourceRecovery { return xads; }
+ public void retrieveData(String parameter,String delimiter) + { + StringTokenizer st = new StringTokenizer(parameter,delimiter); + while (st.hasMoreTokens()) + { + String data = st.nextToken(); + if(data.length()>9) + { + if(_USERNAME.equalsIgnoreCase(data.substring(0,8))) + { + _username =data.substring(9); + } + if(_PASSWORD.equalsIgnoreCase(data.substring(0,8))) + { + _password =data.substring(9); + } + if(_JNDINAME.equalsIgnoreCase(data.substring(0,8))) + { + _dataSourceId=data.substring(9); + } + } + } + + if(_dataSourceId == null && parameter != null && parameter.indexOf('=') == -1) { + // try to fallback to old parameter format where only the dataSourceId is given, without jndiname= prefix + _dataSourceId = parameter; + } + } + + private String getValueForKey(String config, String key) + { + Pattern usernamePattern = Pattern.compile("(name=" + key + ", value=)(.*)(</li>)"); + Matcher m = usernamePattern.matcher(config); + if(m.find()) + { + return m.group(2); + } + return ""; + } + + private String getValueForLoginModuleClass(String config) + { + Pattern usernamePattern = Pattern.compile("(" + _MODULE + ":)(.*)"); + Matcher m = usernamePattern.matcher(config); + if(m.find()) + { + return m.group(2); + } + return ""; + } + + private static String decode(String secret) throws NoSuchPaddingException, NoSuchAlgorithmException, + InvalidKeyException, BadPaddingException, IllegalBlockSizeException + { + byte[] kbytes = "jaas is the way".getBytes(); + SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish"); + + BigInteger n = new BigInteger(secret, 16); + byte[] encoding = n.toByteArray(); + + Cipher cipher = Cipher.getInstance("Blowfish"); + cipher.init(Cipher.DECRYPT_MODE, key); + byte[] decode = cipher.doFinal(encoding); + return new String(decode); + } + + private static String decodePBE(MBeanServerConnection server, String password, String jaasSecurityDomain) throws Exception + { + byte[] secret = (byte[]) server.invoke(new ObjectName(jaasSecurityDomain), "decode64", new Object[] {password}, new String[] {"java.lang.String"}); + return new String(secret, "UTF-8"); + } + + private boolean _supportsIsValidMethod;
private XAConnection _connection; private XADataSource _dataSource; private LocalConnectionEventListener _connectionEventListener; private boolean _hasMoreResources; + private boolean _encrypted;
private String _dataSourceId; + private String _username; + private String _password; + private String _dbUsername; + private String _dbPassword; + + private final String _JNDINAME = "jndiname"; + private final String _USERNAME = "username"; + private final String _PASSWORD = "password"; + private final String _MODULE = "LoginModule Class"; + private final String _DELIMITER = ","; + private Logger log = org.jboss.logging.Logger.getLogger(AppServerJDBCXARecovery.class); } diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh new file mode 100755 index 0000000..6c170b3 --- /dev/null +++ b/modules/enterprise/server/container/src/main/bin-resources/bin/generate-db-password.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# the sleep is important to prevent a race condition when called from the installer +sleep 2 + +# We stand in $RHQ/bin when called from the installer +cd ../jbossas/ + +java -cp lib/jboss-common.jar:lib/jboss-jmx.jar:server/default/lib/jbosssx.jar:server/default/lib/jboss-jca.jar org.jboss.resource.security.SecureIdentityLoginModule $* diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml index 256d419..8f6ca6d 100644 --- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml +++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/conf/login-config.xml @@ -14,6 +14,28 @@ </authentication> </application-policy>
+<!-- security domains for encrypted dataseouce passwords --> + <application-policy name = "XADSRealm"> + <authentication> + <login-module code = "org.jboss.resource.security.SecureIdentityLoginModule" + flag = "required"> + <module-option name = "username">${rhq.server.database.user-name}</module-option> + <module-option name = "password">${rhq.server.database.password}</module-option> + <module-option name = "managedConnectionFactoryName">jboss.jca:service=XATxCM,name=RHQDS</module-option> + </login-module> + </authentication> + </application-policy> + <application-policy name = "NONXADSRealm"> + <authentication> + <login-module code = "org.jboss.resource.security.SecureIdentityLoginModule" + flag = "required"> + <module-option name = "username">${rhq.server.database.user-name}</module-option> + <module-option name = "password">${rhq.server.database.password}</module-option> + <module-option name = "managedConnectionFactoryName">jboss.jca:service=NoTxCM,name=NoTxRHQDS</module-option> + </login-module> + </authentication> + </application-policy> + <!-- Security domain for JBossMQ --> <application-policy name = "jbossmq"> <authentication> diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej index e6f18ac..612e0c1 100644 --- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej +++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.h2.rej @@ -7,16 +7,14 @@ <xa-datasource> <jndi-name>RHQDS</jndi-name> <xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class> - <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property> - <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property> <xa-datasource-property name="URL">${rhq.server.database.connection-url}</xa-datasource-property>
<no-tx-separate-pools/> <track-connection-by-tx/> <isSameRM-override-value>false</isSameRM-override-value> + + <security-domain>XADSRealm</security-domain>
- <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>5</min-pool-size> <max-pool-size>50</max-pool-size> @@ -31,8 +29,7 @@ <jndi-name>NoTxRHQDS</jndi-name> <connection-url>${rhq.server.database.connection-url}</connection-url> <driver-class>${rhq.server.database.driver-class}</driver-class> - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> + <security-domain>NONXADSRealm</security-domain> <connection-property name="char.encoding">UTF-8</connection-property> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>2</min-pool-size> diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej index 2197386..5559b83 100644 --- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej +++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.oracle.rej @@ -7,8 +7,6 @@ <xa-datasource> <jndi-name>RHQDS</jndi-name> <xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class> - <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property> - <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property> <xa-datasource-property name="URL">${rhq.server.database.connection-url}</xa-datasource-property>
<xa-datasource-property name="ConnectionProperties">SetBigStringTryClob=true</xa-datasource-property> @@ -18,10 +16,10 @@ <!-- Checks the Oracle error codes and messages for fatal errors --> <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name> <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa --> - <track-connection-by-tx/> - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> + + <security-domain>XADSRealm</security-domain> + <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>5</min-pool-size> <max-pool-size>50</max-pool-size> @@ -43,8 +41,9 @@ <jndi-name>NoTxRHQDS</jndi-name> <connection-url>${rhq.server.database.connection-url}</connection-url> <driver-class>${rhq.server.database.driver-class}</driver-class> - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> + + <security-domain>NONXADSRealm</security-domain> + <connection-property name="char.encoding">UTF-8</connection-property> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>2</min-pool-size> diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej index 242bfce..2a71733 100644 --- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej +++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.postgres.rej @@ -7,15 +7,13 @@ <xa-datasource> <jndi-name>RHQDS</jndi-name> <xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class> - <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property> - <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property> <xa-datasource-property name="ServerName">${rhq.server.database.server-name}</xa-datasource-property> <xa-datasource-property name="PortNumber">${rhq.server.database.port}</xa-datasource-property> <xa-datasource-property name="DatabaseName">${rhq.server.database.db-name}</xa-datasource-property> + + <security-domain>XADSRealm</security-domain>
<track-connection-by-tx/> - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>5</min-pool-size> <max-pool-size>50</max-pool-size> @@ -30,8 +28,7 @@ <jndi-name>NoTxRHQDS</jndi-name> <connection-url>${rhq.server.database.connection-url}</connection-url> <driver-class>${rhq.server.database.driver-class}</driver-class> - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> + <security-domain>NONXADSRealm</security-domain> <connection-property name="char.encoding">UTF-8</connection-property> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>2</min-pool-size> diff --git a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej index 61ccc08..c79418f 100644 --- a/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej +++ b/modules/enterprise/server/container/src/main/resources/jbossas/server/default/deploy/rhq-ds.xml.sqlserver.rej @@ -7,8 +7,6 @@ <xa-datasource> <jndi-name>RHQDS</jndi-name> <xa-datasource-class>${rhq.server.database.xa-datasource-class}</xa-datasource-class> - <xa-datasource-property name="User">${rhq.server.database.user-name}</xa-datasource-property> - <xa-datasource-property name="Password">${rhq.server.database.password}</xa-datasource-property> <xa-datasource-property name="ServerName">${rhq.server.database.server-name}</xa-datasource-property> <xa-datasource-property name="PortNumber">${rhq.server.database.port}</xa-datasource-property> <xa-datasource-property name="DatabaseName">${rhq.server.database.db-name}</xa-datasource-property> @@ -24,9 +22,7 @@
<xa-datasource-property name="XaEmulation">true</xa-datasource-property> --> - - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> + <security-domain>XADSRealm</security-domain> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <min-pool-size>5</min-pool-size> <max-pool-size>50</max-pool-size> @@ -43,8 +39,7 @@ <jndi-name>NoTxRHQDS</jndi-name> <connection-url>${rhq.server.database.connection-url}</connection-url> <driver-class>${rhq.server.database.driver-class}</driver-class> - <user-name>${rhq.server.database.user-name}</user-name> - <password>${rhq.server.database.password}</password> + <security-domain>NONXADSRealm</security-domain>
<track-connection-by-tx></track-connection-by-tx>
commit 002b86ac0fc42f69e390a5f51ea104a7afbd8369 Author: Joseph Marques joseph@redhat.com Date: Fri Mar 26 03:13:34 2010 -0400
improve logging to capture some simple rules and thresholds to indicate performance issues
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java index 17247dc..22aaccb 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/common/framework/FaceletRedirectionViewHandler.java @@ -62,10 +62,27 @@ public class FaceletRedirectionViewHandler extends FaceletViewHandler { public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException { long monitorId = HibernatePerformanceMonitor.get().start(); super.renderView(context, viewToRender); - HibernatePerformanceMonitor.get().stop(monitorId, "URL " + viewToRender.getViewId()); + HibernatePerformanceMonitor.get().stop(monitorId, "URL " + getURL(viewToRender)); }
- protected void handleRnderException(FacesContext context, Exception ex) throws IOException, ELException, + private String getURL(UIViewRoot viewToRender) { + StringBuilder results = new StringBuilder(viewToRender.getViewId()); + + boolean first = true; + for (Map.Entry<String, Object> urlParam : viewToRender.getAttributes().entrySet()) { + if (first) { + results.append('?'); + } else { + results.append('&'); + } + results.append(urlParam.getKey() + "=" + urlParam.getValue()); + } + + return results.toString(); + } + + @Override + protected void handleRenderException(FacesContext context, Exception ex) throws IOException, ELException, FacesException { try { if (context.getViewRoot().getViewId().equals("/rhq/common/error.xhtml")) { diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java index 8b6c03c..6299947 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/WebUserTrackingFilter.java @@ -13,6 +13,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
import org.rhq.enterprise.gui.legacy.util.SessionUtils; +import org.rhq.enterprise.server.util.HibernatePerformanceMonitor;
public class WebUserTrackingFilter extends BaseFilter {
@@ -23,6 +24,8 @@ public class WebUserTrackingFilter extends BaseFilter { ServletException { HttpServletRequest request = (HttpServletRequest) req;
+ HibernatePerformanceMonitor.get().zeroStats(); + // only record GET requests, resubmitting to POST pages is dangerous String method = request.getMethod(); if (method.equals("GET")) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java index 1215cb0..848a067 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernatePerformanceMonitor.java @@ -18,14 +18,20 @@ */ package org.rhq.enterprise.server.util;
+import java.lang.management.ManagementFactory; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong;
+import javax.management.MBeanServer; import javax.persistence.EntityManager;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hibernate.stat.QueryStatistics; +import org.hibernate.stat.Statistics; + +import org.rhq.core.domain.util.PersistenceUtility;
/** * @author Joseph Marques @@ -45,6 +51,15 @@ public class HibernatePerformanceMonitor { return singleton; }
+ public void zeroStats() { + if (log.isDebugEnabled()) { + EntityManager entityManager = LookupUtil.getEntityManager(); + MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); + Statistics stats = PersistenceUtility.getStatisticsService(entityManager, platformMBeanServer); + stats.clear(); + } + } + public long start() { if (log.isDebugEnabled()) { EntityManager entityManager = LookupUtil.getEntityManager(); @@ -61,11 +76,38 @@ public class HibernatePerformanceMonitor { if (log.isDebugEnabled()) { HibernateStatisticsStopWatch watch = watches.remove(id); if (watch == null) { - // could happen if debugging was turned on and the start() call was already skipped - return; + return; // could happen if debugging was turned on and the start() call was already skipped } watch.stop(); - log.debug(watch.toString() + (logPrefix == null ? "(unknown)" : " for " + logPrefix + " ")); + + String cause = ""; + if (watch.getQueryExecutions() != 0) { + if ((watch.getConnects() / (double) (watch.getEntityLoads() + watch.getQueryExecutions())) >= 5.0) { + cause = "(N+1 issue?) ";// might indicate need for LEFT JOIN FETCHes + } + if ((watch.getTransations() / (double) watch.getQueryExecutions()) >= 5.0) { + cause = "(xaction nesting?) "; // might indicate excessive @REQUIRES_NEW + } else if (watch.getTransations() > 10) { + cause = "(too many xactions?"; + } + } + if (watch.getTime() > 3000) { + cause = "(slowness?) "; // might indicate inefficient query or table contention + } + + String callingContext = " for " + (logPrefix == null ? "(unknown)" : logPrefix); + log.debug(watch.toString() + cause + callingContext); + + if (logPrefix.contains("URL")) { + String[] queries = watch.getStats().getQueries(); + for (int i = 0; i < queries.length; i++) { + String query = queries[i]; + QueryStatistics queryStats = watch.getStats().getQueryStatistics(query); + log.debug("queryString[" + i + "]=" + queries[i]); + log.debug("queryStats[" + i + "=" + queryStats); + } + //watch.getStats().logSummary(); + } } }
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java index 5ca8470..7eb62da 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/HibernateStatisticsStopWatch.java @@ -34,10 +34,10 @@ public class HibernateStatisticsStopWatch {
private Statistics stats;
- long queryExecutions; - long transations; - long entityLoads; - long connects; + long queryExecutions; // Get global number of executed queries + long transations; // The number of transactions we know to have completed + long entityLoads; // Get global number of entity loads + long connects; // Get the global number of connections asked by the sessions long time;
public HibernateStatisticsStopWatch(EntityManager entityManager) { @@ -61,6 +61,30 @@ public class HibernateStatisticsStopWatch { time += System.currentTimeMillis(); }
+ public Statistics getStats() { + return stats; + } + + public long getQueryExecutions() { + return queryExecutions; + } + + public long getTransations() { + return transations; + } + + public long getEntityLoads() { + return entityLoads; + } + + public long getConnects() { + return connects; + } + + public long getTime() { + return time; + } + public String toString() { return "HibernateStats" // + "[ queries=" + queryExecutions //
commit d0d27d83e1e961d591b674e7c4a80e6adf2981e8 Author: Joseph Marques joseph@redhat.com Date: Fri Mar 26 03:11:37 2010 -0400
BZ 577109 - fix for partial-page requests not properly recovering from view exceptions
during the authentication action, test whether we've "bookmarked" an ajax request; if so, redirect to the URLs in the web user preferences stored by WebUserTrackingFilter;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java index 62e9518..c314189 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/authentication/AuthenticateUserAction.java @@ -145,6 +145,13 @@ public class AuthenticateUserAction extends TilesAction { if ((url == null) || url.equals("/Logout.do")) { url = URL_DASHBOARD; } + if (url.toLowerCase().indexOf("ajax") != -1) { + // we can't return to a URL that was a partial page request + // because the view no longer exists, and will blow up. + // instead, redirect back to the last saved URL + url = webUser.getWebPreferences().getLastVisitedURL(2); + System.out.println("Bypassing partial-page with " + url); + }
af = new ActionForward(url); }
commit bf2ad7ab6e9532e4869f4373712fcbc0c04f8618 Author: Simeon Pinder spinder@redhat.com Date: Wed Mar 24 05:04:01 2010 -0400
added null ptr check before retrieval for JSON population.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp index 093c943..61a7505 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp @@ -67,9 +67,11 @@
%> { "start" : "<%=sdf.format(new Date(installedPackage.getTimestamp()))%>", - "title" : "<%= (""+installedPackage.getPackageVersion().getDisplayName() + " " + installedPackage.getPackageVersion().getDisplayVersion()).replaceAll("["']","").trim()%>", + "title" : "<% out.write( + (installedPackage.getPackageVersion().getDisplayName()==null ? null : installedPackage.getPackageVersion().getDisplayName().replaceAll("["']","")) + " " + + (installedPackage.getPackageVersion().getDisplayVersion() ==null ? null : installedPackage.getPackageVersion().getDisplayVersion().replaceAll("["']","")));%>", "link" : "<%=link%>", - "description" : "<b>User:</b> <%= (""+installedPackage.getContentServiceRequest() == null ? "-Detected-" : installedPackage.getContentServiceRequest().getSubjectName()).replaceAll("["']","").trim()%><br/> <b>Version: <%= (""+installedPackage.getPackageVersion().getDisplayVersion()).replaceAll("["']","").trim()%></b> <br/><b>Status:</b> <%=(""+installedPackage.getStatus()).replaceAll("["']","").trim()%>", + "description" : "<b>User:</b> <% out.write((installedPackage.getContentServiceRequest() == null ? "-Detected- " : installedPackage.getContentServiceRequest().getSubjectName().replaceAll("["']","").trim())+"<br/> <b>Version: "+(installedPackage.getPackageVersion().getDisplayVersion() ==null ? null :installedPackage.getPackageVersion().getDisplayVersion().replaceAll("["']","").trim())+" </b> <br/><b>Status:</b> "+installedPackage.getStatus());%>", "icon" : "<%=icon%>", "color" : "<%=(installedPackage.getStatus() != InstalledPackageHistoryStatus.FAILED ? "#4EB84E" : "#DD5656")%>" }
commit 7002a02a713675e1deec633096094120838a6473 Author: Simeon Pinder spinder@redhat.com Date: Tue Mar 23 18:59:22 2010 -0400
added single and double quote removal code to *JSON jsps to guard against creating invalid runtime javascript
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp index 5cebe5d..2cc3da3 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventAlertJSON.jsp @@ -59,9 +59,9 @@ %>
{ "start" : "<%=sdf.format(new Date(alert.getCtime()))%>", - "title" : "<%=alert.getAlertDefinition().getName()%>", + "title" : "<%= (""+alert.getAlertDefinition().getName()).replaceAll("["']","").trim()%>", "link" : "<%=link%>", - "description" : "<%=buf.toString()%>", + "description" : "<%= (""+buf.toString()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(alert.getAlertDefinition().getPriority() == AlertPriority.LOW ? "#4EB84E" : "#DD5656")%>" } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp index b64cb55..6bb34c4 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventConfigJSON.jsp @@ -49,7 +49,7 @@ { "start" : "<%=sdf.format(configUpdate.getCreatedTime())%>", "title" : "Configuration Change", "link" : "<%=link%>", - "description" : "<b>User:</b> <%=configUpdate.getSubjectName()%><br/><b>Status:</b> <%=configUpdate.getStatus()%>", + "description" : "<b>User:</b> <%= (""+configUpdate.getSubjectName()).replaceAll("["']","").trim()%><br/><b>Status:</b> <%= (""+configUpdate.getStatus()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(configUpdate.getStatus() != ConfigurationUpdateStatus.FAILURE ? "#4EB84E" : "#DD5656")%>" } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp index ccb197b..093c943 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventContentJSON.jsp @@ -67,9 +67,9 @@
%> { "start" : "<%=sdf.format(new Date(installedPackage.getTimestamp()))%>", - "title" : "<%=installedPackage.getPackageVersion().getDisplayName() + " " + installedPackage.getPackageVersion().getDisplayVersion()%>", + "title" : "<%= (""+installedPackage.getPackageVersion().getDisplayName() + " " + installedPackage.getPackageVersion().getDisplayVersion()).replaceAll("["']","").trim()%>", "link" : "<%=link%>", - "description" : "<b>User:</b> <%= installedPackage.getContentServiceRequest() == null ? "-Detected-" : installedPackage.getContentServiceRequest().getSubjectName()%><br/> <b>Version: <%=installedPackage.getPackageVersion().getDisplayVersion()%></b> <br/><b>Status:</b> <%=installedPackage.getStatus()%>", + "description" : "<b>User:</b> <%= (""+installedPackage.getContentServiceRequest() == null ? "-Detected-" : installedPackage.getContentServiceRequest().getSubjectName()).replaceAll("["']","").trim()%><br/> <b>Version: <%= (""+installedPackage.getPackageVersion().getDisplayVersion()).replaceAll("["']","").trim()%></b> <br/><b>Status:</b> <%=(""+installedPackage.getStatus()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(installedPackage.getStatus() != InstalledPackageHistoryStatus.FAILED ? "#4EB84E" : "#DD5656")%>" } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp index 5e139db..46f3480 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventCreateDeleteChildJSON.jsp @@ -65,7 +65,7 @@ { "start" : "<%=sdf.format(entry.getCreatedTime())%>", "title" : "Child resource created", "link" : "<%=link%>", - "description" : "<b>User:</b> <%=entry.getSubjectName()%><br/><b>Status:</b> <%=entry.getStatus()%>", + "description" : "<b>User:</b> <%=(""+entry.getSubjectName()).replaceAll("["']","").trim()%><br/><b>Status:</b> <%=(""+entry.getStatus()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(entry.getStatus() != CreateResourceStatus.FAILURE ? "#4EB84E" : "#DD5656")%>" } @@ -101,7 +101,7 @@ { "start" : "<%=sdf.format(entry.getCreatedTime())%>", "title" : "Child resource deleted", "link" : "<%=link%>", - "description" : "<b>User:</b> <%=entry.getSubjectName()%><br/><b>Status:</b> <%=entry.getStatus()%>", + "description" : "<b>User:</b> <%=(""+entry.getSubjectName()).replaceAll("["']","").trim()%><br/><b>Status:</b> <%=(""+entry.getStatus()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(entry.getStatus() != DeleteResourceStatus.FAILURE ? "#4EB84E" : "#DD5656")%>" } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp index e575df5..87a791d 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventEventsJSON.jsp @@ -178,9 +178,9 @@ %>
{ "start" : "<%=sdf.format(event.getTimestamp())%>", - "title" : "<%= title%>", + "title" : "<%= (""+title).replaceAll("["']","").trim()%>", "link" : "<%=link%>", - "description" : "<%=detail%>", + "description" : "<%=(""+detail).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=color%>" } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp index d42c09c..0846050 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventOperationsJSON.jsp @@ -58,9 +58,9 @@ %>
{ "start" : "<%=sdf.format(new Date(operation.getCreatedTime()))%>", - "title" : "Operation: <%=operation.getOperationDefinition().getName()%>", + "title" : "Operation: <%=(""+operation.getOperationDefinition().getName()).replaceAll("["']","").trim()%>", "link" : "<%=link%>", - "description" : "<b>User:</b> <%=operation.getSubjectName()%><br/><b>Status:</b> <%=operation.getStatus()%>", + "description" : "<b>User:</b> <%=(""+operation.getSubjectName()).replaceAll("["']","").trim()%><br/><b>Status:</b> <%=(""+operation.getStatus()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(operation.getStatus() == OperationRequestStatus.SUCCESS ? "#4EB84E" : "#DD5656")%>" } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp index 9f8ce1d..06ff3aa 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/resource/common/monitor/events/EventPluginConfigJSON.jsp @@ -60,7 +60,7 @@ { "start" : "<%=sdf.format(configUpdate.getCreatedTime())%>", "title" : "Plugin Configuration Change", "link" : "<%=link%>", - "description" : "<b>User:</b> <%=configUpdate.getSubjectName()%><br/><b>Status:</b> <%=configUpdate.getStatus()%>", + "description" : "<b>User:</b> <%=(""+configUpdate.getSubjectName()).replaceAll("["']","").trim()%><br/><b>Status:</b> <%=(""+configUpdate.getStatus()).replaceAll("["']","").trim()%>", "icon" : "<%=icon%>", "color" : "<%=(configUpdate.getStatus() != ConfigurationUpdateStatus.FAILURE ? "#4EB84E" : "#DD5656")%>" }
commit 59ef9c778f809c2723d3764c8dcd5bdf7660f909 Merge: d6c56f6... eb64c17... Author: John Sanda jsanda@redhat.com Date: Tue Mar 23 11:43:37 2010 -0400
Merge branch 'master' into ldap
commit eb64c175e4653e92bb2d0128ec5abf930377c1a6 Merge: 4af7705... 79f695f... Author: Ian P. Springer <ips@jetengine.(none)> Date: Mon Mar 22 16:20:01 2010 -0400
Merge branch 'bugfixes'
commit 79f695ff4458919a8d6099a7fe6ba94518271d2a Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Mar 19 14:37:34 2010 -0400
add id's to executions, so we will be able to override those executions in descendant poms (cherry picked from commit 8f9b19320ccf5fb32b1c572f4d7d8c7d8a184a65)
diff --git a/pom.xml b/pom.xml index 0574c8e..6ab5dd6 100644 --- a/pom.xml +++ b/pom.xml @@ -531,9 +531,8 @@ </plugins> </pluginManagement>
- <plugins> -
+ <plugins>
<!-- Set the 'maven.version' property to the version of Maven being used, so we can include the Maven version in the MANIFEST.MF files of all @@ -614,8 +613,9 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> - <executions> + <executions> <execution> + <id>read-build-properties</id> <phase>process-resources</phase> <goals> <goal>read-project-properties</goal>
commit 6f189dd5afe53f5b9a41645dc41ac8b26bb35e50 Author: John Sanda jsanda@redhat.com Date: Mon Mar 22 13:35:13 2010 -0400
Adding profile for bugfixes branch to use in hudson build
diff --git a/etc/m2/settings-bugfixes.xml b/etc/m2/settings-bugfixes.xml new file mode 100644 index 0000000..b64aac6 --- /dev/null +++ b/etc/m2/settings-bugfixes.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--===== a sample Maven 2 user settings file for the RHQ build =====--> +<!-- See: http://maven.apache.org/settings.html --> +<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> + + <!-- + The below line can be uncommented if you want your local repo to be + in a more convenient location under Windows. + --> + <!--<localRepository>C:\.m2-repo</localRepository>--> + + <!-- + **************************** PROFILES **************************** + --> + + <!-- + See: + http://maven.apache.org/guides/introduction/introduction-to-profiles.html + and: http://docs.codehaus.org/display/MAVENUSER/Profiles + --> + + <activeProfiles> + <activeProfile>test.bugfixes</activeProfile> + </activeProfiles> + + <profiles> + <profile> + <!-- Profile to use to point test runs at a different db --> + <id>test.bugfixes</id> + <properties> + <rhq.test.ds.db-name>rhqbugfixes</rhq.test.ds.db-name> + <rhq.test.ds.connection-url>jdbc:postgresql://127.0.0.1:5432/rhqbugfixes</rhq.test.ds.connection-url> + <DatabaseTest.nofail>true</DatabaseTest.nofail> + + <!-- comm and agent config properties --> + <rhq.comm.test.connectorBindPort>98989</rhq.comm.test.connectorBindPort> + <rhq.comm.test.connector2BindPort>62628</rhq.comm.test.connector2BindPort> + <agent1.cfg.file>test-agent1-cfg-mvn.xml</agent1.cfg.file> + <agent2.cfg.file>test-agent2-cfg-mvn.xml</agent2.cfg.file> + <agent1.server.bind-port>55555</agent1.server.bind-port> + <agent2.server.bind-port>66666</agent2.server.bind-port> + <agent1.communications.connector.bind-port>33333</agent1.communications.connector.bind-port> + <agent2.communications.connector.bind-port>44444</agent2.communications.connector.bind-port> + </properties> + </profile> + </profiles> + <pluginGroups> + <!-- + This will allow you to invoke "org.rhq" Maven goals using the + "rhq" prefix + --> + <pluginGroup>org.rhq</pluginGroup> + </pluginGroups> +</settings>
commit 4af7705cf5e243aa8294820984df3bd8f8af9652 Author: Heiko W. Rupp hwr@redhat.com Date: Mon Mar 22 15:21:14 2010 +0100
BZ 571885 - If no notification templaes are defined, tell the user so and don't bomb out.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml index eec04d4..1c42245 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/alert/viewAlert.xhtml @@ -225,6 +225,7 @@ <h:form id="newNotificationsFromTemplateForm"> <input type="hidden" name="ad" value="${param.ad}"/>
+ <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size > 0}"> <div> <h:selectOneMenu id="templateList" value="#{definitionNotificationsUIBean.selectedTemplate}"> <f:selectItems value="#{definitionNotificationsUIBean.notificationTemplates}"/> @@ -243,11 +244,18 @@ styleClass="buttonmed" style="margin-top: auto;"> </h:commandButton> + </rich:panel> + + <rich:panel rendered="#{definitionNotificationsUIBean.notificationTemplates.size == 0}"> + No Alert Notification Templates have been defined yet.<br/> + Please create some in Administration -> System Configuration -> AlertNotification Templates + </rich:panel>
<h:outputLink id="alertTemplateCancelLink" styleClass="buttonmed" value="#" style="float: right; margin: 10px;"> <h:outputText value="Cancel" /> <rich:componentControl for="addAlertFromTemplatePanel" attachTo="alertTemplateCancelLink" operation="hide" event="onclick" /> </h:outputLink> + </h:form> </rich:modalPanel>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java index 15bf999..c8f66d0 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertNotificationManagerBean.java @@ -384,7 +384,8 @@ public class AlertNotificationManagerBean implements AlertNotificationManagerLoc try { template = (NotificationTemplate) q.getSingleResult(); } catch (NoResultException nre) { - throw new IllegalArgumentException("There is no template with name '" + templateName +"'"); + LOG.info("There is no alert notification template with name '" + templateName +"'"); + template = new NotificationTemplate("dummy",null); } return template; }
commit c3012c76bb86e12f72eba142b29570ceab05b4c1 Author: Heiko W. Rupp hwr@redhat.com Date: Mon Mar 22 14:36:36 2010 +0100
BZ 571911 - Fix acknowledge on the subsystem page.
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/ListAlertHistoryUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/ListAlertHistoryUIBean.java index 0b6023a..def7220 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/ListAlertHistoryUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/ListAlertHistoryUIBean.java @@ -179,7 +179,7 @@ public class ListAlertHistoryUIBean extends PagedDataTableUIBean { Integer[] alertIds = StringUtility.getIntegerArray(selectedAlerts);
try { - int num = alertManager.acknowledgeAlerts(subject,resource.getId(),alertIds); + int num = alertManager.acknowledgeAlerts(subject, alertIds); if (num==-1) FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN,"No Alerts passed to ack"); else diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertHistoryUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertHistoryUIBean.java index 0ad0c7a..b1db3e8 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertHistoryUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/subsystem/SubsystemAlertHistoryUIBean.java @@ -67,12 +67,12 @@ public class SubsystemAlertHistoryUIBean extends SubsystemView { private SelectItem[] categoryFilterItems;
private static final IntExtractor<AlertHistoryComposite> RESOURCE_ID_EXTRACTOR = new IntExtractor<AlertHistoryComposite>() { - + public int extract(AlertHistoryComposite object) { return object.getAlert().getAlertDefinition().getResource().getId(); } }; - + public SubsystemAlertHistoryUIBean() { datePattern = EnterpriseFacesContextUtility.getWebUser().getWebPreferences().getDateTimeDisplayPreferences() .getDateTimeFormatTrigger(); @@ -158,12 +158,11 @@ public class SubsystemAlertHistoryUIBean extends SubsystemView { public String acknowledgeSelectedAlerts() {
Subject subject = EnterpriseFacesContextUtility.getSubject(); - Resource resource = EnterpriseFacesContextUtility.getResource(); AlertManagerLocal alertManager = LookupUtil.getAlertManager();
try { Integer[] selectedItems = getSelectedItems(); - int num = alertManager.acknowledgeAlerts(subject,resource.getId(), selectedItems); + int num = alertManager.acknowledgeAlerts(subject, selectedItems); if (num==-1) FacesContextUtility.addMessage(FacesMessage.SEVERITY_WARN,"No Alerts passed to ack"); else @@ -243,7 +242,7 @@ public class SubsystemAlertHistoryUIBean extends SubsystemView { protected IntExtractor<AlertHistoryComposite> getResourceIdExtractor() { return RESOURCE_ID_EXTRACTOR; } - + private void getDataFromRequest() { SubsystemAlertHistoryUIBean outer = SubsystemAlertHistoryUIBean.this; outer.resourceFilter = FacesContextUtility.getOptionalRequestParameter(FORM_PREFIX + "resourceFilter"); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml index bf591c4..1f81df9 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/subsystem/alertHistory.xhtml @@ -200,7 +200,7 @@ value="PURGE ALL" styleClass="on-pager-button buttonsmall" rendered="#{GlobalPermissionsUIBean.superuser}" /> <onc:selectCommandButton action="#{SubsystemAlertHistoryUIBean.acknowledgeSelectedAlerts}" - value="ACKNOWLEDGE SELECTED" target="selectedAlerts" styleClass="on-pager-button buttonsmall" + value="ACKNOWLEDGE SELECTED" target="selectedItems" styleClass="on-pager-button buttonsmall" rendered="#{GlobalPermissionsUIBean.superuser}" />
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java index 0f48f9e..322a93c 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerBean.java @@ -566,14 +566,12 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote { * Acknowledge the alerts (that got fired) so that admins know who is working * on fixing the situation. * @param user calling user - * @param resourceId resource the alerts happened on * @param alertIds PKs of the alerts to ack * @return number of alerts acknowledged */ - public int acknowledgeAlerts(Subject user, int resourceId, Integer[] alertIds) { - if (!authorizationManager.hasResourcePermission(user, Permission.MANAGE_ALERTS, resourceId)) { - throw new PermissionException("User [" + user.getName() + "] does not have permissions to acknowledge alerts " - + "for resourceId=" + resourceId); + public int acknowledgeAlerts(Subject user, Integer[] alertIds) { + if (!authorizationManager.hasGlobalPermission(user, Permission.MANAGE_ALERTS)) { + throw new PermissionException("User [" + user.getName() + "] does not have permissions to acknowledge alerts "); }
int i=0; @@ -585,8 +583,11 @@ public class AlertManagerBean implements AlertManagerLocal, AlertManagerRemote { for (int id : alertIds) { acknowledgeAlert(id,user); i++; - if (i %20 == 0) + if (i % 50 == 0) { entityManager.flush(); + entityManager.clear(); + } + } return i; } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java index e482ffa..46e4b8e 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertManagerLocal.java @@ -122,11 +122,10 @@ public interface AlertManagerLocal { * Acknowledge the alerts (that got fired) so that admins know who is working * on fixing the situation. * @param user calling user - * @param resourceId resource the alerts happened on * @param alertIds PKs of the alerts to ack * @return number of alerts acknowledged */ - int acknowledgeAlerts(Subject user, int resourceId, Integer[] alertIds); + int acknowledgeAlerts(Subject user, Integer[] alertIds);
/** * Remove the alerts with the specified id's.
commit d0ac8f88594f6fab62ac3ade64cd278c07c38c48 Author: Heiko W. Rupp hwr@redhat.com Date: Mon Mar 22 12:13:36 2010 +0100
BZ 571968 - refresh list of templates after delete
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java index 19bc895..f384e3f 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/alert/NotificationTemplatesUIBean.java @@ -148,6 +148,9 @@ public class NotificationTemplatesUIBean implements Serializable { String summary = getDeletionSummary(numDeleted); FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, summary);
+ // Re-get the list of still existing templates + this.notificationTemplates = alertNotificationManager.listNotificationTemplates(this.subject); + return null; }
commit ba33dfa1d25f9f3e386e0f4e8124aa1654fa3a0e Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Mar 19 17:30:50 2010 -0400
fix file upload hanging by implementing workaround for https://jira.jboss.org/jira/browse/RF-8359; upgrade RichFaces from 3.3.2.GA to 3.3.3.CR1; create fileUpload.xhtml template that is shared by both file upload pages
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/fileUpload.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/fileUpload.xhtml new file mode 100644 index 0000000..b2b5aca --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/common/fileUpload.xhtml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> + +<ui:composition + template="/rhq/layout/popup.xhtml" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:fn="http://java.sun.com/jsp/jstl/functions" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.org/rich" + xmlns:onc="http://jboss.org/on/component%22%3E + + <ui:define name="body-area"> + + <rich:panel id="fileUploadPanel"> + <f:facet name="header"> + <h:outputText value="#{pageTitle}"/> + </f:facet> + + <h:panelGrid columns="1" width="100%"> + <h:form id="fileUploadForm" enctype="multipart/form-data"> + <rich:fileUpload + fileUploadListener="#{fileUploadUIBean.fileUploadListener}" + listHeight="60px" + maxFilesQuantity="1" + immediateUpload="false" + autoclear="false" + onuploadcomplete="javascript:window.opener.location.reload();window.close()" + allowFlash="false"> + </rich:fileUpload> + </h:form> + </h:panelGrid> + </rich:panel> + + </ui:define> + +</ui:composition> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml index dfe7cd8..fd72919 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/create.xhtml @@ -1,125 +1,125 @@ -<?xml version="1.0"?> - -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:a4j="http://richfaces.org/a4j" - xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E - -<ui:composition template="/rhq/resource/layout/main.xhtml"> - - <ui:param name="pageTitle" value="Upload New Package"/> - <ui:param name="selectedTabName" value="Content.New"/> - <ui:define name="content"> - - <rich:panel id="fileUploadPanel"> - <f:facet name="header"> - <h:outputText value="Package File"/> - </f:facet> - - <h:panelGrid columns="1" width="100%" rendered="${ResourceUIBean.permissions.content}"> - rich:panel - <input type="button" - class="buttonmed" - value="UPLOAD FILE..." - onclick="javascript:open('/rhq/resource/content/file-upload.xhtml', 'uploadwin', 'titlebar=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=160,width=450')"/> - <rich:spacer width="5" /> - <h:outputText rendered="#{UploadNewPackageUIBean.fileUploaded}" - value="File Uploaded: #{UploadNewPackageUIBean.fileItem.fileName}"/> - </rich:panel> - </h:panelGrid> - - <h:outputText rendered="#{!ResourceUIBean.permissions.content}" - value="You do not have permissions to upload content"/> - - </rich:panel> - - <h:form id="uploadForm"> - <input type="hidden" name="id" value="${param.id}"/> - - <rich:panel rendered="#{CreateNewPackageUIBean.needRequestPackageDetails}"> - - <f:facet name="header">New Package Details</f:facet> - - <input type="hidden" name="newPackage" value="true"/> - - <table> - <tr> - <td align="right"><b>Name*</b></td> - <td align="left"><h:inputText value="#{CreateNewPackageUIBean.packageName}"/></td> - </tr> - <tr> - <td align="right"><b>Version*</b></td> - <td align="left"><h:inputText value="#{CreateNewPackageUIBean.version}"/></td> - </tr> - <tr> - <td align="right"><b>Architecture*</b></td> - <td align="left"> - <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedArchitectureId}"> - <f:selectItems value="#{CreateNewPackageUIBean.architectures}" /> - </h:selectOneMenu> - </td> - </tr> - <tr> - <td align="right"><b>Type*</b></td> - <td align="left"> - <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedPackageTypeId}"> - <f:selectItems value="#{CreateNewPackageUIBean.packageTypes}" /> - </h:selectOneMenu> - </td> - </tr> - </table> - - <div class="note-panel"><span class="required-marker-text">*</span><span> denotes a required field.</span></div> - - </rich:panel> - - rich:panel - +<?xml version="1.0"?> + +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E + +<ui:composition template="/rhq/resource/layout/main.xhtml"> + + <ui:param name="pageTitle" value="Upload New Package"/> + <ui:param name="selectedTabName" value="Content.New"/> + <ui:define name="content"> + + <rich:panel id="fileUploadPanel"> + <f:facet name="header"> + <h:outputText value="Package File"/> + </f:facet> + + <h:panelGrid columns="1" width="100%" rendered="${ResourceUIBean.permissions.content}"> + rich:panel + <input type="button" + class="buttonmed" + value="UPLOAD FILE..." + onclick="javascript:open('/rhq/resource/content/file-upload.xhtml', 'uploadwin', 'titlebar=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,height=160,width=450')"/> + <rich:spacer width="5" /> + <h:outputText rendered="#{UploadNewPackageUIBean.fileUploaded}" + value="File Uploaded: #{UploadNewPackageUIBean.fileItem.fileName}"/> + </rich:panel> + </h:panelGrid> + + <h:outputText rendered="#{!ResourceUIBean.permissions.content}" + value="You do not have permissions to upload content"/> + + </rich:panel> + + <h:form id="uploadForm"> + <input type="hidden" name="id" value="${param.id}"/> + + <rich:panel rendered="#{CreateNewPackageUIBean.needRequestPackageDetails}"> + + <f:facet name="header">New Package Details</f:facet> + + <input type="hidden" name="newPackage" value="true"/> + + <table> + <tr> + <td align="right"><b>Name*</b></td> + <td align="left"><h:inputText value="#{CreateNewPackageUIBean.packageName}"/></td> + </tr> + <tr> + <td align="right"><b>Version*</b></td> + <td align="left"><h:inputText value="#{CreateNewPackageUIBean.version}"/></td> + </tr> + <tr> + <td align="right"><b>Architecture*</b></td> + <td align="left"> + <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedArchitectureId}"> + <f:selectItems value="#{CreateNewPackageUIBean.architectures}" /> + </h:selectOneMenu> + </td> + </tr> + <tr> + <td align="right"><b>Type*</b></td> + <td align="left"> + <h:selectOneMenu value="#{CreateNewPackageUIBean.selectedPackageTypeId}"> + <f:selectItems value="#{CreateNewPackageUIBean.packageTypes}" /> + </h:selectOneMenu> + </td> + </tr> + </table> + + <div class="note-panel"><span class="required-marker-text">*</span><span> denotes a required field.</span></div> + + </rich:panel> + + rich:panel + <f:facet name="header">Repository</f:facet> - + <p>Select one of the following options describing in which repository the new package should be created.</p> - + <input type="radio" name="repoOption" value="subscribed">Currently Subscribed Repository</input> - <rich:spacer width="5"/> + <rich:spacer width="5"/> <h:selectOneMenu value="#{CreateNewPackageUIBean.subscribedRepoId}"> <f:selectItems value="#{CreateNewPackageUIBean.subscribedRepos}" /> - </h:selectOneMenu> - <br/> + </h:selectOneMenu> + <br/> <input type="radio" name="repoOption" value="unsubscribed">Existing Repository</input> - <rich:spacer width="5"/> + <rich:spacer width="5"/> <h:selectOneMenu value="#{CreateNewPackageUIBean.unsubscribedRepoId}"> <f:selectItems value="#{CreateNewPackageUIBean.unsubscribedRepos}" /> - </h:selectOneMenu> - <br/> + </h:selectOneMenu> + <br/> <input type="radio" name="repoOption" value="new">New Repository</input> <rich:spacer width="5"/><h:inputText value="#{CreateNewPackageUIBean.newRepoName}"/> - - </rich:panel> - - <h:panelGrid id="buttonGrid" columns="2" styleClass="buttons-table" columnClasses="button-cell"> - - <h:commandButton style="margin-top: 10px;" value="CONTINUE" - action="#{CreateNewPackageUIBean.createPackage}" styleClass="buttonmed" - rendered="#{UploadNewPackageUIBean.fileUploaded}"/> - <h:commandButton style="margin-top: 10px;" value="CONTINUE" - disabled="true" styleClass="buttonmed-disabled" - rendered="#{!UploadNewPackageUIBean.fileUploaded}"/> - - <h:commandButton style="margin-top: 10px;" value="CANCEL" - action="#{CreateNewPackageUIBean.cancel}" styleClass="buttonmed"/> - - </h:panelGrid> - - </h:form> - - </ui:define> -</ui:composition> - -</html> + + </rich:panel> + + <h:panelGrid id="buttonGrid" columns="2" styleClass="buttons-table" columnClasses="button-cell"> + + <h:commandButton style="margin-top: 10px;" value="CONTINUE" + action="#{CreateNewPackageUIBean.createPackage}" styleClass="buttonmed" + rendered="#{UploadNewPackageUIBean.fileUploaded}"/> + <h:commandButton style="margin-top: 10px;" value="CONTINUE" + disabled="true" styleClass="buttonmed-disabled" + rendered="#{!UploadNewPackageUIBean.fileUploaded}"/> + + <h:commandButton style="margin-top: 10px;" value="CANCEL" + action="#{CreateNewPackageUIBean.cancel}" styleClass="buttonmed"/> + + </h:panelGrid> + + </h:form> + + </ui:define> +</ui:composition> + +</html> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/file-upload.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/file-upload.xhtml index 9745ebc..2f3386c 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/file-upload.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/content/file-upload.xhtml @@ -1,40 +1,19 @@ <?xml version="1.0"?>
-<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<ui:composition + template="/rhq/common/fileUpload.xhtml" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:fn="http://java.sun.com/jsp/jstl/functions" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.org/rich" + xmlns:onc="http://jboss.org/on/component%22%3E
-<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" - xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E + <ui:param name="pageTitle" value="Package File Upload"/> + <ui:param name="fileUploadUIBean" value="#{UploadNewPackageUIBean}"/>
- <ui:composition template="/rhq/layout/popup.xhtml"> - <ui:param name="pageTitle" value="Package File Upload"/> - - <ui:define name="body-area"> - <rich:panel id="fileUploadPanel"> - <f:facet name="header"> - <h:outputText value="Package File Upload"/> - </f:facet> - - <h:panelGrid columns="1" width="100%"> - <rich:fileUpload - id="contentUpload" - fileUploadListener="#{UploadNewPackageUIBean.fileUploadListener}" - listHeight="60px" - maxFilesQuantity="1" - immediateUpload="false" - autoclear="false" - onuploadcomplete="javascript:window.opener.location.reload();window.close()" - allowFlash="false"> - </rich:fileUpload> - </h:panelGrid> - </rich:panel> - </ui:define> - </ui:composition> -</html>
+</ui:composition> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/inventory/create-file-upload.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/inventory/create-file-upload.xhtml index 12ab23c..4074817 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/inventory/create-file-upload.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/inventory/create-file-upload.xhtml @@ -1,40 +1,18 @@ <?xml version="1.0"?>
-<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:ui="http://java.sun.com/jsf/facelets" - xmlns:c="http://java.sun.com/jstl/core" - xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" - xmlns:rich="http://richfaces.ajax4jsf.org/rich%22%3E - - <ui:composition template="/rhq/layout/popup.xhtml"> - <ui:param name="pageTitle" value="New Child Resource Package File Upload"/> - - <ui:define name="body-area"> - <rich:panel id="fileUploadPanel"> - <f:facet name="header"> - <h:outputText value="New Child Resource Package File Upload"/> - </f:facet> - - <h:panelGrid columns="1" width="100%"> - <rich:fileUpload - id="contentUpload" - fileUploadListener="#{UploadNewChildPackageUIBean.fileUploadListener}" - listHeight="60px" - maxFilesQuantity="1" - immediateUpload="false" - autoclear="false" - onuploadcomplete="javascript:window.opener.location.reload();window.close()" - allowFlash="false"> - </rich:fileUpload> - </h:panelGrid> - </rich:panel> - </ui:define> - </ui:composition> -</html> +<ui:composition + template="/rhq/common/fileUpload.xhtml" + xmlns="http://www.w3.org/1999/xhtml" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:fn="http://java.sun.com/jsp/jstl/functions" + xmlns:a4j="http://richfaces.org/a4j" + xmlns:rich="http://richfaces.org/rich" + xmlns:onc="http://jboss.org/on/component%22%3E
+ <ui:param name="pageTitle" value="New Child Resource Package File Upload"/> + <ui:param name="fileUploadUIBean" value="#{UploadNewChildPackageUIBean}"/> + +</ui:composition> diff --git a/pom.xml b/pom.xml index e2cc42b..0574c8e 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ <postgresql.version>8.4-701.jdbc3</postgresql.version> <h2.version>1.1.117</h2.version> <jtds.version>1.2.2</jtds.version> - <richfaces.version>3.3.2.GA</richfaces.version> + <richfaces.version>3.3.3.CR1</richfaces.version> <jline.version>0.9.94</jline.version> <sigar.version>1.6.3.82</sigar.version> <quartz.version>1.6.5</quartz.version>
commit d49f3d1ce688cdfff563a1f78c66b1a516b8ccc3 Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Mar 19 15:10:45 2010 -0400
...
diff --git a/pom.xml b/pom.xml index 1a21ab1..054740c 100644 --- a/pom.xml +++ b/pom.xml @@ -587,7 +587,7 @@ </executions> </plugin>
- <plugin> + <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> @@ -608,7 +608,7 @@ </configuration> </execution> </executions> - </plugin> + </plugin>
<plugin> <groupId>org.codehaus.mojo</groupId>
commit 8f9b19320ccf5fb32b1c572f4d7d8c7d8a184a65 Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Mar 19 14:37:34 2010 -0400
add id's to executions, so we will be able to override those executions in descendant poms
diff --git a/pom.xml b/pom.xml index e2cc42b..1a21ab1 100644 --- a/pom.xml +++ b/pom.xml @@ -531,9 +531,8 @@ </plugins> </pluginManagement>
- <plugins> -
+ <plugins>
<!-- Set the 'maven.version' property to the version of Maven being used, so we can include the Maven version in the MANIFEST.MF files of all @@ -614,8 +613,9 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> - <executions> + <executions> <execution> + <id>read-build-properties</id> <phase>process-resources</phase> <goals> <goal>read-project-properties</goal>
commit 02f669162cdd6204c1fca900a76633ca2893ae8d Merge: 6114257... eb23f6f... Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Mar 19 13:50:56 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 8b08316ae6df640c4e98ace945c4b5ce165cd5ae Author: John Sanda jsanda@redhat.com Date: Fri Mar 19 13:20:07 2010 -0400
Removing old, commented out code
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java index 0359594..2c28af9 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java @@ -54,7 +54,6 @@ import org.rhq.core.domain.configuration.definition.PropertySimpleType; */ public abstract class ConfigurationMaskingUtility {
-// private static final String MASKED_PROPERTY_VALUE = "\u0002MASKED\u0003"; private static final String MASKED_PROPERTY_VALUE = "___MASKED___";
/**
commit 8c0ccb0c56b0936dd483663b38e116bbb51c37f8 Merge: 5b5bf03... f988b47... Author: John Sanda jsanda@redhat.com Date: Fri Mar 19 12:41:26 2010 -0400
Merge branch 'bugfixes' of ssh://git.fedorahosted.org/git/rhq/rhq into bugfixes
commit 5b5bf037d6630d144108a59f5df55a3a271c7083 Author: John Sanda jsanda@redhat.com Date: Fri Mar 19 12:36:52 2010 -0400
Changing the masked property value since the unicode chars were getting stripped off
Password fields were masked with a value of "\u0002MASKED\u0003" prior to being rendered. When the form is submitted though, the password property has the unicode characters stripped off which in turn resulted in the password property not getting unmasked.
I stumbled onto this when updating the connection properties for a jboss server and I realized that the value for the credentials property was getting lost.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java index 718b06c..0359594 100644 --- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java +++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigurationMaskingUtility.java @@ -54,7 +54,8 @@ import org.rhq.core.domain.configuration.definition.PropertySimpleType; */ public abstract class ConfigurationMaskingUtility {
- private static final String MASKED_PROPERTY_VALUE = "\u0002MASKED\u0003"; +// private static final String MASKED_PROPERTY_VALUE = "\u0002MASKED\u0003"; + private static final String MASKED_PROPERTY_VALUE = "___MASKED___";
/** * Mask the values of all simple properties of type PASSWORD in the configuration. The configuration does not
commit 6114257b990eaebd93ab552ae6ea621415099dbe Author: Ian P. Springer <ips@jetengine.(none)> Date: Thu Mar 18 18:31:34 2010 -0400
fix content source sync so status of successfully completed requests gets flipped from INPROGRESS to SUCCESS; also improve results message for sync requests
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java index ab2fad2..4e078aa 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/content/RepoManagerBean.java @@ -394,8 +394,8 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
// Import groups first List<RepoGroupDetails> repoGroups = report.getRepoGroups(); - int repoGroupCounter = 0;
+ List<RepoGroupDetails> importedRepoGroups = new ArrayList<RepoGroupDetails>(); for (RepoGroupDetails createMe : repoGroups) { String name = createMe.getName();
@@ -411,7 +411,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { // but be sure to mention it to the report try { createRepoGroup(subject, existingGroup); - repoGroupCounter++; + importedRepoGroups.add(createMe); } catch (RepoException e) {
if (e.getType() == RepoException.RepoExceptionType.NAME_ALREADY_EXISTS) { @@ -424,7 +424,13 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { } } } - result.append("Imported [").append(repoGroupCounter).append("] repo groups.").append('\n'); + + if (importedRepoGroups.isEmpty()) { + result.append("There are new repo groups since the last time this content source was synchronized.\n"); + } else { + result.append("Imported the following [").append(importedRepoGroups.size()).append("] repo group(s): "). + append(importedRepoGroups).append('\n'); + }
// Hold on to all current candidate repos for the content provider. If any were not present in this // report, remove them from the system (the rationale being, the content provider no longer knows @@ -437,19 +443,18 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
// Once the groups are in the system, import any repos that were added List<RepoDetails> repos = report.getRepos(); - int repoCounter = 0;
// First add repos that have no parent. We later add repos with a parent afterwards to prevent // issues where both the parent and child are specified in this report. + List<RepoDetails> importedRepos = new ArrayList<RepoDetails>(); for (RepoDetails createMe : repos) { - if (createMe.getParentRepoName() == null) { try { - addCandidateRepo(contentSourceId, createMe); + if (addCandidateRepo(contentSourceId, createMe)) { + importedRepos.add(createMe); + } removeRepoFromList(createMe.getName(), candidatesForThisProvider); - repoCounter++; } catch (Exception e) { - if (e instanceof RepoException && ((RepoException) e).getType() == RepoException.RepoExceptionType.NAME_ALREADY_EXISTS) { result.append("Skipping addition of existing repo [").append(createMe.getName()).append("]") @@ -466,12 +471,12 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { // Take a second pass through the list checking for any repos that were created to be // a child of another repo. for (RepoDetails createMe : repos) { - if (createMe.getParentRepoName() != null) { try { - addCandidateRepo(contentSourceId, createMe); - removeRepoFromList(createMe.getName(), candidatesForThisProvider); - repoCounter++; + if (addCandidateRepo(contentSourceId, createMe)) { + importedRepos.add(createMe); + } + removeRepoFromList(createMe.getName(), candidatesForThisProvider); } catch (Exception e) { log.error("Error processing repo [" + createMe + "]", e); result.append("Could not add repo [").append(createMe.getName()).append( @@ -480,7 +485,12 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { } }
- result.append("Imported [").append(repoCounter).append("] repos.").append('\n'); + if (importedRepos.isEmpty()) { + result.append("There are new repos since the last time this content source was synchronized.\n"); + } else { + result.append("Imported the following ").append(importedRepos.size()).append(" repo(s): "). + append(importedRepos).append('\n'); + }
// Any repos that haven't been removed from candidatesForThisProvider were not returned in this // report, so remove them from the database. @@ -500,7 +510,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { }
if (!repo.isCandidate()) { - throw new RepoException("Unable to import repo, repo is already imported. ID: " + repoId); + throw new RepoException("Unable to import repo - repo is already imported. ID: " + repoId); }
repo.setCandidate(false); @@ -865,7 +875,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { * @throws Exception if there is an error associating the content source with the repo or if the repo * indicates a parent or repo group that does not exist */ - private void addCandidateRepo(int contentSourceId, RepoDetails createMe) throws Exception { + private boolean addCandidateRepo(int contentSourceId, RepoDetails createMe) throws Exception {
Subject overlord = subjectManager.getOverlord(); String name = createMe.getName(); @@ -874,7 +884,7 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote {
// If the repo doesn't exist, create it. if (existingRepo.size() != 0) { - return; + return false; }
// Create and populate the repo @@ -908,6 +918,8 @@ public class RepoManagerBean implements RepoManagerLocal, RepoManagerRemote { addRepoRelationship(overlord, addMe.getId(), parent.getId(), PARENT_RELATIONSHIP_NAME); } } + + return true; }
private void removeRepoFromList(String repoName, List<Repo> repoList) { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java index 21fac03..c486873 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/ContentProviderManager.java @@ -186,7 +186,6 @@ public class ContentProviderManager { results = new ContentSourceSyncResults(contentSource); results.setResults(progress.toString()); results = contentSourceManager.persistContentSourceSyncResults(results); - }
if (results == null) { @@ -202,12 +201,15 @@ public class ContentProviderManager { // one sync will get an error and rollback its tx and no harm // will be done. log.info("Content provider [" + contentSource.getName() - + "] is already currently being synchronized, this sync request will be ignored"); + + "] is already currently being synchronized - this sync request will be ignored."); return false; }
RepoSourceSynchronizer repoSourceSynchronizer = new RepoSourceSynchronizer(contentSource, provider); repoSourceSynchronizer.synchronizeCandidateRepos(progress); + results.setStatus(ContentSyncStatus.SUCCESS); + results.setResults(progress.toString()); + } catch (Throwable t) { if (results != null) { // try to reload the results in case it was updated by the SLSB diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoDetails.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoDetails.java index 3ac75db..d277579 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoDetails.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoDetails.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform -* Copyright (C) 2005-2008 Red Hat, Inc. +* Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -127,4 +127,15 @@ public class RepoDetails { public void setRepoGroup(String repoGroup) { this.repoGroup = repoGroup; } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("RepoDetails["); + sb.append("name='").append(this.name).append('''); + sb.append(", parentRepoName='").append(this.parentRepoName).append('''); + sb.append(", repoGroup='").append(this.repoGroup).append('''); + sb.append(']'); + return sb.toString(); + } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoGroupDetails.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoGroupDetails.java index 502cdea..5ae72e1 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoGroupDetails.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/RepoGroupDetails.java @@ -101,4 +101,14 @@ public class RepoGroupDetails { public void setDescription(String description) { this.description = description; } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("RepoGroupDetails["); + sb.append("name='").append(this.name).append('''); + sb.append(", typeName='").append(this.typeName).append('''); + sb.append(']'); + return sb.toString(); + } } diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java index 5f801ab..6edf1f9 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/content/sync/RepoSourceSynchronizer.java @@ -67,7 +67,7 @@ public class RepoSourceSynchronizer { }
progress.append(new Date()).append(": "); - progress.append("Asking content provider for repositories to import..."); + progress.append("Asking content provider for new repositories to import...\n");
RepoSource repoSource = (RepoSource) provider;
diff --git a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java index 967fbcf..7f065da 100644 --- a/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java +++ b/modules/enterprise/server/plugins/jboss-software/src/main/java/org/rhq/enterprise/server/plugins/jboss/software/JBossSoftwareContentSourceAdapter.java @@ -126,7 +126,7 @@ public class JBossSoftwareContentSourceAdapter implements ContentProvider, Packa try { rssDocument = retrieveRssDocument(); } catch (Exception e) { - throw new SyncException("Error retrieving rss doc", e); + throw new SyncException("Error retrieving RSS document.", e); }
if (rssDocument == null) {
commit eb23f6fb9a557cb23069ae103a25905bdab5370b Author: Filip Drabek fdrabek@dhcp-lab-136.englab.brq.redhat.com Date: Thu Mar 18 22:27:23 2010 +0100
BZ - 535792 JBossCache plugin throws parsing error while checking configuration.
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/DeploymentUtility.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/DeploymentUtility.java index 242084b..60d2467 100644 --- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/DeploymentUtility.java +++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/DeploymentUtility.java @@ -145,7 +145,7 @@ public class DeploymentUtility {
// this is the deployment descriptor file that we are currently examining; // this is what will be returned if the MBean was configured in this file. - String file = i.eval("sdi.url").toString(); + String file = i.eval("sdi.watch").toString();
if (file.startsWith("file:/")) { file = file.substring(5);
commit 99156a79b26d6c43951ee4b1b596b6efc5b268bc Author: Joseph Marques joseph@redhat.com Date: Thu Mar 18 14:37:15 2010 -0400
search assist has not been written for resource groups yet, disable for now
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java index cd31a4d..5c39367 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseGroupsUIBean.java @@ -1,5 +1,6 @@ package org.rhq.enterprise.gui.inventory.browse;
+import java.util.ArrayList; import java.util.List;
import javax.faces.model.DataModel; @@ -10,7 +11,6 @@ import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.resource.group.GroupCategory; import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; -import org.rhq.core.domain.search.SearchSubsystem; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.core.gui.util.FacesContextUtility; @@ -18,7 +18,6 @@ import org.rhq.enterprise.gui.common.framework.PagedDataTableUIBean; import org.rhq.enterprise.gui.common.paging.PageControlView; import org.rhq.enterprise.gui.common.paging.PagedListDataModel; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; -import org.rhq.enterprise.server.search.execution.SearchAssistManager; import org.rhq.enterprise.server.search.execution.SearchSuggestion; import org.rhq.enterprise.server.util.LookupUtil;
@@ -86,13 +85,10 @@ public class BrowseGroupsUIBean extends PagedDataTableUIBean { } }
- SearchAssistManager searchAssist = new SearchAssistManager(SearchSubsystem.Group); - public List<SearchSuggestion> autocomplete(Object suggest) { String currentInputText = (String) suggest;
- List<SearchSuggestion> suggestions = searchAssist.getAdvancedSuggestions(currentInputText, currentInputText - .length()); + List<SearchSuggestion> suggestions = new ArrayList<SearchSuggestion>();
// offer suggestions based on currentInputText return suggestions; diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml index 9d92183..65be544 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/inventory/browseGroups.xhtml @@ -39,6 +39,7 @@ <h:inputText id="filter" value="#{BrowseGroupsUIBean.filter}" onkeypress="return ignoreEnterKey(event);" style="width: 600px;" /> + ui:remove <rich:suggestionbox id="suggest" for="filter" tokens=",[]" width="600" height="400" @@ -58,6 +59,7 @@ <h:outputText value="#{suggestItem.label}" /> </h:column> </rich:suggestionbox> + </ui:remove> rich:spacer/ <a4j:commandButton value="GO" reRender="browseGroupsDataTable, browseGroupsDataTableScroller"
commit d07e040c976d1493d4c5fae7cf70e76ed8c35273 Author: Ian P. Springer <ips@jetengine.(none)> Date: Thu Mar 18 13:51:22 2010 -0400
add support for discovering and managing JBoss EWP (https://jira.jboss.org/jira/browse/JBPAPP-3673) (cherry picked from commit f988b4721041aefe74cff16ee0d0f5e6475cdf39)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java index 4c8e999..b02bd01 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java @@ -85,11 +85,14 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom static { MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.AS, new ComparableVersion("5.2.0.Beta1")); MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.EAP, new ComparableVersion("5.0.0.Beta")); + MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.EWP, new ComparableVersion("5.0.0.CR1")); MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.SOA, new ComparableVersion("5.0.0.Beta")); }
private static final String[] CLIENT_JARS = new String[] { "client/jbossall-client.jar", + "client/trove.jar", + "client/javassist.jar", "common/lib/jboss-security-aspects.jar", "lib/jboss-managed.jar", "lib/jboss-metatype.jar", diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java index 6804195..024bc41 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java @@ -1,6 +1,6 @@ /* * Jopr Management Platform -* Copyright (C) 2005-2009 Red Hat, Inc. +* Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -25,7 +25,7 @@ package org.rhq.plugins.jbossas5.helper; import java.util.jar.Attributes;
/** - * The product type of a JBoss application server installation - AS, EAP, or SOA. + * The product type of a JBoss 5.x/6.x application server installation - AS, EAP, EWP, or SOA. * * @author Jessica Sant * @author Ian Springer @@ -33,6 +33,7 @@ import java.util.jar.Attributes; public enum JBossProductType { AS("JBoss AS", "JBoss Application Server", "default"), // the public offering EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"), // the customer offering + EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"), // the customer offering SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "production"); // the customer SOA platform
public final String NAME; @@ -40,6 +41,7 @@ public enum JBossProductType { public final String DEFAULT_CONFIG_NAME;
private static final String EAP_IMPLEMENTATION_TITLE = "JBoss [EAP]"; + private static final String EWP_IMPLEMENTATION_TITLE = "JBoss [EWP]"; private static final String SOA_IMPLEMENTATION_TITLE = "JBoss [SOA]";
JBossProductType(String name, String description, String defaultConfigName) { @@ -49,10 +51,11 @@ public enum JBossProductType { }
/** - * Determines the product type (AS, EAP or SOA) based on the Implementation-Title MANIFEST.MF attribute. + * Determines the product type (AS, EAP, EWP, or SOA) based on the Implementation-Title MANIFEST.MF attribute. * * @param attributes the attributes from a manifest file (typically run.jar or jboss-j2ee.jar) - * @return AS, EAP or SOA + * + * @return the product type (AS, EAP, EWP, or SOA) */ public static JBossProductType determineJBossProductType(Attributes attributes) { JBossProductType result = JBossProductType.AS; @@ -61,6 +64,8 @@ public enum JBossProductType { if (implementationTitle != null) { if (implementationTitle.equalsIgnoreCase(EAP_IMPLEMENTATION_TITLE)) { result = JBossProductType.EAP; + } else if (implementationTitle.equalsIgnoreCase(EWP_IMPLEMENTATION_TITLE)) { + result = JBossProductType.EWP; } else if (implementationTitle.equalsIgnoreCase(SOA_IMPLEMENTATION_TITLE)) { result = JBossProductType.SOA; }
commit f988b4721041aefe74cff16ee0d0f5e6475cdf39 Author: Ian P. Springer <ips@jetengine.(none)> Date: Thu Mar 18 13:51:22 2010 -0400
add support for discovering and managing JBoss EWP (https://jira.jboss.org/jira/browse/JBPAPP-3673)
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java index 4c8e999..b02bd01 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java @@ -85,11 +85,14 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom static { MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.AS, new ComparableVersion("5.2.0.Beta1")); MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.EAP, new ComparableVersion("5.0.0.Beta")); + MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.EWP, new ComparableVersion("5.0.0.CR1")); MINIMUM_PRODUCT_VERSIONS.put(JBossProductType.SOA, new ComparableVersion("5.0.0.Beta")); }
private static final String[] CLIENT_JARS = new String[] { "client/jbossall-client.jar", + "client/trove.jar", + "client/javassist.jar", "common/lib/jboss-security-aspects.jar", "lib/jboss-managed.jar", "lib/jboss-metatype.jar", diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java index 6804195..024bc41 100644 --- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java +++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossProductType.java @@ -1,6 +1,6 @@ /* * Jopr Management Platform -* Copyright (C) 2005-2009 Red Hat, Inc. +* Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -25,7 +25,7 @@ package org.rhq.plugins.jbossas5.helper; import java.util.jar.Attributes;
/** - * The product type of a JBoss application server installation - AS, EAP, or SOA. + * The product type of a JBoss 5.x/6.x application server installation - AS, EAP, EWP, or SOA. * * @author Jessica Sant * @author Ian Springer @@ -33,6 +33,7 @@ import java.util.jar.Attributes; public enum JBossProductType { AS("JBoss AS", "JBoss Application Server", "default"), // the public offering EAP("JBoss EAP", "JBoss Enterprise Application Platform", "default"), // the customer offering + EWP("JBoss EWP", "JBoss Enterprise Web Platform", "default"), // the customer offering SOA("JBoss SOA-P", "JBoss Enterprise SOA Platform", "production"); // the customer SOA platform
public final String NAME; @@ -40,6 +41,7 @@ public enum JBossProductType { public final String DEFAULT_CONFIG_NAME;
private static final String EAP_IMPLEMENTATION_TITLE = "JBoss [EAP]"; + private static final String EWP_IMPLEMENTATION_TITLE = "JBoss [EWP]"; private static final String SOA_IMPLEMENTATION_TITLE = "JBoss [SOA]";
JBossProductType(String name, String description, String defaultConfigName) { @@ -49,10 +51,11 @@ public enum JBossProductType { }
/** - * Determines the product type (AS, EAP or SOA) based on the Implementation-Title MANIFEST.MF attribute. + * Determines the product type (AS, EAP, EWP, or SOA) based on the Implementation-Title MANIFEST.MF attribute. * * @param attributes the attributes from a manifest file (typically run.jar or jboss-j2ee.jar) - * @return AS, EAP or SOA + * + * @return the product type (AS, EAP, EWP, or SOA) */ public static JBossProductType determineJBossProductType(Attributes attributes) { JBossProductType result = JBossProductType.AS; @@ -61,6 +64,8 @@ public enum JBossProductType { if (implementationTitle != null) { if (implementationTitle.equalsIgnoreCase(EAP_IMPLEMENTATION_TITLE)) { result = JBossProductType.EAP; + } else if (implementationTitle.equalsIgnoreCase(EWP_IMPLEMENTATION_TITLE)) { + result = JBossProductType.EWP; } else if (implementationTitle.equalsIgnoreCase(SOA_IMPLEMENTATION_TITLE)) { result = JBossProductType.SOA; }
commit cfc3016d77b64c8d65a12acd3e15d544f76fa77d Author: Ian P. Springer <ips@jetengine.(none)> Date: Thu Mar 18 10:14:47 2010 -0400
fix bug when trying to toggle favorite flag on current Resource (cherry picked from commit 5019f944b1cfd381f358023333e8a6ec988f58f4)
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java index 25b3dfe..5bf3da5 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java @@ -21,18 +21,22 @@ package org.rhq.enterprise.gui.inventory.resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
-import org.rhq.core.gui.util.FacesContextUtility; +import org.jboss.seam.ScopeType; +import org.jboss.seam.annotations.In; +import org.jboss.seam.annotations.Name; +import org.jboss.seam.annotations.Scope; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.action.resource.common.QuickFavoritesUtil; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; -import org.rhq.enterprise.gui.util.WebUtility;
/** - * A session-scoped bean for toggling the current resource in request scope + * A session-scoped bean for toggling the current resource in request scope. * * @author Joseph Marques */ +@Name("FavoritesUIBean") +@Scope(ScopeType.EVENT) public class FavoritesUIBean {
protected final Log log = LogFactory.getLog(FavoritesUIBean.class); @@ -45,6 +49,7 @@ public class FavoritesUIBean { * requests, particularly with the raw config editor. The raw config editor however extends the life of the * current ResourceUIBean beyond the current request so that the id can be accessed through ResourceUIBean. */ + @In(value = ResourceUIBean.MANAGED_BEAN_NAME, create = true) private ResourceUIBean resourceUIBean;
public FavoritesUIBean() { @@ -88,5 +93,4 @@ public class FavoritesUIBean {
return null; } - } \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java index 03be73e..bc62589 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java @@ -25,6 +25,9 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.seam.ScopeType; +import org.jboss.seam.annotations.Name; +import org.jboss.seam.annotations.Scope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
@@ -62,6 +65,8 @@ import org.rhq.enterprise.server.util.LookupUtil; * * @author Ian Springer */ +@Name(ResourceUIBean.MANAGED_BEAN_NAME) +@Scope(ScopeType.EVENT) public class ResourceUIBean {
protected final Log log = LogFactory.getLog(ResourceUIBean.class); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml index ff5d3d9..fb313ca 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml @@ -26,12 +26,14 @@
<!-- /rhq/resource/** -->
+ <!-- <managed-bean> <managed-bean-name>ResourceUIBean</managed-bean-name> <managed-bean-class>org.rhq.enterprise.gui.inventory.resource.ResourceUIBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> - + --> + <managed-bean> <managed-bean-name>ResourceOverviewUIBean</managed-bean-name> <managed-bean-class>org.rhq.enterprise.gui.inventory.resource.ResourceOverviewUIBean</managed-bean-class> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml index 4a0e1cf..9f132c8 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml @@ -85,9 +85,9 @@ groupId - the group id of the Group being accessed
<rich:toolTip for="favoritesStar"> - <h:outputText value="Add resource to favorites list" + <h:outputText value="Add group to favorites list" rendered="#{!ResourceGroupUIBean.favorite}"/> - <h:outputText value="Remove resource from favorites list" + <h:outputText value="Remove group from favorites list" rendered="#{ResourceGroupUIBean.favorite}"/> </rich:toolTip> </a4j:region>
commit 5d7df4e65e66115206314d19d55974166f496a76 Author: Ian P. Springer <ips@jetengine.(none)> Date: Thu Mar 18 10:14:47 2010 -0400
fix bug when trying to toggle favorite flag on current Resource (cherry picked from commit 5019f944b1cfd381f358023333e8a6ec988f58f4)
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java index 25b3dfe..5bf3da5 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/FavoritesUIBean.java @@ -21,18 +21,22 @@ package org.rhq.enterprise.gui.inventory.resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
-import org.rhq.core.gui.util.FacesContextUtility; +import org.jboss.seam.ScopeType; +import org.jboss.seam.annotations.In; +import org.jboss.seam.annotations.Name; +import org.jboss.seam.annotations.Scope; import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.WebUserPreferences; import org.rhq.enterprise.gui.legacy.action.resource.common.QuickFavoritesUtil; import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; -import org.rhq.enterprise.gui.util.WebUtility;
/** - * A session-scoped bean for toggling the current resource in request scope + * A session-scoped bean for toggling the current resource in request scope. * * @author Joseph Marques */ +@Name("FavoritesUIBean") +@Scope(ScopeType.EVENT) public class FavoritesUIBean {
protected final Log log = LogFactory.getLog(FavoritesUIBean.class); @@ -45,6 +49,7 @@ public class FavoritesUIBean { * requests, particularly with the raw config editor. The raw config editor however extends the life of the * current ResourceUIBean beyond the current request so that the id can be accessed through ResourceUIBean. */ + @In(value = ResourceUIBean.MANAGED_BEAN_NAME, create = true) private ResourceUIBean resourceUIBean;
public FavoritesUIBean() { @@ -88,5 +93,4 @@ public class FavoritesUIBean {
return null; } - } \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java index 03be73e..bc62589 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java @@ -25,6 +25,9 @@ import java.util.Set;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jboss.seam.ScopeType; +import org.jboss.seam.annotations.Name; +import org.jboss.seam.annotations.Scope; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
@@ -62,6 +65,8 @@ import org.rhq.enterprise.server.util.LookupUtil; * * @author Ian Springer */ +@Name(ResourceUIBean.MANAGED_BEAN_NAME) +@Scope(ScopeType.EVENT) public class ResourceUIBean {
protected final Log log = LogFactory.getLog(ResourceUIBean.class); diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml index ff5d3d9..fb313ca 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/jsf-managed-beans/inventory-beans.xml @@ -26,12 +26,14 @@
<!-- /rhq/resource/** -->
+ <!-- <managed-bean> <managed-bean-name>ResourceUIBean</managed-bean-name> <managed-bean-class>org.rhq.enterprise.gui.inventory.resource.ResourceUIBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> - + --> + <managed-bean> <managed-bean-name>ResourceOverviewUIBean</managed-bean-name> <managed-bean-class>org.rhq.enterprise.gui.inventory.resource.ResourceOverviewUIBean</managed-bean-class> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml index 4a0e1cf..9f132c8 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/group/layout/summary.xhtml @@ -85,9 +85,9 @@ groupId - the group id of the Group being accessed
<rich:toolTip for="favoritesStar"> - <h:outputText value="Add resource to favorites list" + <h:outputText value="Add group to favorites list" rendered="#{!ResourceGroupUIBean.favorite}"/> - <h:outputText value="Remove resource from favorites list" + <h:outputText value="Remove group from favorites list" rendered="#{ResourceGroupUIBean.favorite}"/> </rich:toolTip> </a4j:region>
commit ad9fe1aba113f55f9493a205c0a2f29d1a26f9e6 Merge: 450dea0... 7721e26... Author: Ian P. Springer <ips@jetengine.(none)> Date: Thu Mar 18 10:42:21 2010 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 7721e26cda6183de4191d6ca6d70379147dc70ac Merge: db755e1... 7e4c228... Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Mar 18 10:18:44 2010 -0400
Merge branch 'bundle'
commit 7e4c2286585b5af7bdb843fb6e4ce1a1e6fe56b0 Merge: b25c245... 96a5298... Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Mar 18 10:13:36 2010 -0400
Merge branch 'bundle-jay' into bundle
commit b25c245e3cfb775f38f7102252d5009c270442f6 Author: Jay Shaughnessy jshaughn@redhat.com Date: Thu Mar 18 10:13:29 2010 -0400
LT
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js index 54f2a5b..7bdcd0d 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js +++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/timeline/ajax/api/scripts/units.js @@ -1,64 +1,64 @@ -/*================================================== - * Default Unit - *================================================== - */ - -SimileAjax.NativeDateUnit = new Object(); - -SimileAjax.NativeDateUnit.makeDefaultValue = function() { - return new Date(); -}; - -SimileAjax.NativeDateUnit.cloneValue = function(v) { - return new Date(v.getTime()); -}; - -SimileAjax.NativeDateUnit.getParser = function(format) { - if (typeof format == "string") { - format = format.toLowerCase(); - } - return (format == "iso8601" || format == "iso 8601") ? - SimileAjax.DateTime.parseIso8601DateTime : - SimileAjax.DateTime.parseGregorianDateTime; -}; - -SimileAjax.NativeDateUnit.parseFromObject = function(o) { - return SimileAjax.DateTime.parseGregorianDateTime(o); -}; - -SimileAjax.NativeDateUnit.toNumber = function(v) { - return v.getTime(); -}; - -SimileAjax.NativeDateUnit.fromNumber = function(n) { - return new Date(n); -}; - -SimileAjax.NativeDateUnit.compare = function(v1, v2) { - var n1, n2; - if (typeof v1 == "object") { - n1 = v1.getTime(); - } else { - n1 = Number(v1); - } - if (typeof v2 == "object") { - n2 = v2.getTime(); - } else { - n2 = Number(v2); - } - - return n1 - n2; -}; - -SimileAjax.NativeDateUnit.earlier = function(v1, v2) { - return SimileAjax.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2; -}; - -SimileAjax.NativeDateUnit.later = function(v1, v2) { - return SimileAjax.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2; -}; - -SimileAjax.NativeDateUnit.change = function(v, n) { - return new Date(v.getTime() + n); -}; - +/*================================================== + * Default Unit + *================================================== + */ + +SimileAjax.NativeDateUnit = new Object(); + +SimileAjax.NativeDateUnit.makeDefaultValue = function() { + return new Date(); +}; + +SimileAjax.NativeDateUnit.cloneValue = function(v) { + return new Date(v.getTime()); +}; + +SimileAjax.NativeDateUnit.getParser = function(format) { + if (typeof format == "string") { + format = format.toLowerCase(); + } + return (format == "iso8601" || format == "iso 8601") ? + SimileAjax.DateTime.parseIso8601DateTime : + SimileAjax.DateTime.parseGregorianDateTime; +}; + +SimileAjax.NativeDateUnit.parseFromObject = function(o) { + return SimileAjax.DateTime.parseGregorianDateTime(o); +}; + +SimileAjax.NativeDateUnit.toNumber = function(v) { + return v.getTime(); +}; + +SimileAjax.NativeDateUnit.fromNumber = function(n) { + return new Date(n); +}; + +SimileAjax.NativeDateUnit.compare = function(v1, v2) { + var n1, n2; + if (typeof v1 == "object") { + n1 = v1.getTime(); + } else { + n1 = Number(v1); + } + if (typeof v2 == "object") { + n2 = v2.getTime(); + } else { + n2 = Number(v2); + } + + return n1 - n2; +}; + +SimileAjax.NativeDateUnit.earlier = function(v1, v2) { + return SimileAjax.NativeDateUnit.compare(v1, v2) < 0 ? v1 : v2; +}; + +SimileAjax.NativeDateUnit.later = function(v1, v2) { + return SimileAjax.NativeDateUnit.compare(v1, v2) > 0 ? v1 : v2; +}; + +SimileAjax.NativeDateUnit.change = function(v, n) { + return new Date(v.getTime() + n); +}; +
commit d6c56f6ad3a3bbd9cc9d4ce20ef339623359da82 Merge: 8f0337b... 6bf9398... Author: Partha Aji paji@redhat.com Date: Tue Mar 9 10:31:32 2010 -0500
Merge branch 'linux-config' into ldap
commit 8f0337b2df94be73adf900606e276b4d372dfa2a Author: Partha Aji paji@redhat.com Date: Tue Mar 9 02:26:00 2010 -0500
Added code to handle ldap group queries
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java index 4f3aaea..f2734a3 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java @@ -20,6 +20,7 @@ package org.rhq.enterprise.server.authz;
import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -509,6 +510,9 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { }
private List<Role> findRolesByLdapGroupNames(List<String> ldapGroupNames) { + if (ldapGroupNames.isEmpty()) { + return Collections.EMPTY_LIST; + } Query query = entityManager.createNamedQuery(LdapGroup.FIND_BY_ROLES_GROUP_NAMES); query.setParameter("names", ldapGroupNames); return (List<Role>) query.getResultList(); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java index 3820a63..eb20236 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java @@ -19,7 +19,6 @@
package org.rhq.enterprise.server.resource.group;
-import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -28,6 +27,8 @@ import java.util.Set;
import javax.naming.Context; import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import javax.naming.ldap.InitialLdapContext; @@ -58,121 +59,110 @@ public class LdapGroupManager {
public Set<Map<String, String>> findAvailableGroups() { SystemManagerLocal manager = LookupUtil.getSystemManager(); - manager.getSystemConfiguration(); - Set<Map<String, String>> ldapSet = new HashSet<Map<String, String>>(); - String[] names = { "bar", "foo" }; - - for (String name : names) { - Map<String, String> group = new HashMap<String, String>(); - group.put("id", name); - group.put("name", name); - group.put("description", name); - ldapSet.add(group); - } - return ldapSet; + + Properties options = manager.getSystemConfiguration(); + String groupFilter = (String) options.get(RHQConstants.LDAPGroupFilter); + String filter = String.format("(%s)", groupFilter); + + return buildGroup(options, filter); }
public Set<String> findAvailableGroupsFor(String userName) { SystemManagerLocal manager = LookupUtil.getSystemManager(); - manager.getSystemConfiguration(); - Set<String> ldapSet = new HashSet<String>(); - String[] names = { "foo" };
- for (String name : names) { - ldapSet.add(name); + Properties options = manager.getSystemConfiguration(); + String groupFilter = (String) options.get(RHQConstants.LDAPGroupFilter); + String groupMember = (String) options.get(RHQConstants.LDAPGroupMember); + String userDN = getUserDN(options, userName); + String filter = String.format("(&(%s)(%s=%s))", groupFilter, groupMember, userDN); + + Set<Map<String, String>> matched = buildGroup(options, filter); + + Set<String> ldapSet = new HashSet<String>(); + for (Map<String, String> match : matched) { + ldapSet.add(match.get("id")); } return ldapSet; }
- /* - * - {BindDN=uid=shaggy,ou=People, dc=rhndev, dc=redhat, dc=com, - java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory, jboss.security.security_domain=JON, - LoginProperty=uid, BaseDN=dc=rhndev,dc=redhat,dc=com, java.naming.provider.url=ldap://fjs-0-16.rhndev.redhat.com, - java.naming.security.protocol=, BindPW=dog8code} - */ - protected boolean test() throws Exception { - + private String getUserDN(Properties options, String userName) { // Load our LDAP specific properties - Properties env = null;// getProperties(); + Properties env = getProperties(options);
// Load the BaseDN - String baseDN = "dc=rhndev,dc=redhat,dc=com"; + // Load the BaseDN + String baseDN = (String) options.get(RHQConstants.LDAPBaseDN);
// Load the LoginProperty - String loginProperty = "uid"; - - // Load any search filter - - // Find the user that is calling us - String userName = "sdoo"; - + String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty); + if (loginProperty == null) { + // Use the default + loginProperty = "cn"; + } // Load any information we may need to bind - String bindDN = "uid=shaggy,ou=People, dc=rhndev, dc=redhat, dc=com"; - String bindPW = "dog8code"; + String bindDN = (String) options.get(RHQConstants.LDAPBindDN); + String bindPW = (String) options.get(RHQConstants.LDAPBindPW);
+ // Load any search filter + String searchFilter = (String) options.get(RHQConstants.LDAPFilter); if (bindDN != null) { env.setProperty(Context.SECURITY_PRINCIPAL, bindDN); env.setProperty(Context.SECURITY_CREDENTIALS, bindPW); env.setProperty(Context.SECURITY_AUTHENTICATION, "simple"); } - InitialLdapContext ctx = new InitialLdapContext(env, null); - SearchControls searchControls = getSearchControls(); - - // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar. - String filter; - /* if ((searchFilter != null) && (searchFilter.length() != 0)) { - filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))"; - } else { - filter = "(" + loginProperty + "=" + userName + ")"; + + try { + InitialLdapContext ctx = new InitialLdapContext(env, null); + SearchControls searchControls = getSearchControls(); + + // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar. + String filter; + if ((searchFilter != null) && (searchFilter.length() != 0)) { + filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))"; + } else { + filter = "(" + loginProperty + "=" + userName + ")"; + } + + log.debug("Using LDAP filter=" + filter); + + // Loop through each configured base DN. It may be useful + // in the future to allow for a filter to be configured for + // each BaseDN, but for now the filter will apply to all. + String[] baseDNs = baseDN.split(BASEDN_DELIMITER); + for (int x = 0; x < baseDNs.length; x++) { + NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls); + if (!answer.hasMore()) { + log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]); + // Nothing found for this DN, move to the next one if we have one. + continue; } - */ - //filter = "(" + loginProperty + "=" + userName + ")"; - filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName - + ",ou=People, dc=rhndev, dc=redhat, dc=com))"; - - // Loop through each configured base DN. It may be useful - // in the future to allow for a filter to be configured for - // each BaseDN, but for now the filter will apply to all. - String[] baseDNs = baseDN.split(BASEDN_DELIMITER); - log.info(Arrays.asList(baseDNs)); - for (int x = 0; x < baseDNs.length; x++) { - NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls); - log.info(answer.hasMore()); - while (answer.hasMore()) { + // We use the first match SearchResult si = (SearchResult) answer.next(); - log.info(si); - - /* - // Construct the UserDN - String userDN = si.getName() + "," + baseDNs[x]; - print (userDN); - ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN); - ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, "dog8code"); - ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple"); - ctx.reconnect(null);*/ + + // Construct the UserDN + String userDN = si.getName() + "," + baseDNs[x]; + return userDN; }
+ // If we try all the BaseDN's and have not found a match, return false + return ""; + } catch (NamingException e) { + throw new RuntimeException(e); } - - // If we try all the BaseDN's and have not found a match, return false - return false; }
/** + * @throws NamingException * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,java.lang.String) */ - protected void buildGroup(Properties options, String userName) { + protected Set<Map<String, String>> buildGroup(Properties options, String filter) { + Set<Map<String, String>> ret = new HashSet<Map<String, String>>(); // Load our LDAP specific properties Properties env = getProperties(options);
// Load the BaseDN String baseDN = (String) options.get(RHQConstants.LDAPBaseDN); - if (baseDN == null) { - // If the BaseDN is not specified, log an error and refuse the login attempt - log.info("BaseDN is not set, refusing login"); - }
// Load the LoginProperty String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty); @@ -180,54 +170,46 @@ public class LdapGroupManager { // Use the default loginProperty = "cn"; } - - String groupFilter = (String) options.get("groupFilter"); - String groupMember = (String) options.get("groupMember"); - // Load any information we may need to bind - String bindDN = (String) options.get("BindDN"); - String bindPW = (String) options.get("BindPW"); + String bindDN = (String) options.get(RHQConstants.LDAPBindDN); + String bindPW = (String) options.get(RHQConstants.LDAPBindPW); if (bindDN != null) { env.setProperty(Context.SECURITY_PRINCIPAL, bindDN); env.setProperty(Context.SECURITY_CREDENTIALS, bindPW); env.setProperty(Context.SECURITY_AUTHENTICATION, "simple"); } - try { InitialLdapContext ctx = new InitialLdapContext(env, null); SearchControls searchControls = getSearchControls(); - String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName - + ",ou=People, dc=rhndev, dc=redhat, dc=com))"; - // Load any search filter - String searchFilter = (String) options.get("Filter"); - // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar. - if ((searchFilter != null) && (searchFilter.length() != 0)) { - filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))"; - } else { - filter = "(" + loginProperty + "=" + userName + ")"; - } + /*String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName + + ",ou=People, dc=rhndev, dc=redhat, dc=com))";*/
// Loop through each configured base DN. It may be useful // in the future to allow for a filter to be configured for // each BaseDN, but for now the filter will apply to all. String[] baseDNs = baseDN.split(BASEDN_DELIMITER); + for (int x = 0; x < baseDNs.length; x++) { NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls); - if (!answer.hasMore()) { - log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]); - - // Nothing found for this DN, move to the next one if we have one. - continue; + while (answer.hasMore()) { + // We use the first match + SearchResult si = (SearchResult) answer.next(); + Map<String, String> entry = new HashMap<String, String>(); + String name = (String) si.getAttributes().get("cn").get(); + Attribute desc = si.getAttributes().get("description"); + String description = desc != null ? (String) desc.get() : ""; + entry.put("id", name); + entry.put("name", name); + entry.put("description", description); + ret.add(entry); } - - // We use the first match - SearchResult si = (SearchResult) answer.next(); - } - - } catch (Exception e) { - log.info("Failed to validate password: " + e.getMessage()); + } catch (NamingException e) { + // TODO Auto-generated catch block + throw new RuntimeException(e); } + + return ret; }
/** @@ -240,13 +222,11 @@ public class LdapGroupManager { private Properties getProperties(Properties options) { Properties env = new Properties(options); // Set our default factory name if one is not given - String factoryName = env.getProperty(Context.INITIAL_CONTEXT_FACTORY); - if (factoryName == null) { - env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); - } + String factoryName = env.getProperty(RHQConstants.LDAPFactory); + env.setProperty(Context.INITIAL_CONTEXT_FACTORY, factoryName);
// Setup SSL if requested - String protocol = env.getProperty(Context.SECURITY_PROTOCOL); + String protocol = env.getProperty(RHQConstants.LDAPProtocol); if ((protocol != null) && protocol.equals("ssl")) { String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket"); if (ldapSocketFactory == null) { @@ -256,7 +236,7 @@ public class LdapGroupManager { }
// Set the LDAP url - String providerUrl = env.getProperty(Context.PROVIDER_URL); + String providerUrl = env.getProperty(RHQConstants.LDAPUrl); if (providerUrl == null) { providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389"); }
commit 08e009091f9fbea25e5b08c3ab8b0bb82fa2c71d Author: Partha Aji paji@redhat.com Date: Mon Mar 8 14:51:08 2010 -0500
Added the logic to sync roles to ldap users on login
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java index 78fa9dc..b8e2beb 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java @@ -43,13 +43,16 @@ import org.rhq.core.domain.authz.Role; * */ @Entity -@NamedQueries( { @NamedQuery(name = LdapGroup.DELETE_BY_ID, query = "DELETE FROM LdapGroup an WHERE an.id IN ( :ids )") }) +@NamedQueries( { + @NamedQuery(name = LdapGroup.DELETE_BY_ID, query = "DELETE FROM LdapGroup an WHERE an.id IN ( :ids )"), + @NamedQuery(name = LdapGroup.FIND_BY_ROLES_GROUP_NAMES, query = "SELECT distinct l.role FROM LdapGroup l WHERE l.name in (:names)") }) @Table(name = "RHQ_ROLE_LDAP_GROUP") @SequenceGenerator(name = "id", sequenceName = "RHQ_ROLE_LDAP_GROUP_ID_SEQ", allocationSize = 100) @XmlAccessorType(XmlAccessType.FIELD) public class LdapGroup implements Serializable { private static final long serialVersionUID = 1L; public static final String DELETE_BY_ID = "LdapGroup.deleteById"; + public static final String FIND_BY_ROLES_GROUP_NAMES = "LdapGroup.findRolesByGroupNames"; @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy = GenerationType.AUTO, generator = "id") diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java index 1c8b5a0..2c6db30 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/RegisterAction.java @@ -18,7 +18,9 @@ */ package org.rhq.enterprise.gui.admin.user;
+import java.util.ArrayList; import java.util.HashMap; +import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,7 +39,10 @@ import org.rhq.enterprise.gui.legacy.WebUser; import org.rhq.enterprise.gui.legacy.action.BaseAction; import org.rhq.enterprise.gui.legacy.util.RequestUtils; import org.rhq.enterprise.gui.legacy.util.SessionUtils; +import org.rhq.enterprise.server.RHQConstants; import org.rhq.enterprise.server.auth.SubjectManagerLocal; +import org.rhq.enterprise.server.authz.RoleManagerLocal; +import org.rhq.enterprise.server.resource.group.LdapGroupManager; import org.rhq.enterprise.server.util.LookupUtil;
/** @@ -106,6 +111,14 @@ public class RegisterAction extends BaseAction { HashMap parms = new HashMap(1); parms.put(Constants.USER_PARAM, newSubject.getId());
+ String provider = LookupUtil.getSystemManager().getSystemConfiguration().getProperty(RHQConstants.JAASProvider); + if (RHQConstants.LDAPJAASProvider.equals(provider)) { + List<String> groupNames = new ArrayList(LdapGroupManager.getInstance().findAvailableGroupsFor( + newSubject.getName())); + RoleManagerLocal roleManager = LookupUtil.getRoleManager(); + roleManager.assignRolesToLdapSubject(newSubject.getId(), groupNames); + + } return returnSuccess(request, mapping, parms, false); } } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java index bcf7738..4f3aaea 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java @@ -174,6 +174,14 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { */ @RequiredPermission(Permission.MANAGE_SECURITY) public void addRolesToSubject(Subject subject, int subjectId, int[] roleIds) { + addRolesToSubject(subject, subjectId, roleIds, false); + } + + /** + * @see org.rhq.enterprise.server.authz.RoleManagerLocal#addRolesToSubject(Subject, int, int[]) + */ + @RequiredPermission(Permission.MANAGE_SECURITY) + public void addRolesToSubject(Subject subject, int subjectId, int[] roleIds, boolean isLdap) { if (roleIds != null) { Subject subjectToModify = subjectManager.getSubjectById(subjectId); // attach it if (subjectToModify == null) { @@ -194,10 +202,11 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { + "], but role was not found"); } role.addSubject(subjectToModify); + if (isLdap) { + role.addLdapSubject(subjectToModify); + } } } - - return; }
/** @@ -499,6 +508,23 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { } }
+ private List<Role> findRolesByLdapGroupNames(List<String> ldapGroupNames) { + Query query = entityManager.createNamedQuery(LdapGroup.FIND_BY_ROLES_GROUP_NAMES); + query.setParameter("names", ldapGroupNames); + return (List<Role>) query.getResultList(); + } + + public void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames) { + Subject sub = entityManager.find(Subject.class, subjectId); + List<Role> roles = findRolesByLdapGroupNames(ldapGroupNames); + sub.getRoles().clear(); + sub.getLdapRoles().clear(); + for (Role role : roles) { + sub.addRole(role); + sub.addLdapRole(role); + } + } + private void processDependentPermissions(Role role) { /* * if you can control user/roles, then you can give yourself permissions, too; so we might as well diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java index 34b81e0..30dcceb 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java @@ -219,4 +219,5 @@ public interface RoleManagerLocal {
PageList<Role> findRolesByCriteria(Subject subject, RoleCriteria criteria);
+ void assignRolesToLdapSubject(int subjectId, List<String> ldapGroupNames); } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java index 1875475..3820a63 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java @@ -72,18 +72,14 @@ public class LdapGroupManager { return ldapSet; }
- public Set<Map<String, String>> findAvailableGroupsFor(String userName) { + public Set<String> findAvailableGroupsFor(String userName) { SystemManagerLocal manager = LookupUtil.getSystemManager(); manager.getSystemConfiguration(); - Set<Map<String, String>> ldapSet = new HashSet<Map<String, String>>(); - String[] names = { "bar", "foo" }; + Set<String> ldapSet = new HashSet<String>(); + String[] names = { "foo" };
for (String name : names) { - Map<String, String> group = new HashMap<String, String>(); - group.put("id", name); - group.put("name", name); - group.put("description", name); - ldapSet.add(group); + ldapSet.add(name); } return ldapSet; }
commit ac2479467dc65ab832e240749582df68183be033 Author: Partha Aji paji@redhat.com Date: Mon Mar 8 12:07:05 2010 -0500
Added methods to get 2 kinds of ldap groups
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java index c673cb5..78b1f1f 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java @@ -81,8 +81,7 @@ public class AddLdapGroupsFormPrepareAction extends TilesAction {
log.trace("getting pending groups for role [" + roleId + ")"); String name = "foo"; - Set<Map<String, String>> allGroups = LdapGroupManager.getInstance().findAvailableGroupsByRole(whoami, - role.getId()); + Set<Map<String, String>> allGroups = LdapGroupManager.getInstance().findAvailableGroups(); RoleManagerLocal roleManager = LookupUtil.getRoleManager();
PageList<LdapGroup> assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java index 86bd8b4..1875475 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java @@ -35,7 +35,6 @@ import javax.naming.ldap.InitialLdapContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.auth.Subject; import org.rhq.enterprise.server.RHQConstants; import org.rhq.enterprise.server.system.SystemManagerLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -57,7 +56,23 @@ public class LdapGroupManager { return INSTANCE; }
- public Set<Map<String, String>> findAvailableGroupsByRole(Subject subject, int roleId) { + public Set<Map<String, String>> findAvailableGroups() { + SystemManagerLocal manager = LookupUtil.getSystemManager(); + manager.getSystemConfiguration(); + Set<Map<String, String>> ldapSet = new HashSet<Map<String, String>>(); + String[] names = { "bar", "foo" }; + + for (String name : names) { + Map<String, String> group = new HashMap<String, String>(); + group.put("id", name); + group.put("name", name); + group.put("description", name); + ldapSet.add(group); + } + return ldapSet; + } + + public Set<Map<String, String>> findAvailableGroupsFor(String userName) { SystemManagerLocal manager = LookupUtil.getSystemManager(); manager.getSystemConfiguration(); Set<Map<String, String>> ldapSet = new HashSet<Map<String, String>>();
commit 4730f9bdaf6da619e1b4b5b61936bb3d5450725d Merge: c4d4879... 3fcd671... Author: Partha Aji paji@redhat.com Date: Mon Mar 8 09:50:22 2010 -0500
Merge branch 'linux-config' into ldap
commit c4d48792e4876666f24ed0159562cb00eba3d3b0 Author: Partha Aji paji@redhat.com Date: Mon Mar 8 09:49:26 2010 -0500
Added functionality to deal with roles
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml index 6e0a31e..fc59516 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml @@ -27,16 +27,16 @@ </constraint> </table>
- <table name="RHQ_ROLE_LDAP_GROUP_MAP"> + <table name="RHQ_ROLE_LDAP_GROUP"> + <column name="ID" default="sequence-only" initial="10001" + primarykey="true" required="true" type="INTEGER"/> <column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/> - <column name="LDAP_GROUP_NAME" required="true" type="VARCHAR2"/> + <column name="LDAP_GROUP_NAME" size="128" required="true" type="VARCHAR2"/>
- <constraint name="RHQ_ROLE_LDAP_GROUP_MAP_KEY"> - <primaryKey> - <field ref="ROLE_ID"/> - <field ref="LDAP_GROUP_NAME"/> - </primaryKey> - </constraint> + <index name="RHQ_ROLE_LDAP_GROUP_IDX" unique="true"> + <field ref="ROLE_ID"/> + <field ref="LDAP_GROUP_NAME"/> + </index> </table>
<table name="RHQ_PERMISSION"> diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index 9b991cd..beb1703 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -240,6 +240,7 @@ public class Subject implements Externalizable {
private void init() { roles = new HashSet<Role>(); + ldapRoles = new HashSet<Role>(); }
/** @@ -376,8 +377,15 @@ public class Subject implements Externalizable { this.roles = roles; }
- public void addRole(Role role) { + public void addRole(Role role, boolean isLdap) { getRoles().add(role); + if (isLdap) { + getLdapRoles().add(role); + } + } + + public void addRole(Role role) { + addRole(role, false); }
public void removeRole(Role role) { diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index b7004bd..ada89a8 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -37,6 +37,7 @@ import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table;
@@ -46,6 +47,7 @@ import org.hibernate.annotations.CollectionOfElements; import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.resource.group.LdapGroup;
/** * A role has zero or more {@link org.rhq.core.domain.resource.group.ResourceGroup}s assigned to it. You can assign a @@ -110,6 +112,9 @@ public class Role implements Serializable { @ManyToMany(mappedBy = "ldapRoles") private java.util.Set<Subject> ldapSubjects = new HashSet<Subject>();
+ @OneToMany(mappedBy = "role", cascade = javax.persistence.CascadeType.ALL) + private Set<LdapGroup> ldapGroups = new HashSet<LdapGroup>(); + @ManyToMany(mappedBy = "roles") private java.util.Set<org.rhq.core.domain.resource.group.ResourceGroup> resourceGroups = new HashSet<org.rhq.core.domain.resource.group.ResourceGroup>();
@@ -181,6 +186,26 @@ public class Role implements Serializable { return this.permissions.remove(permission); }
+ public Set<LdapGroup> getLdapGroups() { + if (ldapGroups == null) { + ldapGroups = new HashSet<LdapGroup>(); + } + return this.ldapGroups; + } + + public void setLdapGroups(Set<LdapGroup> groups) { + this.ldapGroups = groups; + } + + public void addLdapGroup(LdapGroup ldapGroup) { + ldapGroup.setRole(this); + this.ldapGroups.add(ldapGroup); + } + + public boolean removeLdapGroup(LdapGroup ldapGroup) { + return this.ldapGroups.remove(ldapGroup); + } + public java.util.Set<Subject> getSubjects() { return subjects; } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java new file mode 100644 index 0000000..78fa9dc --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/LdapGroup.java @@ -0,0 +1,125 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.core.domain.resource.group; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Transient; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; + +import org.rhq.core.domain.authz.Role; + +/** + * @author paji + * + */ +@Entity +@NamedQueries( { @NamedQuery(name = LdapGroup.DELETE_BY_ID, query = "DELETE FROM LdapGroup an WHERE an.id IN ( :ids )") }) +@Table(name = "RHQ_ROLE_LDAP_GROUP") +@SequenceGenerator(name = "id", sequenceName = "RHQ_ROLE_LDAP_GROUP_ID_SEQ", allocationSize = 100) +@XmlAccessorType(XmlAccessType.FIELD) +public class LdapGroup implements Serializable { + private static final long serialVersionUID = 1L; + public static final String DELETE_BY_ID = "LdapGroup.deleteById"; + @Id + @Column(name = "ID", nullable = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "id") + private Integer id; + + @ManyToOne + @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID", nullable = false) + private Role role; + + @Column(name = "LDAP_GROUP_NAME", nullable = false) + private String name; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Transient + private String description = ""; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + @Override + public int hashCode() { + return getName().hashCode() + 17 * ((role != null) ? role.hashCode() : 0); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + + if (!(o instanceof LdapGroup)) { + return false; + } + LdapGroup grp = (LdapGroup) o; + if (!getName().equals(grp.getName())) { + return false; + } + + if (getRole() != null) { + return getRole().equals(grp.getRole()); + } + + return grp.getRole() == null; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } +} diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java index 4f35fe6..237858d 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java @@ -568,7 +568,7 @@ public class SystemConfigForm extends BaseValidatorForm { public void setLdapSearchFilter(String s) { ldapSearchFilter = s; } - + public String getLdapGroupFilter() { return ldapGroupFilter; } @@ -578,7 +578,7 @@ public class SystemConfigForm extends BaseValidatorForm { }
public String getLdapGroupMember() { - return ldapGroupFilter; + return ldapGroupMember; }
public void setLdapGroupMember(String s) { @@ -609,7 +609,6 @@ public class SystemConfigForm extends BaseValidatorForm { this.reindex = reindex; }
- /* (non-Javadoc) * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, * javax.servlet.http.HttpServletRequest) diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java new file mode 100644 index 0000000..fe91d46 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsAction.java @@ -0,0 +1,87 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.admin.role; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.rhq.enterprise.gui.legacy.Constants; +import org.rhq.enterprise.gui.legacy.action.BaseAction; +import org.rhq.enterprise.gui.legacy.action.BaseValidatorForm; +import org.rhq.enterprise.gui.legacy.util.RequestUtils; +import org.rhq.enterprise.gui.legacy.util.SessionUtils; +import org.rhq.enterprise.server.authz.RoleManagerLocal; +import org.rhq.enterprise.server.util.LookupUtil; + +/** + * An Action that adds resource groups for a role. + */ +public class AddLdapGroupsAction extends BaseAction { + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Log log = LogFactory.getLog(AddLdapGroupsAction.class.getName()); + HttpSession session = request.getSession(); + + AddLdapGroupsForm addForm = (AddLdapGroupsForm) form; + Integer roleId = addForm.getR(); + + ActionForward forward = checkSubmit(request, mapping, form, Constants.ROLE_PARAM, roleId); + if (forward != null) { + BaseValidatorForm spiderForm = (BaseValidatorForm) form; + + if (spiderForm.isCancelClicked() || spiderForm.isResetClicked()) { + log.debug("removing pending group list"); + SessionUtils.removeList(session, Constants.PENDING_RESGRPS_SES_ATTR); + } else if (spiderForm.isAddClicked()) { + log.debug("adding to pending group list"); + SessionUtils.addToList(session, Constants.PENDING_RESGRPS_SES_ATTR, addForm.getAvailableGroups()); + } else if (spiderForm.isRemoveClicked()) { + log.debug("removing from pending group list"); + SessionUtils.removeFromList(session, Constants.PENDING_RESGRPS_SES_ATTR, addForm.getPendingGroups()); + } + + return forward; + } + + log.debug("getting pending group list"); + List<String> pendingGroupIds = SessionUtils.getListAsListStr(request.getSession(), + Constants.PENDING_RESGRPS_SES_ATTR); + for (String id : pendingGroupIds) { + log.debug("adding group [" + id + "] for role [" + roleId + "]"); + } + + RoleManagerLocal roleManager = LookupUtil.getRoleManager(); + roleManager.addLdapGroupsToRole(RequestUtils.getSubject(request), roleId, pendingGroupIds); + + log.debug("removing pending group list"); + SessionUtils.removeList(session, Constants.PENDING_RESGRPS_SES_ATTR); + + RequestUtils.setConfirmation(request, "admin.role.confirm.AddLdapGroups"); + return returnSuccess(request, mapping, Constants.ROLE_PARAM, roleId); + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsForm.java new file mode 100644 index 0000000..4740012 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsForm.java @@ -0,0 +1,139 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.admin.role; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts.action.ActionMapping; + +import org.rhq.enterprise.gui.legacy.action.BaseValidatorForm; + +/** + * A subclass of <code>Spider</code> representing the <em>Add Role Resource Groups</em> form. + */ +public class AddLdapGroupsForm extends BaseValidatorForm { + //-------------------------------------instance variables + + private String[] availableGroups; + private String[] pendingGroups; + private Integer psa; + private Integer psp; + private Integer r; + + //-------------------------------------constructors + + public AddLdapGroupsForm() { + super(); + } + + //-------------------------------------public methods + + public String[] getAvailableGroup() { + return this.availableGroups; + } + + public String[] getAvailableGroups() { + return getAvailableGroup(); + } + + public void setAvailableGroup(String[] availableGroups) { + this.availableGroups = availableGroups; + } + + public void setAvailableGroups(String[] availableGroups) { + setAvailableGroup(availableGroups); + } + + public String[] getPendingGroup() { + return this.pendingGroups; + } + + public String[] getPendingGroups() { + return getPendingGroup(); + } + + public void setPendingGroup(String[] pendingGroups) { + this.pendingGroups = pendingGroups; + } + + public void setPendingGroups(String[] pendingGroups) { + setPendingGroup(pendingGroups); + } + + public Integer getPsa() { + return this.psa; + } + + public void setPsa(Integer ps) { + this.psa = ps; + } + + public Integer getPsp() { + return this.psp; + } + + public void setPsp(Integer ps) { + this.psp = ps; + } + + public Integer getR() { + return this.r; + } + + public void setR(Integer r) { + this.r = r; + } + + public void reset(ActionMapping mapping, HttpServletRequest request) { + super.reset(mapping, request); + this.psa = null; + this.psp = null; + this.r = null; + this.pendingGroups = new String[0]; + this.availableGroups = new String[0]; + } + + public String toString() { + StringBuilder s = new StringBuilder(super.toString()); + s.append("r=" + r + " "); + s.append("psa=" + psa + " "); + s.append("psp=" + psp + " "); + + s.append("availableGroups={"); + listToString(s, availableGroups); + s.append("} "); + + s.append("pendingGroups={"); + listToString(s, pendingGroups); + s.append("}"); + + return s.toString(); + } + + private void listToString(StringBuilder s, String[] l) { + if (l != null) { + for (int i = 0; i < l.length; i++) { + s.append(l[i]); + if (i < (l.length - 1)) { + s.append(", "); + } + } + } + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java new file mode 100644 index 0000000..c673cb5 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/AddLdapGroupsFormPrepareAction.java @@ -0,0 +1,149 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.admin.role; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.tiles.ComponentContext; +import org.apache.struts.tiles.actions.TilesAction; + +import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.authz.Role; +import org.rhq.core.domain.resource.group.LdapGroup; +import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.legacy.Constants; +import org.rhq.enterprise.gui.legacy.util.RequestUtils; +import org.rhq.enterprise.gui.legacy.util.SessionUtils; +import org.rhq.enterprise.gui.util.WebUtility; +import org.rhq.enterprise.server.authz.RoleManagerLocal; +import org.rhq.enterprise.server.resource.group.LdapGroupManager; +import org.rhq.enterprise.server.util.LookupUtil; + +/** + * An Action that retrieves data to facilitate display of the form for adding groups to a role. + */ +public class AddLdapGroupsFormPrepareAction extends TilesAction { + public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { + Log log = LogFactory.getLog(AddLdapGroupsFormPrepareAction.class.getName()); + + Subject whoami = RequestUtils.getSubject(request); + AddLdapGroupsForm addForm = (AddLdapGroupsForm) form; + Integer roleId = addForm.getR(); + + if (roleId == null) { + roleId = RequestUtils.getRoleId(request); + } + + Role role = (Role) request.getAttribute(Constants.ROLE_ATTR); + if (role == null) { + RequestUtils.setError(request, Constants.ERR_ROLE_NOT_FOUND); + return null; + } + + addForm.setR(role.getId()); + + PageControl pca = WebUtility.getPageControl(request, "a"); + PageControl pcp = WebUtility.getPageControl(request, "p"); + + /* pending groups are those on the right side of the "add + * to list" widget- awaiting association with the rolewhen the form's "ok" button is clicked. */ + List<String> pendingGroupIds = SessionUtils.getListAsListStr(request.getSession(), + Constants.PENDING_RESGRPS_SES_ATTR); + + log.trace("getting pending groups for role [" + roleId + ")"); + String name = "foo"; + Set<Map<String, String>> allGroups = LdapGroupManager.getInstance().findAvailableGroupsByRole(whoami, + role.getId()); + RoleManagerLocal roleManager = LookupUtil.getRoleManager(); + + PageList<LdapGroup> assignedList = roleManager.findLdapGroupsByRole(role.getId(), PageControl + .getUnlimitedInstance()); + + allGroups = filterExisting(assignedList, allGroups); + Set<String> pendingIds = new HashSet<String>(pendingGroupIds); + + Set<Map<String, String>> pendingSet = findPendingGroups(pendingIds, allGroups); + PageList<Map<String, String>> pendingGroups = new PageList<Map<String, String>>(pendingSet, pendingSet.size(), + pcp); + + request.setAttribute(Constants.PENDING_RESGRPS_ATTR, pendingGroups); + request.setAttribute(Constants.NUM_PENDING_RESGRPS_ATTR, new Integer(pendingGroups.getTotalSize())); + + /* available groups are all groups in the system that are not + * associated with the role and are not pending + */ + log.trace("getting available groups for role [" + roleId + "]"); + + Set<Map<String, String>> availableGroupsSet = findAvailableGroups(pendingIds, allGroups); + PageList<Map<String, String>> availableGroups = new PageList<Map<String, String>>(availableGroupsSet, + availableGroupsSet.size(), pca); + request.setAttribute(Constants.AVAIL_RESGRPS_ATTR, availableGroups); + request.setAttribute(Constants.NUM_AVAIL_RESGRPS_ATTR, new Integer(availableGroups.getTotalSize())); + + return null; + } + + private Set<Map<String, String>> findPendingGroups(Set<String> pending, Set<Map<String, String>> allGroups) { + Set<Map<String, String>> ret = new HashSet<Map<String, String>>(); + for (Map<String, String> group : allGroups) { + if (pending.contains(group.get("name"))) { + ret.add(group); + } + } + return ret; + } + + private Set<Map<String, String>> findAvailableGroups(Set<String> pending, Set<Map<String, String>> allGroups) { + Set<Map<String, String>> ret = new HashSet<Map<String, String>>(); + for (Map<String, String> group : allGroups) { + if (!pending.contains(group.get("name"))) { + ret.add(group); + } + } + return ret; + } + + private Set<Map<String, String>> filterExisting(List<LdapGroup> pendingItems, Set<Map<String, String>> allGroups) { + Set<String> pending = new HashSet<String>(); + for (LdapGroup group : pendingItems) { + pending.add(group.getName()); + } + + Set<Map<String, String>> ret = new HashSet<Map<String, String>>(); + for (Map<String, String> group : allGroups) { + if (!pending.contains(group.get("name"))) { + ret.add(group); + } + } + return ret; + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java new file mode 100644 index 0000000..fb359c6 --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveLdapGroupsAction.java @@ -0,0 +1,54 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.admin.role; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import org.rhq.core.util.collection.ArrayUtils; +import org.rhq.enterprise.gui.legacy.Constants; +import org.rhq.enterprise.gui.legacy.action.BaseAction; +import org.rhq.enterprise.gui.legacy.util.RequestUtils; +import org.rhq.enterprise.server.util.LookupUtil; + +/** + * An Action that retrieves data to facilitate display of the form for removing groups to a role. + */ +public class RemoveLdapGroupsAction extends BaseAction { + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Log log = LogFactory.getLog(RemoveLdapGroupsAction.class.getName()); + + RemoveResourceGroupsForm rmForm = (RemoveResourceGroupsForm) form; + int roleId = rmForm.getR(); + int[] groupIds = ArrayUtils.unwrapArray(rmForm.getLdapGroups()); + + log.debug("removing groups " + groupIds + "] for role [" + roleId + "]"); + LookupUtil.getRoleManager().removeLdapGroupsFromRole(RequestUtils.getSubject(request), roleId, groupIds); + + RequestUtils.setConfirmation(request, "admin.role.confirm.RemoveLdapGroups"); + return returnSuccess(request, mapping, Constants.ROLE_PARAM, roleId); + } +} \ No newline at end of file diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveResourceGroupsForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveResourceGroupsForm.java index 578136d..3ce789d 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveResourceGroupsForm.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RemoveResourceGroupsForm.java @@ -19,7 +19,9 @@ package org.rhq.enterprise.gui.admin.role;
import javax.servlet.http.HttpServletRequest; + import org.apache.struts.action.ActionMapping; + import org.rhq.enterprise.gui.legacy.action.BaseValidatorForm;
/** @@ -28,6 +30,9 @@ import org.rhq.enterprise.gui.legacy.action.BaseValidatorForm; public class RemoveResourceGroupsForm extends BaseValidatorForm { //-------------------------------------instance variables
+ private Integer[] ldapGroups; + private Integer ldapGroupPageSize; + private Integer[] groups; private Integer r;
@@ -51,6 +56,14 @@ public class RemoveResourceGroupsForm extends BaseValidatorForm { this.groups = groups; }
+ public void setLdapGroups(Integer[] groups) { + this.ldapGroups = groups; + } + + public Integer[] getLdapGroups() { + return ldapGroups; + } + public Integer getPsg() { return getPs(); } @@ -59,6 +72,14 @@ public class RemoveResourceGroupsForm extends BaseValidatorForm { setPs(pageSize); }
+ public Integer getPsldapGroups() { + return ldapGroupPageSize; + } + + public void setPsldapGroups(Integer pageSize) { + ldapGroupPageSize = pageSize; + } + public Integer getR() { return this.r; } diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RoleAdminPortalAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RoleAdminPortalAction.java index 2918c1d..b637b98 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RoleAdminPortalAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/RoleAdminPortalAction.java @@ -20,14 +20,17 @@ package org.rhq.enterprise.gui.admin.role;
import java.util.HashMap; import java.util.Properties; + import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; + import org.rhq.core.domain.authz.Role; import org.rhq.enterprise.gui.legacy.Constants; import org.rhq.enterprise.gui.legacy.Portal; @@ -55,6 +58,9 @@ public class RoleAdminPortalAction extends BaseDispatchAction { private static final String TITLE_ADD_GROUPS = "admin.role.AddRoleGroupsTitle"; private static final String PORTLET_ADD_GROUPS = ".admin.role.AddGroups";
+ private static final String TITLE_ADD_LDAP_GROUPS = "admin.role.AddRoleLdapGroupsTitle"; + private static final String PORTLET_ADD_LDAP_GROUPS = ".admin.role.AddLdapGroups"; + private static final String TITLE_EDIT = "admin.role.EditRoleTitle";
private static final String PORTLET_EDIT = ".admin.role.Edit"; @@ -78,6 +84,7 @@ public class RoleAdminPortalAction extends BaseDispatchAction { keyMethodMap.setProperty(Constants.MODE_LIST, "listRoles"); keyMethodMap.setProperty(Constants.MODE_ADD_USERS, "addRoleUsers"); keyMethodMap.setProperty(Constants.MODE_ADD_GROUPS, "addRoleGroups"); + keyMethodMap.setProperty(Constants.MODE_ADD_LDAP_GROUPS, "addLdapGroups"); keyMethodMap.setProperty(Constants.MODE_EDIT, "editRole"); keyMethodMap.setProperty(Constants.MODE_NEW, "newRole"); keyMethodMap.setProperty(Constants.MODE_VIEW, "viewRole"); @@ -121,6 +128,17 @@ public class RoleAdminPortalAction extends BaseDispatchAction { return null; }
+ public ActionForward addLdapGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + setRole(request); + + Portal portal = Portal.createPortal(TITLE_ADD_LDAP_GROUPS, PORTLET_ADD_LDAP_GROUPS); + portal.setDialog(true); + request.setAttribute(Constants.PORTAL_KEY, portal); + + return null; + } + public ActionForward editRole(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { setRole(request); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java index dd53eed..3414dab 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/role/ViewAction.java @@ -35,6 +35,7 @@ import org.apache.struts.tiles.ComponentContext; import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.authz.Role; +import org.rhq.core.domain.resource.group.LdapGroup; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.AuthzConstants; import org.rhq.core.domain.util.PageControl; @@ -69,8 +70,10 @@ public class ViewAction extends WorkflowPrepareAction { Subject whoami = RequestUtils.getSubject(request); PageControl pcu = WebUtility.getPageControl(request, "u"); PageControl pcg = WebUtility.getPageControl(request, "g"); + PageControl pcldap = WebUtility.getPageControl(request, "l"); log.trace("user page control: " + pcu); log.trace("group page control: " + pcg); + log.trace("ldap group page control: " + pcldap);
RoleManagerLocal roleManager = LookupUtil.getRoleManager(); ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager(); @@ -101,6 +104,14 @@ public class ViewAction extends WorkflowPrepareAction { request.setAttribute(Constants.NUM_RESGRPS_ATTR, new Integer(groups.getTotalSize())); }
+ PageList<LdapGroup> ldapGroups = roleManager.findLdapGroupsByRole(roleId, pcldap); + request.setAttribute(Constants.ROLE_LDAPGRPS_ATTR, ldapGroups); + if (ldapGroups == null) { + request.setAttribute(Constants.NUM_LDAPGRPS_ATTR, new Integer(0)); + } else { + request.setAttribute(Constants.NUM_LDAPGRPS_ATTR, new Integer(ldapGroups.getTotalSize())); + } + // create and initialize the remove users form RemoveUsersForm rmUsersForm = new RemoveUsersForm(); rmUsersForm.setR(roleId); diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/AttrConstants.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/AttrConstants.java index 5c82d46..6c87a4f 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/AttrConstants.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/AttrConstants.java @@ -233,6 +233,12 @@ public interface AttrConstants { public static final String ROLE_RESGRPS_ATTR = "RoleResGrps";
/** + * The request scope attribute under which actions store the <code>List</code> of <code>LDAPGroupValue</code> + * objects for the requested role. + */ + public static final String ROLE_LDAPGRPS_ATTR = "RoleLdapGrps"; + + /** * The request scope attribute under which actions store the number of <code>AuthzSubjectValue</code> objects in the * associated <code>List</code>. */ @@ -298,6 +304,12 @@ public interface AttrConstants { public static final String NUM_RESGRPS_ATTR = "NumResGrps";
/** + * The request scope attribute under which actions store the number of <code>LdapGroupValue</code> objects in + * the associated <code>List</code>. + */ + public static final String NUM_LDAPGRPS_ATTR = "NumLdapGrps"; + + /** * The request scope attribute under which actions store the full <code>List</code> of <code> * ResourceGroupValue</code> objects. */ diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/ParamConstants.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/ParamConstants.java index a659e89..8847962 100755 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/ParamConstants.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/legacy/ParamConstants.java @@ -457,6 +457,12 @@ public interface ParamConstants {
/** * a value for a standard request paramater mode.<br> + * signify adding ldap groups for a role. + */ + public static final String MODE_ADD_LDAP_GROUPS = "addLdapGroups"; + + /** + * a value for a standard request paramater mode.<br> * signify displaying a list of items */ public static final String MODE_ADD = "add"; diff --git a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties index e95869f..62af674 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties +++ b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties @@ -280,6 +280,7 @@ admin.role.ViewRoleTitle=${product.shortName} View Role - {0} admin.role.EditRoleTitle=${product.shortName} Edit Role Properties and Permissions - {0} admin.role.AddRoleUsersTitle=${product.shortName} Edit Role Assign Users To Role - {0} admin.role.AddRoleGroupsTitle=${product.shortName} Edit Role Assign Groups To Role - {0} +admin.role.AddRoleLdapGroupsTitle=${product.shortName} Edit Role Assign LDAP Groups To Role - {0} admin.role.AlertNotificationTimeRangeTitle=${product.shortName} Edit Role Alert Notification Time Range - {0} admin.role.ChangeRoleOwnerTitle=${product.shortName} Change Owner - {0} admin.role.error.StaticRole=You cannot alter the roles for one or more of these users @@ -342,7 +343,8 @@ admin.role.add.users=Edit {0}: Assign Users to Role admin.role.groups.GroupsTab=Groups admin.role.groups.AssignToRoleTab=Assign To Role admin.role.groups.NewResourceGroupButton=New Group... -admin.role.groups.AssignedGroupsTab=Assigned Groups +admin.role.groups.AssignedGroupsTab=Assigned Resource Groups +admin.role.groups.AssignedLdapGroupsTab=Assigned LDAP Groups # admin.role.list.NameTH=Name admin.role.list.OwnerTH=Owner @@ -362,9 +364,11 @@ admin.role.confirm.Create=Role {0} has been created. admin.role.confirm.Edit=Your changes have been saved. admin.role.confirm.AddUsers=The requested users have been assigned to the role. admin.role.confirm.AddResourceGroups=The requested groups have been assigned to the role. +admin.role.confirm.AddLdapGroups=The requested groups have been assigned to the role. admin.role.confirm.Remove=The requested roles have been removed. admin.role.confirm.RemoveUsers=The requested users have been removed. admin.role.confirm.RemoveResourceGroups=The requested groups have been removed. +admin.role.confirm.RemoveLdapGroups=The requested groups have been removed. admin.role.confirm.ChangeOwner=The owner has been changed. # admin.role.error.RoleNotFound=The specified role does not exist. diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml index 76321ce..d18f2d4 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/struts-config.xml @@ -30,6 +30,8 @@ type="org.rhq.enterprise.gui.admin.role.RemoveUsersForm"/> <form-bean name="AddRoleResourceGroupsForm" type="org.rhq.enterprise.gui.admin.role.AddResourceGroupsForm"/> + <form-bean name="AddRoleLdapGroupsForm" + type="org.rhq.enterprise.gui.admin.role.AddLdapGroupsForm"/> <form-bean name="RemoveRoleResourceGroupsForm" type="org.rhq.enterprise.gui.admin.role.RemoveResourceGroupsForm"/> <!-- / --> @@ -546,6 +548,46 @@ <forward name="failure" path="/admin/role/RoleAdmin.do?mode=view"/> <forward name="success" path="/admin/role/RoleAdmin.do?mode=view"/> </action> + + + <action path="/admin/role/AddLdapGroupsFormPrepare" + name="AddRoleLdapGroupsForm" + scope="request" + type="org.rhq.enterprise.gui.admin.role.AddLdapGroupsFormPrepareAction"> + <set-property property="title" value="Add+Resource+Group"/> + </action> + + <action path="/admin/role/AddLdapGroups" + type="org.rhq.enterprise.gui.admin.role.AddLdapGroupsAction" + name="AddRoleLdapGroupsForm" + scope="request" + input="/admin/role/RoleAdmin.do?mode=addLdapGroups"> + <set-property property="workflow" value="role/ViewUser"/> + <forward name="cancel" path="/admin/role/RoleAdmin.do?mode=view" + redirect="true"/> + <forward name="reset" path="/admin/role/RoleAdmin.do?mode=addLdapGroups" + redirect="true"/> + <forward name="new" path="/resource/group/Inventory.do?mode=new" redirect="true"/> + <forward name="add" path="/admin/role/RoleAdmin.do?mode=addLdapGroups"/> + <forward name="remove" path="/admin/role/RoleAdmin.do?mode=addLdapGroups"/> + <forward name="failure" path="/admin/role/RoleAdmin.do?mode=addLdapGroups"/> + <forward name="success" path="/admin/role/RoleAdmin.do?mode=view"/> + </action> + + <action path="/admin/role/RemoveLdapGroups" + type="org.rhq.enterprise.gui.admin.role.RemoveLdapGroupsAction" + name="RemoveRoleResourceGroupsForm" + scope="request" + input="/admin/role/RoleAdmin.do?mode=view"> + <forward name="failure" path="/admin/role/RoleAdmin.do?mode=view"/> + <forward name="success" path="/admin/role/RoleAdmin.do?mode=view"/> + </action> + + + + + + <!-- / -->
<action path="/admin/role/ChangeOwnerFormPrepare" diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/admin-def.xml b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/admin-def.xml index 6dac0a0..0559198 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/admin-def.xml +++ b/modules/enterprise/gui/portal-war/src/main/webapp/WEB-INF/tiles/admin-def.xml @@ -73,6 +73,10 @@ controllerUrl="/admin/role/AddResourceGroupsFormPrepare.do" path="/admin/role/AddRoleGroups.jsp"/>
+ <definition name=".admin.role.AddLdapGroups" + controllerUrl="/admin/role/AddLdapGroupsFormPrepare.do" + path="/admin/role/AddLdapRoleGroups.jsp"/> + <definition name=".admin.role.ChangeOwner" controllerUrl="/admin/role/ChangeOwnerFormPrepare.do" path="/admin/role/ChangeRoleOwner.jsp"/> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp new file mode 100644 index 0000000..93ec22e --- /dev/null +++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/AddLdapRoleGroups.jsp @@ -0,0 +1,30 @@ +<%@ page language="java" %> +<%@ page errorPage="/common/Error.jsp" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %> + +<html:form action="/admin/role/AddLdapGroups" method="POST"> + +<tiles:insert definition=".page.title.admin.role"> + <tiles:put name="titleName" beanName="Role" beanProperty="name"/> +</tiles:insert> + +<tiles:insert definition=".portlet.error"/> + +<tiles:insert page="/admin/role/RoleGroupsForm.jsp"> + <tiles:put name="availableResGrps" beanName="AvailableResGrps"/> + <tiles:put name="numAvailableResGrps" beanName="NumAvailableResGrps"/> + <tiles:put name="pendingResGrps" beanName="PendingResGrps"/> + <tiles:put name="numPendingResGrps" beanName="NumPendingResGrps"/> +</tiles:insert> + +<tiles:insert definition=".form.buttons"> + <tiles:put name="addToList" value="true"/> +</tiles:insert> + +<tiles:insert definition=".page.footer"/> + +<html:hidden property="r"/> +</html:form> diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp index 1909ec5..ff4d6f6 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp @@ -12,12 +12,15 @@ <script language="JavaScript" src="<html:rewrite page="/js/listWidget.js"/>" type="text/javascript"></script> <c:set var="userWidgetInstanceName" value="assignedUsers"/> <c:set var="groupWidgetInstanceName" value="assignedGroups"/> +<c:set var="ldapGroupWidgetInstanceName" value="assignedLdapGroups"/> <script type="text/javascript"> var pageData = new Array(); initializeWidgetProperties('<c:out value="${userWidgetInstanceName}"/>'); userWidgetProperties = getWidgetProperties('<c:out value="${userWidgetInstanceName}"/>'); initializeWidgetProperties('<c:out value="${groupWidgetInstanceName}"/>'); groupWidgetProperties = getWidgetProperties('<c:out value="${groupWidgetInstanceName}"/>'); +initializeWidgetProperties('<c:out value="${ldapGroupWidgetInstanceName}"/>'); +ldapGroupWidgetProperties = getWidgetProperties('<c:out value="${ldapGroupWidgetInstanceName}"/>'); </script>
<c:url var="selfPuAction" value="/admin/role/RoleAdmin.do"> @@ -179,25 +182,24 @@ groupWidgetProperties = getWidgetProperties('<c:out value="${groupWidgetInstance <html:form method="POST" action="/admin/role/RemoveLdapGroups">
<tiles:insert definition=".header.tab"> - <tiles:put name="tabKey" value="admin.role.groups.AssignedGroupsTab"/> + <tiles:put name="tabKey" value="admin.role.groups.AssignedLdapGroupsTab"/> </tiles:insert>
<display:table items="${RoleLdapGrps}" var="group" action="${selfPgAction}" - postfix="g" + postfix="ldapGroups" width="100%" cellpadding="0" cellspacing="0">
- <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, groupWidgetProperties, true)" name="listToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox" > - <display:checkboxdecorator name="g" onclick="ToggleSelection(this, groupWidgetProperties, true)" styleClass="listMember"/> + <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, ldapGroupWidgetProperties, true)" name="listToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox" > + <display:checkboxdecorator name="ldapGroups" onclick="ToggleSelection(this, ldapGroupWidgetProperties, true)" styleClass="listMember"/> </display:column>
- <display:column width="25%" property="name" href="/rhq/group/inventory/view.xhtml?category=${group.groupCategory.name}&groupId=${group.id}" title="common.header.Group" - sortAttr="r.name"/> - <display:column width="75%" property="description" title="common.header.Description"/> + <display:column property="name" title="common.header.Group" sortAttr="r.name"/> + </display:table>
<tiles:insert definition=".toolbar.addToList"> <tiles:put name="addToListUrl" value="/admin/role/RoleAdmin.do?mode=addLdapGroups"/> - <tiles:put name="widgetInstanceName" beanName="groupWidgetInstanceName"/> + <tiles:put name="widgetInstanceName" beanName="ldapGroupWidgetInstanceName"/> <tiles:put name="addToListParamName" value="r"/> <tiles:put name="addToListParamValue" beanName="Role" beanProperty="id"/> <tiles:put name="pageList" beanName="RoleLdapGrps"/> diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java index 8762845..bcf7738 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java @@ -21,6 +21,7 @@ package org.rhq.enterprise.server.authz; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Set;
@@ -38,6 +39,7 @@ import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.authz.Role; import org.rhq.core.domain.criteria.RoleCriteria; +import org.rhq.core.domain.resource.group.LdapGroup; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; @@ -88,6 +90,15 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { return roles; }
+ @Override + public PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl) { + Role role = entityManager.find(Role.class, roleId); + if (role == null) { + throw new IllegalArgumentException("Could not find role[" + roleId + "] to lookup ldap Groups on"); + } + return new PageList<LdapGroup>(role.getLdapGroups(), role.getLdapGroups().size(), pageControl); + } + /** * @see org.rhq.enterprise.server.authz.RoleManagerLocal#findRoles(PageControl) */ @@ -431,6 +442,63 @@ public class RoleManagerBean implements RoleManagerLocal, RoleManagerRemote { } }
+ /** + * @see org.rhq.enterprise.server.authz.RoleManagerLocal#addResourceGroupsToRole(Subject, int, int[]) + */ + @RequiredPermission(Permission.MANAGE_SECURITY) + public void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds) { + if ((groupIds != null) && (groupIds.size() > 0)) { + Role role = entityManager.find(Role.class, roleId); + if (role == null) { + throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to"); + } + role.getLdapGroups().size(); // load them in + + for (String groupId : groupIds) { + LdapGroup group = new LdapGroup(); + group.setName(groupId); + if (role == null) { + throw new IllegalArgumentException("Tried to add ldapGroup[" + groupId + "] to role[" + roleId + + "], but resourceGroup was not found"); + } + role.addLdapGroup(group); + } + } + } + + /** + * @see org.rhq.enterprise.server.authz.RoleManagerLocal#removeLdapGroupsFromRole(Subject, int, int[]) + */ + + @RequiredPermission(Permission.MANAGE_SECURITY) + public void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds) { + if ((groupIds != null) && (groupIds.length > 0)) { + Role role = entityManager.find(Role.class, roleId); + if (role == null) { + throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from"); + } + role.getLdapGroups().size(); // load them in + + for (Integer groupId : groupIds) { + LdapGroup doomedGroup = entityManager.find(LdapGroup.class, groupId); + if (doomedGroup == null) { + throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role[" + + roleId + "], but subject was not found"); + } + role.removeLdapGroup(doomedGroup); + } + + Query purgeQuery = entityManager.createNamedQuery(LdapGroup.DELETE_BY_ID); + + List<Integer> ids = new LinkedList<Integer>(); + for (int i : groupIds) { + ids.add(i); + } + purgeQuery.setParameter("ids", ids); + purgeQuery.executeUpdate(); + } + } + private void processDependentPermissions(Role role) { /* * if you can control user/roles, then you can give yourself permissions, too; so we might as well diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java index 58f962a..34b81e0 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerLocal.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.server.authz;
+import java.util.List; import java.util.Set;
import javax.ejb.Local; @@ -26,6 +27,7 @@ import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.authz.Role; import org.rhq.core.domain.criteria.RoleCriteria; +import org.rhq.core.domain.resource.group.LdapGroup; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList;
@@ -159,6 +161,8 @@ public interface RoleManagerLocal {
Role getRole(Subject subject, int roleId);
+ PageList<LdapGroup> findLdapGroupsByRole(int roleId, PageControl pageControl); + PageList<Role> findSubjectAssignedRoles(Subject subject, int subjectId, PageControl pc);
//This is a proxy of getAvailableRolesForSubject but without pendingRoleIds as required by remote spec @@ -198,6 +202,8 @@ public interface RoleManagerLocal {
void addRolesToResourceGroup(Subject subject, int groupId, int[] roleIds);
+ void addLdapGroupsToRole(Subject subject, int roleId, List<String> groupIds); + /** * Removes the given resource groups from the given role. * @@ -209,6 +215,8 @@ public interface RoleManagerLocal {
void removeRolesFromResourceGroup(Subject subject, int groupId, int[] roleIds);
+ void removeLdapGroupsFromRole(Subject subject, int roleId, int[] groupIds); + PageList<Role> findRolesByCriteria(Subject subject, RoleCriteria criteria);
} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java index 12d0787..2c98b0a 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java @@ -166,6 +166,8 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM configOptions.put(Context.SECURITY_PROTOCOL, conf.getProperty(RHQConstants.LDAPProtocol)); configOptions.put("LoginProperty", conf.getProperty(RHQConstants.LDAPLoginProperty)); configOptions.put("Filter", conf.getProperty(RHQConstants.LDAPFilter)); + configOptions.put("GroupFilter", conf.getProperty(RHQConstants.LDAPGroupFilter)); + configOptions.put("GroupMemberFilter", conf.getProperty(RHQConstants.LDAPGroupMember)); configOptions.put("BaseDN", conf.getProperty(RHQConstants.LDAPBaseDN)); configOptions.put("BindDN", conf.getProperty(RHQConstants.LDAPBindDN)); configOptions.put("BindPW", conf.getProperty(RHQConstants.LDAPBindPW)); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java new file mode 100644 index 0000000..86bd8b4 --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/LdapGroupManager.java @@ -0,0 +1,290 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.server.resource.group; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.naming.Context; +import javax.naming.NamingEnumeration; +import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; +import javax.naming.ldap.InitialLdapContext; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.rhq.core.domain.auth.Subject; +import org.rhq.enterprise.server.RHQConstants; +import org.rhq.enterprise.server.system.SystemManagerLocal; +import org.rhq.enterprise.server.util.LookupUtil; +import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory; + +/** + * @author paji + * + */ +public class LdapGroupManager { + private static final LdapGroupManager INSTANCE = new LdapGroupManager(); + private static final String BASEDN_DELIMITER = ";"; + private Log log = LogFactory.getLog(LdapGroupManager.class); + + private LdapGroupManager() { + } + + public static LdapGroupManager getInstance() { + return INSTANCE; + } + + public Set<Map<String, String>> findAvailableGroupsByRole(Subject subject, int roleId) { + SystemManagerLocal manager = LookupUtil.getSystemManager(); + manager.getSystemConfiguration(); + Set<Map<String, String>> ldapSet = new HashSet<Map<String, String>>(); + String[] names = { "bar", "foo" }; + + for (String name : names) { + Map<String, String> group = new HashMap<String, String>(); + group.put("id", name); + group.put("name", name); + group.put("description", name); + ldapSet.add(group); + } + return ldapSet; + } + + /* + * + {BindDN=uid=shaggy,ou=People, dc=rhndev, dc=redhat, dc=com, + java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory, jboss.security.security_domain=JON, + LoginProperty=uid, BaseDN=dc=rhndev,dc=redhat,dc=com, java.naming.provider.url=ldap://fjs-0-16.rhndev.redhat.com, + java.naming.security.protocol=, BindPW=dog8code} + */ + protected boolean test() throws Exception { + + // Load our LDAP specific properties + Properties env = null;// getProperties(); + + // Load the BaseDN + String baseDN = "dc=rhndev,dc=redhat,dc=com"; + + // Load the LoginProperty + String loginProperty = "uid"; + + // Load any search filter + + // Find the user that is calling us + String userName = "sdoo"; + + // Load any information we may need to bind + String bindDN = "uid=shaggy,ou=People, dc=rhndev, dc=redhat, dc=com"; + String bindPW = "dog8code"; + + if (bindDN != null) { + env.setProperty(Context.SECURITY_PRINCIPAL, bindDN); + env.setProperty(Context.SECURITY_CREDENTIALS, bindPW); + env.setProperty(Context.SECURITY_AUTHENTICATION, "simple"); + } + InitialLdapContext ctx = new InitialLdapContext(env, null); + SearchControls searchControls = getSearchControls(); + + // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar. + String filter; + /* if ((searchFilter != null) && (searchFilter.length() != 0)) { + filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))"; + } else { + filter = "(" + loginProperty + "=" + userName + ")"; + } + */ + //filter = "(" + loginProperty + "=" + userName + ")"; + filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName + + ",ou=People, dc=rhndev, dc=redhat, dc=com))"; + + // Loop through each configured base DN. It may be useful + // in the future to allow for a filter to be configured for + // each BaseDN, but for now the filter will apply to all. + String[] baseDNs = baseDN.split(BASEDN_DELIMITER); + log.info(Arrays.asList(baseDNs)); + for (int x = 0; x < baseDNs.length; x++) { + NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls); + log.info(answer.hasMore()); + while (answer.hasMore()) { + // We use the first match + SearchResult si = (SearchResult) answer.next(); + log.info(si); + + /* + // Construct the UserDN + String userDN = si.getName() + "," + baseDNs[x]; + print (userDN); + ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userDN); + ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, "dog8code"); + ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple"); + ctx.reconnect(null);*/ + } + + } + + // If we try all the BaseDN's and have not found a match, return false + return false; + } + + /** + * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,java.lang.String) + */ + protected void buildGroup(Properties options, String userName) { + // Load our LDAP specific properties + Properties env = getProperties(options); + + // Load the BaseDN + String baseDN = (String) options.get(RHQConstants.LDAPBaseDN); + if (baseDN == null) { + // If the BaseDN is not specified, log an error and refuse the login attempt + log.info("BaseDN is not set, refusing login"); + } + + // Load the LoginProperty + String loginProperty = (String) options.get(RHQConstants.LDAPLoginProperty); + if (loginProperty == null) { + // Use the default + loginProperty = "cn"; + } + + String groupFilter = (String) options.get("groupFilter"); + String groupMember = (String) options.get("groupMember"); + + // Load any information we may need to bind + String bindDN = (String) options.get("BindDN"); + String bindPW = (String) options.get("BindPW"); + if (bindDN != null) { + env.setProperty(Context.SECURITY_PRINCIPAL, bindDN); + env.setProperty(Context.SECURITY_CREDENTIALS, bindPW); + env.setProperty(Context.SECURITY_AUTHENTICATION, "simple"); + } + + try { + InitialLdapContext ctx = new InitialLdapContext(env, null); + SearchControls searchControls = getSearchControls(); + String filter = "(&(objectclass=groupOfUniqueNames)(uniqueMember=uid=" + userName + + ",ou=People, dc=rhndev, dc=redhat, dc=com))"; + // Load any search filter + String searchFilter = (String) options.get("Filter"); + // Add the search filter if specified. This only allows for a single search filter.. i.e. foo=bar. + if ((searchFilter != null) && (searchFilter.length() != 0)) { + filter = "(&(" + loginProperty + "=" + userName + ")" + "(" + searchFilter + "))"; + } else { + filter = "(" + loginProperty + "=" + userName + ")"; + } + + // Loop through each configured base DN. It may be useful + // in the future to allow for a filter to be configured for + // each BaseDN, but for now the filter will apply to all. + String[] baseDNs = baseDN.split(BASEDN_DELIMITER); + for (int x = 0; x < baseDNs.length; x++) { + NamingEnumeration answer = ctx.search(baseDNs[x], filter, searchControls); + if (!answer.hasMore()) { + log.debug("User " + userName + " not found for BaseDN " + baseDNs[x]); + + // Nothing found for this DN, move to the next one if we have one. + continue; + } + + // We use the first match + SearchResult si = (SearchResult) answer.next(); + + } + + } catch (Exception e) { + log.info("Failed to validate password: " + e.getMessage()); + } + } + + /** + * Load a default set of properties to use when connecting to the LDAP server. If basic authentication is needed, + * the caller must set Context.SECURITY_PRINCIPAL, Context.SECURITY_CREDENTIALS and Context.SECURITY_AUTHENTICATION + * appropriately. + * + * @return properties that are to be used when connecting to LDAP server + */ + private Properties getProperties(Properties options) { + Properties env = new Properties(options); + // Set our default factory name if one is not given + String factoryName = env.getProperty(Context.INITIAL_CONTEXT_FACTORY); + if (factoryName == null) { + env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + } + + // Setup SSL if requested + String protocol = env.getProperty(Context.SECURITY_PROTOCOL); + if ((protocol != null) && protocol.equals("ssl")) { + String ldapSocketFactory = env.getProperty("java.naming.ldap.factory.socket"); + if (ldapSocketFactory == null) { + env.put("java.naming.ldap.factory.socket", UntrustedSSLSocketFactory.class.getName()); + } + env.put(Context.SECURITY_PROTOCOL, "ssl"); + } + + // Set the LDAP url + String providerUrl = env.getProperty(Context.PROVIDER_URL); + if (providerUrl == null) { + providerUrl = "ldap://localhost:" + (((protocol != null) && protocol.equals("ssl")) ? "636" : "389"); + } + + env.setProperty(Context.PROVIDER_URL, providerUrl); + + // Follow referrals automatically + env.setProperty(Context.REFERRAL, "follow"); + + return env; + } + + /** + * A simple method to construct a SearchControls object for use when doing LDAP searches. All of the defaults are + * used, with the exception of the scope, which is set to SUBTREE rather than the default of ONE_LEVEL + * + * @return controls what is searched in LDAP + */ + private SearchControls getSearchControls() { + // Set the scope to subtree, default is one-level + int scope = SearchControls.SUBTREE_SCOPE; + + // No limit on the time waiting for a response + int timeLimit = 0; + + // No limit on the number of entries returned + long countLimit = 0; + + // Attributes to return. + String[] returnedAttributes = null; + + // Don't return the object + boolean returnObject = false; + + // No dereferencing during the search + boolean deference = false; + + SearchControls constraints = new SearchControls(scope, countLimit, timeLimit, returnedAttributes, returnObject, + deference); + return constraints; + } +} diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java index 7a76b01..2315ee8 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/authz/test/RoleManagerBeanTest.java @@ -27,6 +27,7 @@ import org.testng.annotations.Test; import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.authz.Role; +import org.rhq.core.domain.resource.group.LdapGroup; import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.server.auth.SubjectManagerLocal; @@ -243,4 +244,28 @@ public class RoleManagerBeanTest extends AbstractEJB3Test { getTransactionManager().rollback(); } } + + /** + * Test creating, assigning, removing and deleting roles. + * + * @throws Exception + */ + public void testLdapGroups() throws Exception { + getTransactionManager().begin(); + + try { + Subject superuser = subjectManager.getOverlord(); + createSession(superuser); + + Role role = new Role("role-manager-role"); + role.setFsystem(false); + role = roleManager.createRole(superuser, role); + LdapGroup group = new LdapGroup(); + group.setName("Foo"); + role.addLdapGroup(group); + assert roleManager.findLdapGroupsByRole(role.getId(), PageControl.getUnlimitedInstance()).size() == 1 : "Ldap Group Foo Should be assigned"; + } finally { + getTransactionManager().rollback(); + } + } } \ No newline at end of file
commit 98ea3e7acbf13e94808a796a5478b5195fe59204 Merge: 71e2d92... cbb2b49... Author: Partha Aji paji@redhat.com Date: Thu Mar 4 20:02:34 2010 -0500
Merge branch 'linux-config' into ldap
commit 450dea0ece01d8e2f6c3602a0c7512e695ced5c8 Merge: 44ca5dd... 6278e70... Author: Ian P. Springer <ips@jetengine.(none)> Date: Tue Mar 2 08:49:43 2010 -0500
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 71e2d920463a909506ffee19dfa73c26f074578a Merge: 308b9d3... 6445fb2... Author: Partha Aji paji@redhat.com Date: Mon Mar 1 09:49:24 2010 -0500
Merge branch 'linux-config' into ldap
commit 308b9d3b2caa2f344368d713551c12f879448171 Author: Partha Aji paji@redhat.com Date: Mon Mar 1 09:48:27 2010 -0500
whateve
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java index 029a2b9..ad8ae65 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java @@ -47,6 +47,7 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
@SuppressWarnings("unchecked") public Set<Permission> getExplicitGlobalPermissions(Subject subject) { + entityManager.flush(); Query query = entityManager.createNamedQuery(Subject.QUERY_GET_GLOBAL_PERMISSIONS); query.setParameter("subject", subject); List<Permission> results = query.getResultList();
commit 44ca5dd63fabe53654f1db6b17dfbbefdde1a8cb Author: Ian P. Springer <ips@jetengine.(none)> Date: Fri Feb 26 12:28:45 2010 -0500
jmx plugin will no longer log warning if SIGAR is not available; Agent, rather than PC, will log this warning once at startup, and only if the user has not explicitly disabled native support (https://bugzilla.redhat.com/show_bug.cgi?id=568760) (cherry picked from commit ab1816d9ecc4cc6e81472538fe30ae767ea0de39)
diff --git a/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java b/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java index 27a1375..b2bd37f 100644 --- a/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java +++ b/modules/core/native-system/src/main/java/org/rhq/core/system/SystemInfoFactory.java @@ -29,7 +29,6 @@ import java.lang.reflect.Method; import java.net.URL; import java.util.HashMap; import java.util.Map; -import java.util.TreeMap;
import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -50,6 +49,7 @@ public class SystemInfoFactory { private static final String NATIVE_LIBRARY_CLASS_NAME = "org.hyperic.sigar.Sigar";
private static boolean nativeLibraryLoadable; + private static Throwable nativeLibraryLoadThrowable; private static boolean disabled; private static boolean initialized = false;
@@ -78,10 +78,11 @@ public class SystemInfoFactory {
nativeLibraryLoadable = true; } catch (Throwable t) { - nativeLibraryLoadable = false; // can't load the native libs if we don't even have the JNI classes - LOG - .warn("System info API not accessible on this platform (native shared library not found in java.library.path)."); - LOG.trace("Stack trace...", t); + // We don't have the JNI classes (sigar.jar) and/or the native shared library (e.g. libsigar-amd64-linux.so). + // This might be expected (e.g. the admin console WAR (Embedded Jopr) does not include SIGAR), so don't log + // anything, but store the Throwable, so callers can log the cause when appropriate. + nativeLibraryLoadable = false; + nativeLibraryLoadThrowable = t; }
disabled = !nativeLibraryLoadable; // automatically disable native system info iff the native library is not loadable @@ -170,6 +171,17 @@ public class SystemInfoFactory { }
/** + * Returns a Throwable describing why the native library failed to initialize, or null if the native library + * initialized successfully + * + * @return a Throwable describing why the native library failed to initialize, or null if the native library + * initialized successfully + */ + public static Throwable getNativeLibraryLoadThrowable() { + return nativeLibraryLoadThrowable; + } + + /** * This returns <code>true</code> iff the native libraries have actually been initialized. This will return <code> * false</code> if this factory has been {@link #disableNativeSystemInfo() disabled} from the start (i.e. prior to * the first call to {@link #createSystemInfo()} or {@link #getNativeSystemInfoVersion()}). It will also return @@ -308,7 +320,7 @@ public class SystemInfoFactory { private static String findNativeLibrariesRootDirectory() throws Exception { String rootDir = null; File jniLocation = null; - URL jarLocation = null; + URL jarLocation;
if (isNativeSystemInfoAvailable()) { rootDir = System.getProperty("rhq.native-libraries-root-directory"); diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java index 94513d0..c7e03a1 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java @@ -359,6 +359,11 @@ public class AgentMain { private final AgentRestartCounter m_agentRestartCounter = new AgentRestartCounter();
/** + * The -t command line option was specified. + */ + private boolean m_disableNativeSystem; + + /** * The main method that starts the whole thing. * * @param args @@ -2056,9 +2061,20 @@ public class AgentMain { * disabled no matter what this method decides to do. */ private void prepareNativeSystem() { - if (m_configuration.isNativeSystemDisabled() && !SystemInfoFactory.isNativeSystemInfoDisabled()) { - SystemInfoFactory.disableNativeSystemInfo(); - LOG.info(AgentI18NResourceKeys.NATIVE_SYSTEM_DISABLED); + if (m_disableNativeSystem || m_configuration.isNativeSystemDisabled()) { + if (!SystemInfoFactory.isNativeSystemInfoDisabled()) { + SystemInfoFactory.disableNativeSystemInfo(); + LOG.info(AgentI18NResourceKeys.NATIVE_SYSTEM_DISABLED); + } + } else { + if (!SystemInfoFactory.isNativeSystemInfoAvailable()) { + Throwable t = SystemInfoFactory.getNativeLibraryLoadThrowable(); + if (LOG.isDebugEnabled()) { + LOG.debug(AgentI18NResourceKeys.NATIVE_SYSINFO_UNAVAILABLE_DEBUG, t); + } else { + LOG.warn(AgentI18NResourceKeys.NATIVE_SYSINFO_UNAVAILABLE); + } + } }
return; @@ -2814,8 +2830,7 @@ public class AgentMain { }
case 't': { - SystemInfoFactory.disableNativeSystemInfo(); - LOG.info(AgentI18NResourceKeys.NATIVE_SYSTEM_DISABLED); + m_disableNativeSystem = true; } } } diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java index e098b2b..08d4311 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java @@ -519,6 +519,15 @@ public interface AgentI18NResourceKeys { @I18NMessage("Neither server auto-detection nor polling is enabled - the client will be allowed to start sending commands immediately, but when the server is offline, be prepared for alot of errors to be logged") String NO_AUTO_DETECT = "AgentMain.no-auto-detect";
+ @I18NMessage("Native system info is enabled, but the system info API is not accessible on this platform " + + "(sigar.jar not found in classpath or SIGAR shared library not found in shared library path). " + + "Enable DEBUG logging for more details.") + String NATIVE_SYSINFO_UNAVAILABLE = "AgentMain.native-sysinfo-unavailable"; + + @I18NMessage("Native system info is enabled, but the system info API is not accessible on this platform " + + "(sigar.jar not found in classpath or SIGAR shared library not found in shared library path).") + String NATIVE_SYSINFO_UNAVAILABLE_DEBUG = "AgentMain.native-sysinfo-unavailable-debug"; + @I18NMessage("The agent encountered an error during startup and must abort") String STARTUP_ERROR = "AgentMain.startup-error";
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java index 84ae286..ce8631a 100644 --- a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXDiscoveryComponent.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. + * Copyright (C) 2005-2010 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFactory; import org.rhq.core.domain.configuration.Configuration; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails; +import org.rhq.core.pluginapi.inventory.ProcessScanResult; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext; import org.rhq.core.pluginapi.inventory.ManualAddFacet; @@ -66,8 +67,8 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual
public static final String ADDITIONAL_CLASSPATH_ENTRIES = "additionalClassPathEntries";
- /* Ignore certain processes that are managed by their own plugin. For example The Tomcat plugin will - * handle tomcat processes configured for JMX management. + /* Ignore certain processes that are managed by their own plugin. For example, the Tomcat plugin will + * handle Tomcat processes configured for JMX management. */ private static final String[] PROCESS_FILTERS;
@@ -79,7 +80,7 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual processFilters = env.split(","); } } catch (Throwable t) { - log.error("Can't determine process filters, using default. Cause: " + t); + log.error("Can't determine process filters; using default... Cause: " + t); } finally { PROCESS_FILTERS = processFilters; } @@ -135,10 +136,11 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual // }
try { - List<ProcessInfo> processes = context.getSystemInformation().getProcesses("process|basename|match=^java.*"); + List<ProcessScanResult> processes = context.getAutoDiscoveredProcesses();
- for (ProcessInfo process : processes) { - DiscoveredResourceDetails details = discoverProcess(context, process); + for (ProcessScanResult process : processes) { + ProcessInfo processInfo = process.getProcessInfo(); + DiscoveredResourceDetails details = discoverProcess(context, processInfo); if (details != null) { boolean isFiltered = false; for (String filter : PROCESS_FILTERS) { @@ -153,10 +155,11 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual } } } catch (Exception e) { - if (log.isDebugEnabled()) - log.debug("Unable to complete base jmx server discovery.", e); - else - log.warn("Unable to complete base jmx server discovery (enable DEBUG for stack): " + e); + if (log.isDebugEnabled()) { + log.debug("Unable to complete base JMX server discovery.", e); + } else { + log.warn("Unable to complete base JMX server discovery (enable DEBUG for stack): " + e); + } }
return found; @@ -228,12 +231,16 @@ public class JMXDiscoveryComponent implements ResourceDiscoveryComponent, Manual String arg = process.getCommandLine()[i];
if (!arg.startsWith("-")) { - if (arg.length() < 200) { // don't use it if its really long, that's an ugly resource name + if (arg.length() <= 200) { name = arg; - break; + } else { + // Truncate it if it's really long for a more palatable Resource name. + name = arg.substring(arg.length() - 200); } + break; } else if (arg.equals("-cp") || arg.equals("-classpath")) { - i++; // skip the next arg, its the classpath, we don't want that as the name + // Skip the next arg - it's the classpath, and we don't want that as the name. + i++; } }
diff --git a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml index bcec166..a8131c8 100644 --- a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml @@ -69,6 +69,8 @@
</plugin-configuration>
+ <process-scan name="java" query="process|basename|match=^java.*"/> + <help> <![CDATA[ <p>In order to monitor your Java applications via JMX, you need to expose their MBeans to remote JMX clients.
commit c84a76b89d8c197a3cd3f5dca03ac23e5cf519d5 Merge: 84c5d00... 991b94d... Author: Partha Aji paji@redhat.com Date: Fri Feb 26 11:47:33 2010 -0500
Merge branch 'linux-config' into ldap
commit 84c5d0010c7855544018cdc08e8a0f6c4099703e Author: Shannon Hughes shughes@scooby.rdu.redhat.com Date: Thu Feb 25 16:12:53 2010 -0500
initial ldap group block
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp index 017e832..1909ec5 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/role/ViewRole.jsp @@ -173,6 +173,43 @@ groupWidgetProperties = getWidgetProperties('<c:out value="${groupWidgetInstance </c:if> </c:if>
+<c:if test="${not Role.fsystem}"> +<c:if test="${useroperations['MANAGE_SECURITY']}"> + +<html:form method="POST" action="/admin/role/RemoveLdapGroups"> + +<tiles:insert definition=".header.tab"> + <tiles:put name="tabKey" value="admin.role.groups.AssignedGroupsTab"/> +</tiles:insert> + +<display:table items="${RoleLdapGrps}" var="group" action="${selfPgAction}" + postfix="g" + width="100%" cellpadding="0" cellspacing="0"> + + <display:column width="1%" property="id" title="<input type="checkbox" onclick="ToggleAll(this, groupWidgetProperties, true)" name="listToggleAll">" isLocalizedTitle="false" styleClass="ListCellCheckbox" headerStyleClass="ListHeaderCheckbox" > + <display:checkboxdecorator name="g" onclick="ToggleSelection(this, groupWidgetProperties, true)" styleClass="listMember"/> + </display:column> + + <display:column width="25%" property="name" href="/rhq/group/inventory/view.xhtml?category=${group.groupCategory.name}&groupId=${group.id}" title="common.header.Group" + sortAttr="r.name"/> + <display:column width="75%" property="description" title="common.header.Description"/> +</display:table> + +<tiles:insert definition=".toolbar.addToList"> + <tiles:put name="addToListUrl" value="/admin/role/RoleAdmin.do?mode=addLdapGroups"/> + <tiles:put name="widgetInstanceName" beanName="groupWidgetInstanceName"/> + <tiles:put name="addToListParamName" value="r"/> + <tiles:put name="addToListParamValue" beanName="Role" beanProperty="id"/> + <tiles:put name="pageList" beanName="RoleLdapGrps"/> + <tiles:put name="pageAction" beanName="selfPgAction"/> + <tiles:put name="postfix" value="g"/> +</tiles:insert> + +<html:hidden property="r"/> +</html:form> +</c:if> +</c:if> + <tiles:insert definition=".page.return"> <tiles:put name="returnUrl" value="/admin/role/RoleAdmin.do?mode=list"/> <tiles:put name="returnKey" value="admin.role.view.ReturnToRoles"/>
commit 3e1622402c2fa5724f505065c5b89512fa7da664 Merge: 59a906f... a986379... Author: Partha Aji paji@redhat.com Date: Thu Feb 25 10:19:20 2010 -0500
Merge branch 'linux-config' into ldap
commit 59a906f82c207c0128ad5be30dfc4c112775dbf9 Author: Partha Aji paji@redhat.com Date: Wed Feb 24 19:41:44 2010 -0500
Removed the unused is_ldap column from RHQ_SUBJECT_ROLE_MAP since we are using RHQ_SUBJECT_ROLE_LDAP_MAP for that information
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml index 1eaa6f8..6e0a31e 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml @@ -72,7 +72,6 @@ <table name="RHQ_SUBJECT_ROLE_MAP"> <column name="SUBJECT_ID" required="true" type="INTEGER" references="RHQ_SUBJECT"/> <column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/> - <column name="IS_LDAP" required="true" type="BOOLEAN" default="false"/>
<constraint name="RHQ_SUBJECT_ROLE_MAPPING_KEY"> <primaryKey>
commit b9287ab8a2ff37eed95fc7883504db0a7130c7c1 Author: Partha Aji paji@redhat.com Date: Wed Feb 24 19:32:04 2010 -0500
Mapping For Solution 2 Done
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index c7d895b..9b991cd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -40,7 +40,6 @@ import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.QueryHint; import javax.persistence.SequenceGenerator; @@ -228,18 +227,19 @@ public class Subject implements Externalizable { @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }) private Configuration configuration;
- @OneToMany(mappedBy = "subject") - private Set<SubjectRoleEntity> subjectRoles; + @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") }) + @ManyToMany + private java.util.Set<Role> roles;
+ @JoinTable(name = "RHQ_SUBJECT_ROLE_LDAP_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") }) @ManyToMany - @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") }) - private Set<Role> roles = new HashSet<Role>(); + private java.util.Set<Role> ldapRoles;
@Transient private Integer sessionId = null;
private void init() { - subjectRoles = new HashSet<SubjectRoleEntity>(); + roles = new HashSet<Role>(); }
/** @@ -364,51 +364,44 @@ public class Subject implements Externalizable { this.configuration = configuration; }
- public Set<SubjectRoleEntity> getSubjectRoles() { - if (subjectRoles == null) { - subjectRoles = new HashSet<SubjectRoleEntity>(); + public java.util.Set<Role> getRoles() { + if (this.roles == null) { + this.roles = new HashSet<Role>(); } - return subjectRoles; - } - - public void setSubjectRoles(Set<SubjectRoleEntity> subjectRolesIn) { - subjectRoles = subjectRolesIn; - }
- public Set<Role> getRoles() { - if (roles == null) { - roles = new HashSet<Role>(); - } - return roles; + return this.roles; }
public void setRoles(Set<Role> roles) { this.roles = roles; }
- public void addRole(Role role, boolean ldap) { - SubjectRoleEntity s = new SubjectRoleEntity(); - s.setSubject(this); - s.setRole(role); - s.setLdap(ldap); - getSubjectRoles().add(s); - } - public void addRole(Role role) { - addRole(role, false); + getRoles().add(role); }
public void removeRole(Role role) { - SubjectRoleEntity toRemove = null; - for (SubjectRoleEntity s : getSubjectRoles()) { - if (s.getSubject().equals(this) && s.getRole().equals(role)) { - toRemove = s; - break; - } - } - if (toRemove != null) { - getSubjectRoles().remove(toRemove); + getRoles().remove(role); + } + + public java.util.Set<Role> getLdapRoles() { + if (this.ldapRoles == null) { + this.ldapRoles = new HashSet<Role>(); } + + return this.ldapRoles; + } + + public void setLdapRoles(Set<Role> roles) { + this.ldapRoles = roles; + } + + public void addLdapRole(Role role) { + getLdapRoles().add(role); + } + + public void removeLdapRole(Role role) { + getLdapRoles().remove(role); }
@Override @@ -517,7 +510,7 @@ public class Subject implements Externalizable { this.factive = in.readBoolean(); this.fsystem = in.readBoolean(); this.configuration = (Configuration) in.readObject(); - setRoles((Set<Role>) in.readObject()); + this.roles = (Set<Role>) in.readObject(); this.sessionId = in.readInt(); }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java deleted file mode 100644 index 3636fb5..0000000 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.core.domain.auth; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; - -import org.rhq.core.domain.authz.Role; - -@Entity -@IdClass(SubjectRolePK.class) -@Table(name = "RHQ_SUBJECT_ROLE_MAP") -public class SubjectRoleEntity implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - - @Id - private Subject subject; - - @Id - private Role role; - - @Column(name = "IS_LDAP") - private boolean isLdap; - - public Subject getSubject() { - return subject; - } - - public void setSubject(Subject subject) { - this.subject = subject; - } - - public Role getRole() { - return role; - } - - public void setRole(Role role) { - this.role = role; - } - - public boolean isLdap() { - return isLdap; - } - - public void setLdap(boolean isLdap) { - this.isLdap = isLdap; - } - - @Override - public int hashCode() { - final int PRIME = 31; - int result = 1; - result = (PRIME * result) + ((subject == null) ? 0 : subject.hashCode()); - result = (PRIME * result) + ((role == null) ? 0 : role.hashCode()); - result = (PRIME * result) + ((isLdap) ? 0 : PRIME); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if ((obj == null) || !(obj instanceof SubjectRoleEntity)) { - return false; - } - - final SubjectRoleEntity other = (SubjectRoleEntity) obj; - if (subject == null) { - if (other.subject != null) { - return false; - } - } else if (!subject.equals(other.subject)) { - return false; - } - - if (role == null) { - if (other.role != null) { - return false; - } - } else if (!role.equals(other.role)) { - return false; - } - - return isLdap == other.isLdap; - } -} diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java deleted file mode 100644 index 8b6259c..0000000 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.core.domain.auth; - -import java.io.Serializable; - -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; - -import org.rhq.core.domain.authz.Role; - -/** - * @author paji - * - */ -public class SubjectRolePK implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - @ManyToOne - @JoinColumn(name = "USER_ID", referencedColumnName = "ID") - private Subject subject; - - @ManyToOne - @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID") - private Role role; -} diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index 5267fca..b7004bd 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -37,7 +37,6 @@ import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; -import javax.persistence.OneToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table;
@@ -47,7 +46,6 @@ import org.hibernate.annotations.CollectionOfElements; import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.auth.SubjectRoleEntity;
/** * A role has zero or more {@link org.rhq.core.domain.resource.group.ResourceGroup}s assigned to it. You can assign a @@ -106,11 +104,11 @@ public class Role implements Serializable { @Column(name = "FSYSTEM") private Boolean fsystem;
- @OneToMany(mappedBy = "role") - private java.util.Set<SubjectRoleEntity> roleSubjects; - @ManyToMany(mappedBy = "roles") - private Set<Subject> subjects = new HashSet<Subject>(); + private java.util.Set<Subject> subjects = new HashSet<Subject>(); + + @ManyToMany(mappedBy = "ldapRoles") + private java.util.Set<Subject> ldapSubjects = new HashSet<Subject>();
@ManyToMany(mappedBy = "roles") private java.util.Set<org.rhq.core.domain.resource.group.ResourceGroup> resourceGroups = new HashSet<org.rhq.core.domain.resource.group.ResourceGroup>(); @@ -183,52 +181,56 @@ public class Role implements Serializable { return this.permissions.remove(permission); }
- public Set<SubjectRoleEntity> getRoleSubjects() { - if (roleSubjects == null) { - roleSubjects = new HashSet<SubjectRoleEntity>(); - } - return roleSubjects; + public java.util.Set<Subject> getSubjects() { + return subjects; }
- public void setRoleSubjects(Set<SubjectRoleEntity> subjectsIn) { - roleSubjects = subjectsIn; + public void setSubjects(Set<Subject> subjects) { + this.subjects = subjects; }
- public java.util.Set<Subject> getSubjects() { - if (subjects == null) { - subjects = new HashSet<Subject>(); + public void addSubject(Subject subject) { + if (this.subjects == null) { + this.subjects = new HashSet<Subject>(); } - return subjects; + + subject.addRole(this); + this.subjects.add(subject); }
- public void setSubjects(Set<Subject> subjects) { - this.subjects = subjects; + public void removeSubject(Subject subject) { + if (this.subjects == null) { + this.subjects = new HashSet<Subject>(); + } + + subject.removeRole(this); + this.subjects.remove(subject); }
- public void addSubject(Subject subject, boolean ldap) { - SubjectRoleEntity s = new SubjectRoleEntity(); - s.setSubject(subject); - s.setRole(this); - s.setLdap(ldap); - getRoleSubjects().add(s); + public java.util.Set<Subject> getLdapSubjects() { + return ldapSubjects; }
- public void addSubject(Subject subject) { - addSubject(subject, false); + public void setLdapSubjects(Set<Subject> subjects) { + this.ldapSubjects = subjects; }
- public void removeSubject(Subject subject) { - SubjectRoleEntity toRemove = null; - for (SubjectRoleEntity s : getRoleSubjects()) { - if (s.getSubject().equals(subject) && s.getRole().equals(this)) { - toRemove = s; - break; - } + public void addLdapSubject(Subject subject) { + if (this.ldapSubjects == null) { + this.ldapSubjects = new HashSet<Subject>(); } - if (toRemove != null) { - getRoleSubjects().remove(toRemove); - subject.removeRole(this); + + subject.addLdapRole(this); + this.ldapSubjects.add(subject); + } + + public void removeLdapSubject(Subject subject) { + if (this.ldapSubjects == null) { + this.ldapSubjects = new HashSet<Subject>(); } + + subject.removeLdapRole(this); + this.ldapSubjects.remove(subject); }
public Set<org.rhq.core.domain.resource.group.ResourceGroup> getResourceGroups() {
commit 8d87c981864acc5720869f0f651c9890f8653b0b Author: Partha Aji paji@redhat.com Date: Wed Feb 24 19:05:22 2010 -0500
Initial commit for solution 2
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml index dcb993b..1eaa6f8 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml @@ -82,4 +82,14 @@ </constraint> </table>
+ <table name="RHQ_SUBJECT_ROLE_LDAP_MAP"> + <column name="SUBJECT_ID" required="true" type="INTEGER" references="RHQ_SUBJECT"/> + <column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/> + <constraint name="RHQ_SUBJECT_ROLE_LDAP_MAPPING_KEY"> + <primaryKey> + <field ref="SUBJECT_ID"/> + <field ref="ROLE_ID"/> + </primaryKey> + </constraint> + </table> </dbsetup>
commit 04fad7aae80087e6c5a0e9981d1115159873af8f Author: Partha Aji paji@redhat.com Date: Wed Feb 24 16:06:01 2010 -0500
Added back the Many To Many roles magic to preserve roles variable
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index 73d074a..c7d895b 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -36,6 +36,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; @@ -229,6 +231,10 @@ public class Subject implements Externalizable { @OneToMany(mappedBy = "subject") private Set<SubjectRoleEntity> subjectRoles;
+ @ManyToMany + @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") }) + private Set<Role> roles = new HashSet<Role>(); + @Transient private Integer sessionId = null;
@@ -370,22 +376,14 @@ public class Subject implements Externalizable { }
public Set<Role> getRoles() { - Set<Role> r = new HashSet<Role>(); - for (SubjectRoleEntity s : getSubjectRoles()) { - r.add(s.getRole()); + if (roles == null) { + roles = new HashSet<Role>(); } - return r; + return roles; }
public void setRoles(Set<Role> roles) { - Set<SubjectRoleEntity> sroles = getSubjectRoles(); - sroles.clear(); - for (Role r : roles) { - SubjectRoleEntity s = new SubjectRoleEntity(); - s.setSubject(this); - s.setRole(r); - sroles.add(s); - } + this.roles = roles; }
public void addRole(Role role, boolean ldap) { @@ -501,7 +499,7 @@ public class Subject implements Externalizable { out.writeBoolean(factive); out.writeBoolean(fsystem); out.writeObject(configuration); - out.writeObject(getRoles()); + out.writeObject(roles); // not supplied by remote: subjectNotifications out.writeInt(this.sessionId == null ? 0 : this.sessionId); } diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index d549027..5267fca 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -110,6 +110,9 @@ public class Role implements Serializable { private java.util.Set<SubjectRoleEntity> roleSubjects;
@ManyToMany(mappedBy = "roles") + private Set<Subject> subjects = new HashSet<Subject>(); + + @ManyToMany(mappedBy = "roles") private java.util.Set<org.rhq.core.domain.resource.group.ResourceGroup> resourceGroups = new HashSet<org.rhq.core.domain.resource.group.ResourceGroup>();
@Cascade( { CascadeType.ALL }) @@ -192,22 +195,14 @@ public class Role implements Serializable { }
public java.util.Set<Subject> getSubjects() { - Set<Subject> s = new HashSet<Subject>(); - for (SubjectRoleEntity sre : getRoleSubjects()) { - s.add(sre.getSubject()); + if (subjects == null) { + subjects = new HashSet<Subject>(); } - return s; + return subjects; }
public void setSubjects(Set<Subject> subjects) { - Set<SubjectRoleEntity> sroles = getRoleSubjects(); - sroles.clear(); - for (Subject subject : subjects) { - SubjectRoleEntity s = new SubjectRoleEntity(); - s.setRole(this); - s.setSubject(subject); - sroles.add(s); - } + this.subjects = subjects; }
public void addSubject(Subject subject, boolean ldap) {
commit 09f0af7201c726cd1806d232164d2ea40c1470d2 Author: Shannon Hughes shughes@scooby.rdu.redhat.com Date: Wed Feb 24 14:16:54 2010 -0500
added ldap group member txt field for ldap configs
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java index 6e95ef7..4f35fe6 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java @@ -61,6 +61,7 @@ public class SystemConfigForm extends BaseValidatorForm { private String ldapSearchBase = ""; private String ldapSearchFilter = ""; private String ldapGroupFilter = ""; + private String ldapGroupMember = ""; private String ldapUsername = ""; private String ldapPassword = ""; private Boolean ldapEnabled = null; @@ -85,6 +86,7 @@ public class SystemConfigForm extends BaseValidatorForm { buf.append(" ldapUsername=").append(ldapUsername); buf.append(" ldapPassword=").append(ldapPassword); buf.append(" ldapGroupFilter=").append(ldapGroupFilter); + buf.append(" ldapGroupMember=").append(ldapGroupMember);
return buf.toString(); } @@ -128,6 +130,7 @@ public class SystemConfigForm extends BaseValidatorForm { ldapUsername = ""; ldapPassword = ""; ldapGroupFilter = ""; + ldapGroupMember = "";
super.reset(mapping, request); } @@ -217,6 +220,7 @@ public class SystemConfigForm extends BaseValidatorForm { ldapSearchBase = prop.getProperty(RHQConstants.LDAPBaseDN); ldapSearchFilter = prop.getProperty(RHQConstants.LDAPFilter); ldapGroupFilter = prop.getProperty(RHQConstants.LDAPGroupFilter); + ldapGroupMember = prop.getProperty(RHQConstants.LDAPGroupMember); ldapUsername = prop.getProperty(RHQConstants.LDAPBindDN); ldapPassword = prop.getProperty(RHQConstants.LDAPBindPW);
@@ -317,6 +321,7 @@ public class SystemConfigForm extends BaseValidatorForm { prop.setProperty(RHQConstants.LDAPBaseDN, ldapSearchBase); prop.setProperty(RHQConstants.LDAPFilter, ldapSearchFilter); prop.setProperty(RHQConstants.LDAPGroupFilter, ldapGroupFilter); + prop.setProperty(RHQConstants.LDAPGroupMember, ldapGroupMember); prop.setProperty(RHQConstants.LDAPBindDN, ldapUsername); prop.setProperty(RHQConstants.LDAPBindPW, ldapPassword); prop.setProperty(RHQConstants.LDAPProtocol, ldapSsl ? "ssl" : ""); @@ -572,6 +577,14 @@ public class SystemConfigForm extends BaseValidatorForm { ldapGroupFilter = s; }
+ public String getLdapGroupMember() { + return ldapGroupFilter; + } + + public void setLdapGroupMember(String s) { + ldapGroupMember = s; + } + public String getLdapUsername() { return ldapUsername; } diff --git a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties index c65317a..e95869f 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties +++ b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties @@ -631,6 +631,7 @@ admin.settings.LDAPHostNameLabel=LDAP Host Name: admin.settings.LDAPUsernameLabel=Username: admin.settings.LDAPSearchFilterLabel=Search Filter: admin.settings.LDAPGroupSearchLabel=Group Search Filter: +admin.settings.LDAPGroupMemberLabel=Group Member Filter: admin.settings.LDAPPortLabel=LDAP Port: admin.settings.LDAPUrlLabel=URL: admin.settings.LDAPSslLabel=SSL: diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp index fbf6955..17f0a20 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp @@ -33,27 +33,34 @@ <tr> <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPUrlLabel"/></td> <td width="30%" class="BlockContent"><html:text size="31" property="ldapUrl"/></td> - <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPSslLabel"/></td> - <td width="30%" class="BlockContent"><html:checkbox property="ldapSsl"/></td> - </tr> - <tr> - <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPUsernameLabel"/></td> - <td width="30%" class="BlockContent"><html:text size="31" property="ldapUsername"/></td> - <td width="20%" class="BlockLabel"><fmt:message key="common.label.Password"/></td> - <td width="30%" class="BlockContent"><html:password size="31" property="ldapPassword" redisplay="true"/></td> - </tr> - <tr> - <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPSearchBaseLabel"/></td> - <td width="30%" class="BlockContent"><html:text size="31" property="ldapSearchBase"/></td> <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPSearchFilterLabel"/></td> <td width="30%" class="BlockContent"><html:text size="31" property="ldapSearchFilter"/></td> </tr> <tr> + <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPSearchBaseLabel"/></td> + <td width="30%" class="BlockContent"><html:text size="31" property="ldapSearchBase"/></td> <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPLoginPropertyLabel"/></td> <td width="30%" class="BlockContent"><html:text size="31" property="ldapLoginProperty"/></td> + </tr> + <tr> + <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPUsernameLabel"/></td> + <td width="30%" class="BlockContent"><html:text size="31" property="ldapUsername"/></td> <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPGroupSearchLabel"/></td> <td width="30%" class="BlockContent"><html:text size="31" property="ldapGroupFilter"/></td> </tr> + <tr> + <td width="20%" class="BlockLabel"><fmt:message key="common.label.Password"/></td> + <td width="30%" class="BlockContent"><html:password size="31" property="ldapPassword" redisplay="true"/></td> + <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPGroupMemberLabel"/></td> + <td width="30%" class="BlockContent"><html:text size="31" property="ldapGroupMember"/></td> + </tr> + <tr> + <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPSslLabel"/></td> + <td width="30%" class="BlockContent"><html:checkbox property="ldapSsl"/></td> + <td width="20%" class="BlockLabel"> </td> + <td width="30%" class="BlockContent"> </td> + </tr> +
<tr> <td colspan="4" class="BlockBottomLine"><html:img page="/images/spacer.gif" width="1" height="1" border="0"/></td> diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java index 8a94231..7bb1d72 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java @@ -47,6 +47,7 @@ public class RHQConstants { public static final String LDAPLoginProperty = "CAM_LDAP_LOGIN_PROPERTY"; public static final String LDAPFilter = "CAM_LDAP_FILTER"; public static final String LDAPGroupFilter = "CAM_LDAP_GROUP_FILTER"; + public static final String LDAPGroupMember = "CAM_LDAP_GROUP_MEMBER"; public static final String LDAPBaseDN = "CAM_LDAP_BASE_DN"; public static final String LDAPBindDN = "CAM_LDAP_BIND_DN"; public static final String LDAPBindPW = "CAM_LDAP_BIND_PW";
commit 9e4ca33363b357405733065e27f98e66d46535c1 Author: Partha Aji paji@redhat.com Date: Wed Feb 24 12:51:22 2010 -0500
More updates on the Mapping
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index 191106e..73d074a 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -226,7 +226,7 @@ public class Subject implements Externalizable { @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }) private Configuration configuration;
- @OneToMany(mappedBy = "user") + @OneToMany(mappedBy = "subject") private Set<SubjectRoleEntity> subjectRoles;
@Transient diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java index ea110f7..3636fb5 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java @@ -37,6 +37,11 @@ import org.rhq.core.domain.authz.Role; @Table(name = "RHQ_SUBJECT_ROLE_MAP") public class SubjectRoleEntity implements Serializable {
+ /** + * + */ + private static final long serialVersionUID = 1L; + @Id private Subject subject;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java index e881b5b..8b6259c 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java @@ -19,6 +19,8 @@
package org.rhq.core.domain.auth;
+import java.io.Serializable; + import javax.persistence.JoinColumn; import javax.persistence.ManyToOne;
@@ -28,7 +30,12 @@ import org.rhq.core.domain.authz.Role; * @author paji * */ -public class SubjectRolePK { +public class SubjectRolePK implements Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + @ManyToOne @JoinColumn(name = "USER_ID", referencedColumnName = "ID") private Subject subject;
commit c5ad7ab61a62cc4ad847a7ea43e30d9dbcf81c48 Merge: 17a885c... 073abeb... Author: Partha Aji paji@redhat.com Date: Wed Feb 24 11:32:03 2010 -0500
Merge branch 'linux-config' into ldap
commit 17a885cd48cf2fed8723b6253154fe2173d4cd58 Author: Partha Aji paji@redhat.com Date: Wed Feb 24 11:30:56 2010 -0500
Added a more accurate mapping for SubjectRoleEntity
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index 023faa3..191106e 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -36,7 +36,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; @@ -227,8 +226,7 @@ public class Subject implements Externalizable { @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }) private Configuration configuration;
- @OneToMany - @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }) + @OneToMany(mappedBy = "user") private Set<SubjectRoleEntity> subjectRoles;
@Transient diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java index fc0b0ed..ea110f7 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java @@ -25,20 +25,22 @@ package org.rhq.core.domain.auth; import java.io.Serializable;
import javax.persistence.Column; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.IdClass; import javax.persistence.Table;
import org.rhq.core.domain.authz.Role;
+@Entity +@IdClass(SubjectRolePK.class) @Table(name = "RHQ_SUBJECT_ROLE_MAP") public class SubjectRoleEntity implements Serializable { - @ManyToOne - @JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID") + + @Id private Subject subject;
- @ManyToOne - @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID") + @Id private Role role;
@Column(name = "IS_LDAP") diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java new file mode 100644 index 0000000..e881b5b --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRolePK.java @@ -0,0 +1,39 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2009 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.core.domain.auth; + +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; + +import org.rhq.core.domain.authz.Role; + +/** + * @author paji + * + */ +public class SubjectRolePK { + @ManyToOne + @JoinColumn(name = "USER_ID", referencedColumnName = "ID") + private Subject subject; + + @ManyToOne + @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID") + private Role role; +} diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index 1e66029..d549027 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -106,8 +106,7 @@ public class Role implements Serializable { @Column(name = "FSYSTEM") private Boolean fsystem;
- @OneToMany - @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "ROLE_ID") }) + @OneToMany(mappedBy = "role") private java.util.Set<SubjectRoleEntity> roleSubjects;
@ManyToMany(mappedBy = "roles")
commit 7789e66b5e5a114e67e2d0bb2bedc3641a33abc0 Author: Partha Aji paji@redhat.com Date: Tue Feb 23 13:21:49 2010 -0500
Updated the addSubject/removeSubject stuff from Role to use SubjectRoleEntity bean
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index 121f555..023faa3 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -231,13 +231,11 @@ public class Subject implements Externalizable { @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }) private Set<SubjectRoleEntity> subjectRoles;
- private Set<Role> roles; - @Transient private Integer sessionId = null;
private void init() { - roles = new HashSet<Role>(); + subjectRoles = new HashSet<SubjectRoleEntity>(); }
/** @@ -505,7 +503,7 @@ public class Subject implements Externalizable { out.writeBoolean(factive); out.writeBoolean(fsystem); out.writeObject(configuration); - out.writeObject(roles); + out.writeObject(getRoles()); // not supplied by remote: subjectNotifications out.writeInt(this.sessionId == null ? 0 : this.sessionId); } @@ -523,7 +521,7 @@ public class Subject implements Externalizable { this.factive = in.readBoolean(); this.fsystem = in.readBoolean(); this.configuration = (Configuration) in.readObject(); - this.roles = (Set<Role>) in.readObject(); + setRoles((Set<Role>) in.readObject()); this.sessionId = in.readInt(); }
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index 4e157c6..1e66029 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -110,8 +110,6 @@ public class Role implements Serializable { @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "ROLE_ID") }) private java.util.Set<SubjectRoleEntity> roleSubjects;
- private java.util.Set<Subject> subjects = new HashSet<Subject>(); - @ManyToMany(mappedBy = "roles") private java.util.Set<org.rhq.core.domain.resource.group.ResourceGroup> resourceGroups = new HashSet<org.rhq.core.domain.resource.group.ResourceGroup>();
@@ -183,30 +181,60 @@ public class Role implements Serializable { return this.permissions.remove(permission); }
+ public Set<SubjectRoleEntity> getRoleSubjects() { + if (roleSubjects == null) { + roleSubjects = new HashSet<SubjectRoleEntity>(); + } + return roleSubjects; + } + + public void setRoleSubjects(Set<SubjectRoleEntity> subjectsIn) { + roleSubjects = subjectsIn; + } + public java.util.Set<Subject> getSubjects() { - return subjects; + Set<Subject> s = new HashSet<Subject>(); + for (SubjectRoleEntity sre : getRoleSubjects()) { + s.add(sre.getSubject()); + } + return s; }
public void setSubjects(Set<Subject> subjects) { - this.subjects = subjects; + Set<SubjectRoleEntity> sroles = getRoleSubjects(); + sroles.clear(); + for (Subject subject : subjects) { + SubjectRoleEntity s = new SubjectRoleEntity(); + s.setRole(this); + s.setSubject(subject); + sroles.add(s); + } }
- public void addSubject(Subject subject) { - if (this.subjects == null) { - this.subjects = new HashSet<Subject>(); - } + public void addSubject(Subject subject, boolean ldap) { + SubjectRoleEntity s = new SubjectRoleEntity(); + s.setSubject(subject); + s.setRole(this); + s.setLdap(ldap); + getRoleSubjects().add(s); + }
- subject.addRole(this); - this.subjects.add(subject); + public void addSubject(Subject subject) { + addSubject(subject, false); }
public void removeSubject(Subject subject) { - if (this.subjects == null) { - this.subjects = new HashSet<Subject>(); + SubjectRoleEntity toRemove = null; + for (SubjectRoleEntity s : getRoleSubjects()) { + if (s.getSubject().equals(subject) && s.getRole().equals(this)) { + toRemove = s; + break; + } + } + if (toRemove != null) { + getRoleSubjects().remove(toRemove); + subject.removeRole(this); } - - subject.removeRole(this); - this.subjects.remove(subject); }
public Set<org.rhq.core.domain.resource.group.ResourceGroup> getResourceGroups() {
commit dcb59bb828983e2879cac829852437e00e0f29d8 Author: Partha Aji paji@redhat.com Date: Tue Feb 23 11:03:16 2010 -0500
More clean up work on Subjects and SubjectRoleEntity
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index f7f6ac2..121f555 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -229,9 +229,9 @@ public class Subject implements Externalizable {
@OneToMany @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }) - private java.util.Set<SubjectRoleEntity> subjectRoles; + private Set<SubjectRoleEntity> subjectRoles;
- private java.util.Set<Role> roles; + private Set<Role> roles;
@Transient private Integer sessionId = null; @@ -362,14 +362,18 @@ public class Subject implements Externalizable { this.configuration = configuration; }
- public java.util.Set<SubjectRoleEntity> getSubjectRoles() { + public Set<SubjectRoleEntity> getSubjectRoles() { if (subjectRoles == null) { subjectRoles = new HashSet<SubjectRoleEntity>(); } return subjectRoles; }
- public java.util.Set<Role> getRoles() { + public void setSubjectRoles(Set<SubjectRoleEntity> subjectRolesIn) { + subjectRoles = subjectRolesIn; + } + + public Set<Role> getRoles() { Set<Role> r = new HashSet<Role>(); for (SubjectRoleEntity s : getSubjectRoles()) { r.add(s.getRole()); @@ -378,15 +382,39 @@ public class Subject implements Externalizable { }
public void setRoles(Set<Role> roles) { - this.roles = roles; + Set<SubjectRoleEntity> sroles = getSubjectRoles(); + sroles.clear(); + for (Role r : roles) { + SubjectRoleEntity s = new SubjectRoleEntity(); + s.setSubject(this); + s.setRole(r); + sroles.add(s); + } + } + + public void addRole(Role role, boolean ldap) { + SubjectRoleEntity s = new SubjectRoleEntity(); + s.setSubject(this); + s.setRole(role); + s.setLdap(ldap); + getSubjectRoles().add(s); }
public void addRole(Role role) { - getRoles().add(role); + addRole(role, false); }
public void removeRole(Role role) { - getRoles().remove(role); + SubjectRoleEntity toRemove = null; + for (SubjectRoleEntity s : getSubjectRoles()) { + if (s.getSubject().equals(this) && s.getRole().equals(role)) { + toRemove = s; + break; + } + } + if (toRemove != null) { + getSubjectRoles().remove(toRemove); + } }
@Override diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java index 369b491..fc0b0ed 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java @@ -1,3 +1,25 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2008 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ package org.rhq.core.domain.auth;
import java.io.Serializable; @@ -11,7 +33,6 @@ import org.rhq.core.domain.authz.Role;
@Table(name = "RHQ_SUBJECT_ROLE_MAP") public class SubjectRoleEntity implements Serializable { - @ManyToOne @JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID") private Subject subject; @@ -47,4 +68,43 @@ public class SubjectRoleEntity implements Serializable { this.isLdap = isLdap; }
+ @Override + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = (PRIME * result) + ((subject == null) ? 0 : subject.hashCode()); + result = (PRIME * result) + ((role == null) ? 0 : role.hashCode()); + result = (PRIME * result) + ((isLdap) ? 0 : PRIME); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if ((obj == null) || !(obj instanceof SubjectRoleEntity)) { + return false; + } + + final SubjectRoleEntity other = (SubjectRoleEntity) obj; + if (subject == null) { + if (other.subject != null) { + return false; + } + } else if (!subject.equals(other.subject)) { + return false; + } + + if (role == null) { + if (other.role != null) { + return false; + } + } else if (!role.equals(other.role)) { + return false; + } + + return isLdap == other.isLdap; + } }
commit 2e83a0cc092f8feef995642502447389152d598e Merge: 3f91c1c... 4c82f06... Author: Partha Aji paji@redhat.com Date: Tue Feb 23 10:20:31 2010 -0500
Merge branch 'linux-config' into ldap
commit 3f91c1ca64b04ae174d42ca3839fa1cdaa99dbbc Author: Partha Aji paji@redhat.com Date: Tue Feb 23 10:09:47 2010 -0500
Adding initial mapping change needed for ldap
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java index f13d6ef..f7f6ac2 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/Subject.java @@ -37,7 +37,6 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; @@ -161,8 +160,7 @@ import org.rhq.core.domain.util.serial.ExternalizableStrategy; + " AND s.fsystem = FALSE " // + " AND s.factive = TRUE"), // @NamedQuery(name = Subject.QUERY_DYNAMIC_CONFIG_VALUES, query = "" // - + "SELECT s.name, s.name FROM Subject AS s WHERE s.fsystem = false") -}) + + "SELECT s.name, s.name FROM Subject AS s WHERE s.fsystem = false") }) @SequenceGenerator(name = "RHQ_SUBJECT_ID_SEQ", sequenceName = "RHQ_SUBJECT_ID_SEQ") @Table(name = "RHQ_SUBJECT") /*@Cache(usage= CacheConcurrencyStrategy.TRANSACTIONAL)*/ @@ -229,8 +227,10 @@ public class Subject implements Externalizable { @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE }) private Configuration configuration;
- @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") }) - @ManyToMany + @OneToMany + @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "SUBJECT_ID") }) + private java.util.Set<SubjectRoleEntity> subjectRoles; + private java.util.Set<Role> roles;
@Transient @@ -362,12 +362,19 @@ public class Subject implements Externalizable { this.configuration = configuration; }
- public java.util.Set<Role> getRoles() { - if (this.roles == null) { - this.roles = new HashSet<Role>(); + public java.util.Set<SubjectRoleEntity> getSubjectRoles() { + if (subjectRoles == null) { + subjectRoles = new HashSet<SubjectRoleEntity>(); } + return subjectRoles; + }
- return this.roles; + public java.util.Set<Role> getRoles() { + Set<Role> r = new HashSet<Role>(); + for (SubjectRoleEntity s : getSubjectRoles()) { + r.add(s.getRole()); + } + return r; }
public void setRoles(Set<Role> roles) { diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java new file mode 100644 index 0000000..369b491 --- /dev/null +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/auth/SubjectRoleEntity.java @@ -0,0 +1,50 @@ +package org.rhq.core.domain.auth; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import org.rhq.core.domain.authz.Role; + +@Table(name = "RHQ_SUBJECT_ROLE_MAP") +public class SubjectRoleEntity implements Serializable { + + @ManyToOne + @JoinColumn(name = "SUBJECT_ID", referencedColumnName = "ID") + private Subject subject; + + @ManyToOne + @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID") + private Role role; + + @Column(name = "IS_LDAP") + private boolean isLdap; + + public Subject getSubject() { + return subject; + } + + public void setSubject(Subject subject) { + this.subject = subject; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + public boolean isLdap() { + return isLdap; + } + + public void setLdap(boolean isLdap) { + this.isLdap = isLdap; + } + +} diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java index 35772bd..4e157c6 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Role.java @@ -47,6 +47,7 @@ import org.hibernate.annotations.CollectionOfElements; import org.jetbrains.annotations.NotNull;
import org.rhq.core.domain.auth.Subject; +import org.rhq.core.domain.auth.SubjectRoleEntity;
/** * A role has zero or more {@link org.rhq.core.domain.resource.group.ResourceGroup}s assigned to it. You can assign a @@ -78,8 +79,7 @@ import org.rhq.core.domain.auth.Subject; + " JOIN ss.roles AS rr " // + " WHERE ss.id = :subjectId )"), // @NamedQuery(name = Role.QUERY_DYNAMIC_CONFIG_VALUES, query = "" // - + "SELECT r.name, r.name FROM Role AS r") -}) + + "SELECT r.name, r.name FROM Role AS r") }) @SequenceGenerator(name = "RHQ_ROLE_ID_SEQ", sequenceName = "RHQ_ROLE_ID_SEQ") @Table(name = "RHQ_ROLE") public class Role implements Serializable { @@ -106,7 +106,10 @@ public class Role implements Serializable { @Column(name = "FSYSTEM") private Boolean fsystem;
- @ManyToMany(mappedBy = "roles") + @OneToMany + @JoinTable(name = "RHQ_SUBJECT_ROLE_MAP", joinColumns = { @JoinColumn(name = "ROLE_ID") }) + private java.util.Set<SubjectRoleEntity> roleSubjects; + private java.util.Set<Subject> subjects = new HashSet<Subject>();
@ManyToMany(mappedBy = "roles")
commit 204c6b7de81df429eae5a506c36a84f0ddb7bdc2 Merge: e09efb0... 2ae22a1... Author: Partha Aji paji@redhat.com Date: Mon Feb 22 13:06:45 2010 -0500
Merge branch 'linux-config' into ldap
commit e09efb07b5c91f0a7889d2a6bb58ba41c1ac25c6 Author: Partha Aji paji@redhat.com Date: Mon Feb 22 12:59:31 2010 -0500
Intial config setup for LDAP stuff..
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java index c636aa2..6e95ef7 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/config/SystemConfigForm.java @@ -60,6 +60,7 @@ public class SystemConfigForm extends BaseValidatorForm { private String ldapLoginProperty = ""; private String ldapSearchBase = ""; private String ldapSearchFilter = ""; + private String ldapGroupFilter = ""; private String ldapUsername = ""; private String ldapPassword = ""; private Boolean ldapEnabled = null; @@ -83,6 +84,7 @@ public class SystemConfigForm extends BaseValidatorForm { buf.append(" ldapSearchFilter=").append(ldapSearchFilter); buf.append(" ldapUsername=").append(ldapUsername); buf.append(" ldapPassword=").append(ldapPassword); + buf.append(" ldapGroupFilter=").append(ldapGroupFilter);
return buf.toString(); } @@ -125,6 +127,7 @@ public class SystemConfigForm extends BaseValidatorForm { ldapSearchFilter = ""; ldapUsername = ""; ldapPassword = ""; + ldapGroupFilter = "";
super.reset(mapping, request); } @@ -213,6 +216,7 @@ public class SystemConfigForm extends BaseValidatorForm { ldapLoginProperty = prop.getProperty(RHQConstants.LDAPLoginProperty); ldapSearchBase = prop.getProperty(RHQConstants.LDAPBaseDN); ldapSearchFilter = prop.getProperty(RHQConstants.LDAPFilter); + ldapGroupFilter = prop.getProperty(RHQConstants.LDAPGroupFilter); ldapUsername = prop.getProperty(RHQConstants.LDAPBindDN); ldapPassword = prop.getProperty(RHQConstants.LDAPBindPW);
@@ -312,6 +316,7 @@ public class SystemConfigForm extends BaseValidatorForm { prop.setProperty(RHQConstants.LDAPLoginProperty, ldapLoginProperty); prop.setProperty(RHQConstants.LDAPBaseDN, ldapSearchBase); prop.setProperty(RHQConstants.LDAPFilter, ldapSearchFilter); + prop.setProperty(RHQConstants.LDAPGroupFilter, ldapGroupFilter); prop.setProperty(RHQConstants.LDAPBindDN, ldapUsername); prop.setProperty(RHQConstants.LDAPBindPW, ldapPassword); prop.setProperty(RHQConstants.LDAPProtocol, ldapSsl ? "ssl" : ""); @@ -558,6 +563,14 @@ public class SystemConfigForm extends BaseValidatorForm { public void setLdapSearchFilter(String s) { ldapSearchFilter = s; } + + public String getLdapGroupFilter() { + return ldapGroupFilter; + } + + public void setLdapGroupFilter(String s) { + ldapGroupFilter = s; + }
public String getLdapUsername() { return ldapUsername; diff --git a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties index 571cf22..1565fe3 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties +++ b/modules/enterprise/gui/portal-war/src/main/webapp-filtered/WEB-INF/classes/ApplicationResources.properties @@ -630,6 +630,7 @@ admin.settings.LDAPConfigPropTab=LDAP Configuration Properties admin.settings.LDAPHostNameLabel=LDAP Host Name: admin.settings.LDAPUsernameLabel=Username: admin.settings.LDAPSearchFilterLabel=Search Filter: +admin.settings.LDAPGroupSearchLabel=Group Search Filter: admin.settings.LDAPPortLabel=LDAP Port: admin.settings.LDAPUrlLabel=URL: admin.settings.LDAPSslLabel=SSL: diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp index a0ea5ff..fbf6955 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp +++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/config/LDAPForm.jsp @@ -51,8 +51,8 @@ <tr> <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPLoginPropertyLabel"/></td> <td width="30%" class="BlockContent"><html:text size="31" property="ldapLoginProperty"/></td> - <td width="20%" class="BlockLabel"> </td> - <td width="30%" class="BlockContent"> </td> + <td width="20%" class="BlockLabel"><fmt:message key="admin.settings.LDAPGroupSearchLabel"/></td> + <td width="30%" class="BlockContent"><html:text size="31" property="ldapGroupFilter"/></td> </tr>
<tr> diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java index 5411acc..8a94231 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java @@ -46,6 +46,7 @@ public class RHQConstants { public static final String LDAPProtocol = "CAM_LDAP_PROTOCOL"; public static final String LDAPLoginProperty = "CAM_LDAP_LOGIN_PROPERTY"; public static final String LDAPFilter = "CAM_LDAP_FILTER"; + public static final String LDAPGroupFilter = "CAM_LDAP_GROUP_FILTER"; public static final String LDAPBaseDN = "CAM_LDAP_BASE_DN"; public static final String LDAPBindDN = "CAM_LDAP_BIND_DN"; public static final String LDAPBindPW = "CAM_LDAP_BIND_PW"; @@ -61,7 +62,8 @@ public class RHQConstants { // Are we allowing automatic AgentUpdate binary download public static final String EnableAgentAutoUpdate = "ENABLE_AGENT_AUTO_UPDATE";
- // Are we rendering a special "debug" menu for administrators? + + // Are we rendering a special "debug" menu for administrators? public static final String EnableDebugMode = "ENABLE_DEBUG_MODE";
// How long do we keep data compressed in hourly intervals?
commit 0df397dd638fdfbd953fb6838f2fd00c274e3de3 Author: Shannon Hughes shughes@fred.hughes.lan Date: Mon Feb 22 10:25:46 2010 -0500
initial schema for ldap group feature
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml index 13a4bc5..dcb993b 100644 --- a/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml +++ b/modules/core/dbutils/src/main/scripts/dbsetup/authz-schema.xml @@ -27,6 +27,18 @@ </constraint> </table>
+ <table name="RHQ_ROLE_LDAP_GROUP_MAP"> + <column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/> + <column name="LDAP_GROUP_NAME" required="true" type="VARCHAR2"/> + + <constraint name="RHQ_ROLE_LDAP_GROUP_MAP_KEY"> + <primaryKey> + <field ref="ROLE_ID"/> + <field ref="LDAP_GROUP_NAME"/> + </primaryKey> + </constraint> + </table> + <table name="RHQ_PERMISSION"> <column name="ROLE_ID" type="INTEGER" references="RHQ_ROLE" required="true"/> <column name="OPERATION" type="INTEGER" required="true"/> @@ -60,6 +72,7 @@ <table name="RHQ_SUBJECT_ROLE_MAP"> <column name="SUBJECT_ID" required="true" type="INTEGER" references="RHQ_SUBJECT"/> <column name="ROLE_ID" required="true" type="INTEGER" references="RHQ_ROLE"/> + <column name="IS_LDAP" required="true" type="BOOLEAN" default="false"/>
<constraint name="RHQ_SUBJECT_ROLE_MAPPING_KEY"> <primaryKey>