List of usage examples for org.springframework.context ApplicationContextException ApplicationContextException
public ApplicationContextException(String msg, Throwable cause)
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
public void vcsPrepareCheckin(String serverId, String vcsResourcePath, String vcsResourceType, String pathToServersXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug("Entering VCSManagerImpl.vcsPrepareCheckin() with following params " + " serverName: " + serverId + ", vcsResourcePath: " + vcsResourcePath + ", pathToServersXML: " + pathToServersXML);/*from w w w. jav a 2 s.c o m*/ } try { String prefix = "vcsPrepareCheckin"; String actionName = "vcsPrepareCheckin"; // Set the Module Action Objective String s1 = (vcsResourcePath == null) ? "no_vcsResourcePath" : vcsResourcePath; System.setProperty("MODULE_ACTION_OBJECTIVE", "PREPARE_CHECKIN : " + s1); // Set the global suppress and debug flags for this class based on properties found in the property file setGlobalProperties(); if (!vcsV2Method) vcsConnId = null; CommonUtils.writeOutput("***** BEGIN COMMAND: " + actionName + " *****", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); /***************************************** * VALIDATE COMMAND-LINE VARIABLES *****************************************/ // Validate the arguments if (serverId == null || serverId.trim().length() == 0 || vcsResourcePath == null || vcsResourcePath.trim().length() == 0 || pathToServersXML == null || pathToServersXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments for " + prefix); } // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToServersXML)) { throw new ValidationException("File [" + pathToServersXML + "] does not exist."); } /***************************************** * PRINT OUT COMMAND-LINE VARIABLES *****************************************/ // Print out Debug input parameters CommonUtils.writeOutput("", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---Input Variables from deployment plan file: ", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" SERVER_ID= " + serverId, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" SERVER_PATH= " + pathToServersXML, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" VCONN_ID= " + vcsConnId, prefix, "-debug2", logger, debug1, debug2, debug3); // Get the server info from the servers.xml file CompositeServer serverInfo = WsApiHelperObjects.getServerLogger(serverId, pathToServersXML, prefix, logger); serverInfo = validateServerProperties(serverInfo); // Ping the Server to make sure it is alive and the values are correct. WsApiHelperObjects.pingServer(serverInfo, true); /***************************************** * INITIALIZE VCS STRUCTURE VARIABLE *****************************************/ // Initialize a new VCS structure for passing to the methods VcsStruct vcsStruct = (new VCSManagerImpl()).new VcsStruct(); // Load the VCS structure and decrypt the vcs password -- Retrieve properties from the deploy.properties file vcsStruct.loadVcs(prefix, vcsUser, vcsPassword); /***************************************** * DISPLAY/VALIDATE VCS VARIABLES *****************************************/ // Validate, Create VCS Workspace and Temp directories vcsStruct.validateVcs(prefix); // Resolve Absolute paths vcsStruct.resolveCanonicalPathsVcs(prefix); // Display VCS variables vcsStruct.displayVcs(prefix); String origResourceType = null; String origResourcePath = null; //******************************************************************************************** // Validate vcsResourcePath settings prior to invocation of vcs scripts //******************************************************************************************** origResourcePath = vcsResourcePath; if (vcsResourcePath == null || vcsResourcePath.length() == 0) { throw new ValidationException("VCS Resource Path is null or empty."); } // Encode the VCS resource path vcsResourcePath = ResourceNameCodec.encode(vcsResourcePath); vcsResourcePath = vcsResourcePath.replaceAll("_002F", "/"); //******************************************************************************************** // Validate vcsResourceType settings prior to invocation of vcs scripts //******************************************************************************************** // Get the Resource Type for the VCS Resource Path origResourceType = vcsResourceType; vcsResourceType = getConvertedVcsResourceType(vcsResourceType); // Validate the resource type if (vcsResourceType == null || vcsResourceType.length() == 0) { throw new ValidationException("VCS Resource Type is null or empty."); } if (!validResourceTypes.contains(vcsResourceType)) { throw new ValidationException("VCS Resource Type=[" + vcsResourceType + "] is not valid. Valid Resource Types=[" + validResourceTypes + "]"); } // Print out info statements CommonUtils.writeOutput("", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---VCS Module ID Arguments:", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Resource Path =" + origResourcePath, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Encoded Resource Path =" + vcsResourcePath, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Resource Type =" + origResourceType, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Converted Resource Type=" + vcsResourceType, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("-- BEGIN OUTPUT ------------------------------------", prefix, "-info", logger, debug1, debug2, debug3); //-------------------------------------------------------------- // prepare_checkin //-------------------------------------------------------------- prepare_checkin(vcsResourcePath, vcsResourceType, vcsStruct, serverId, pathToServersXML); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("Successfully completed " + actionName + ".", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
public void vcsPrepareCheckin2(String serverId, String vcsConnectionId, String vcsResourcePath, String vcsResourceType, String pathToVcsXML, String pathToServersXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug("Entering VCSManagerImpl.vcsPrepareCheckin2() with following params " + " serverName: " + serverId + " vcsConnectionId: " + vcsConnectionId + ", vcsResourcePath: " + vcsResourcePath + ", pathToServersXML: " + pathToServersXML); }//from ww w.j a va2 s . c o m try { // Set the VCS Module XML Connection Properties in the JVM Environment setVCSConnectionProperties(vcsConnectionId, pathToVcsXML); vcsConnId = vcsConnectionId; // Invoke the command vcsPrepareCheckin(serverId, vcsResourcePath, vcsResourceType, pathToServersXML, vcsUser, vcsPassword); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
public void vcsPrepareCheckins(String serverId, String vcsIds, String pathToVcsXML, String pathToServersXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug("Entering VCSManagerImpl.vcsPrepareCheckins() with following params " + " serverName: " + serverId + ", vcsIds: " + vcsIds + ", pathToVcsXML: " + pathToVcsXML + ", pathToServersXML: " + pathToServersXML);//from w w w. j a v a2 s . c o m } try { // Set the global suppress and debug flags for this class based on properties found in the property file setGlobalProperties(); if (!vcsV2Method) vcsConnId = null; executeVCS(VCSManager.action.PREPARE_CHECKIN.name(), serverId, vcsIds, pathToVcsXML, pathToServersXML, vcsUser, vcsPassword); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
public void vcsPrepareCheckins2(String serverId, String vcsConnectionId, String vcsIds, String pathToVcsXML, String pathToServersXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug("Entering VCSManagerImpl.vcsPrepareCheckins2() with following params " + " serverName: " + serverId + " vcsConnectionId: " + vcsConnectionId + ", vcsIds: " + vcsIds + ", pathToVcsXML: " + pathToVcsXML + ", pathToServersXML: " + pathToServersXML); }//from w w w . j av a2 s. com try { // Set the VCS Module XML Connection Properties in the JVM Environment setVCSConnectionProperties(vcsConnectionId, pathToVcsXML); vcsConnId = vcsConnectionId; // Invoke the command vcsPrepareCheckins(serverId, vcsIds, pathToVcsXML, pathToServersXML, vcsUser, vcsPassword); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
public void vcsInitializeBaseFolderCheckin2(String vcsConnectionId, String customPathList, String pathToVcsXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug(/* w ww.j a va2s . co m*/ "Entering VCSManagerImpl.vcsInitializeBaseFolderCheckin2() with following params: vcsConnectionId: " + vcsConnectionId + ", customPathList: " + customPathList); } try { // Set the VCS Module XML Connection Properties in the JVM Environment setVCSConnectionProperties(vcsConnectionId, pathToVcsXML); vcsConnId = vcsConnectionId; // Invoke the command vcsInitializeBaseFolderCheckin(customPathList, vcsUser, vcsPassword); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
public void vcsInitializeBaseFolderCheckin(String customPathList, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug(//from ww w . j a va 2 s . c o m "Entering VCSManagerImpl.vcsInitializeBaseFolderCheckin() with following params: customPathList:" + customPathList); } try { /***************************************** * INITIALIZE VARIABLES *****************************************/ // Trim input variables to remove spaces vcsUser = vcsUser.trim(); vcsPassword = vcsPassword.trim(); String prefix = "vcsInitializeBaseFolderCheckin"; String actionName = "vcsInitializeBaseFolderCheckin"; // Always initialize starting at the root (/) folder String vcsResourcePath = "/"; String vcsResourceType = "CONTAINER"; String vcsMessage = "VCS Base Folder Initialization."; // Set the global suppress and debug flags for this class based on properties found in the property file setGlobalProperties(); CommonUtils.writeOutput("***** BEGIN COMMAND: " + actionName + " *****", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); /***************************************** * PRINT OUT COMMAND-LINE VARIABLES *****************************************/ // Print out Debug input parameters CommonUtils.writeOutput("", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---Input Variables from deployment plan file: ", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" VCONN_ID= " + vcsConnId, prefix, "-debug2", logger, debug1, debug2, debug3); /***************************************** * INITIALIZE VCS STRUCTURE VARIABLE *****************************************/ // Initialize a new VCS structure for passing to the methods VcsStruct vcsStruct = (new VCSManagerImpl()).new VcsStruct(); // Load the VCS structure and decrypt the vcs password -- Retrieve properties from the deploy.properties file vcsStruct.loadVcs(prefix, vcsUser, vcsPassword); // Set the Module Action Objective String s1 = (vcsStruct.getVcsUsername() == null) ? "no_User" : "User=" + vcsStruct.getVcsUsername(); System.setProperty("MODULE_ACTION_OBJECTIVE", "INIT_BASE : " + s1); /***************************************** * DISPLAY/VALIDATE VCS VARIABLES *****************************************/ // Validate, Create VCS Workspace and Temp directories vcsStruct.validateVcs(prefix); // Resolve Absolute paths vcsStruct.resolveCanonicalPathsVcs(prefix); // Display VCS variables vcsStruct.displayVcs(prefix); String origResourceType = null; String origResourcePath = null; //******************************************************************************************** // Validate vcsResourcePath settings prior to invocation of vcs scripts //******************************************************************************************** origResourcePath = vcsResourcePath; if (vcsResourcePath == null || vcsResourcePath.length() == 0) { throw new ValidationException("VCS Resource Path is null or empty."); } // Encode the VCS resource path vcsResourcePath = ResourceNameCodec.encode(vcsResourcePath); vcsResourcePath = vcsResourcePath.replaceAll("_002F", "/"); //******************************************************************************************** // Validate vcsResourceType settings prior to invocation of vcs scripts //******************************************************************************************** // Get the Resource Type for the VCS Resource Path origResourceType = vcsResourceType; vcsResourceType = getConvertedVcsResourceType(vcsResourceType); // Validate the resource type if (vcsResourceType == null || vcsResourceType.length() == 0) { throw new ValidationException("VCS Resource Type is null or empty."); } if (!validResourceTypes.contains(vcsResourceType)) { throw new ValidationException("VCS Resource Type=[" + vcsResourceType + "] is not valid. Valid Resource Types=[" + validResourceTypes + "]"); } // Prepend the property VCS_MESSAGE_PREPEND to message String messagePrepend = vcsStruct.getVcsMessagePrepend(); if (messagePrepend != null && messagePrepend.length() > 0) { if (vcsMessage == null) { vcsMessage = messagePrepend; } else { vcsMessage = messagePrepend + " " + vcsMessage; } } // Validate the message is not null or emtpy if (vcsMessage == null || vcsMessage.length() == 0) { throw new ValidationException("VCS Message is null or empty."); } // Print out info statements CommonUtils.writeOutput("", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---VCS Module ID Arguments:", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Resource Path =" + origResourcePath, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Encoded Resource Path =" + vcsResourcePath, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Resource Type =" + origResourceType, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Converted Resource Type=" + vcsResourceType, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Message =" + vcsMessage, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" customPathList =" + customPathList, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("-- BEGIN OUTPUT ------------------------------------", prefix, "-info", logger, debug1, debug2, debug3); //-------------------------------------------------------------- // checkin //-------------------------------------------------------------- initialize_checkin(vcsResourcePath, vcsResourceType, vcsMessage, customPathList, vcsStruct); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("Successfully completed " + actionName + ".", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.RegressionManagerImpl.java
/** * Generates the Regression Security XML section of the RegressionModule.xml. * Generates Regression Security Users from the given filter applying the xml schema userMode=[NOEXEC|OVERWRITE|APPEND]. * Generates Regression Security Queries from the given filter applying the xml schema queryMode=[NOEXEC|OVERWRITE|APPEND]. * Generates a Cartesian product for the Regression Security Plans applying the xml schema planMode=[NOEXEC|OVERWRITE|APPEND] * and planModeType=[SINGLEPLAN|MULTIPLAN]. * Generates to a different RegressionModule.xml file than the source file so that formatting can be maintained in the XML in the source. * This is based on the xml schema pathToTargetRegressionXML. * It is recommended that the users copy the results out of the target, generated file and paste into the source file as needed. * A Cartesian product is where each user contains an execution for all of the queries. * A security plan is as follows:/*from w w w .java2s . c o m*/ * A security plan consists of executing all queries for a single user. * A Cartesian product involves creating a plan for each user with all queries. * * RegressionModule.xml - ns2:RegressionModule/regressionTest/securityGenerationOptions * Schema element: encryptedPassword Encrypted Password - An optional security user default password. It will be encrypted when the * ExecutePDTool.bat -encrypt ..\resources\modules\RegressionModule.xml is executed. * Schema element: userFilter Security user filter - This optional filter is a comma separated list of users or wild card users that * can be used to filter the generation of the Regression Security User list. * Schema element: pathToTargetRegressionXML Path to Target Regression Module XML - a required path to the target configuration file for the regression module. * Provides a way of writing to a different file than the source or original RegressionModule.xml. * Schema element: userMode [NOEXEC|OVERWRITE|APPEND] - NOEXEC (default)=do nothing, don't execute. * OVERWRITE=overwrite existing security user XML, * APPEND=add to existing security user XML if the user does not exist. * Schema element: queryMode [NOEXEC|OVERWRITE|APPEND] - NOEXEC (default)=do nothing, don't execute. * OVERWRITE=overwrite existing security query XML, * APPEND=add to existing security query XML if the query does not exist. * Schema element: planMode [NOEXEC|OVERWRITE|APPEND] - NOEXEC (default)=do nothing, don't execute. * OVERWRITE=overwrite existing security plan XML, * APPEND=add to existing security plan XML if the plan does not exist. * Schema element: planModeType [SINGLEPLAN|MULTIPLAN] - SINGLEPLAN=Generate the Cartesian plan as a single plan. * MULTIPLAN=Generate the Cartesian plan as multiple plans for each user who has the same set of queries. * e.g. when planMode=OVERWRITE and planModeType=MULTIPLAN - will produce a new list where each user is a security plan with the full set of queries. * e.g. when planMode=APPEND and planModeType=SINGLEPLAN - will produce a new plan appended to the existing set of plans where this plan will contain a Cartesian product of users and queries. * * @param serverId server Id from servers.xml * @param regressionIds comma-separated list of the published regression identifiers to run test against * @param pathToSourceRegressionXML path to the source configuration file for the regression module. Provides a way of maintaining existing files without overwriting. * @param pathToServersXML path to servers.xml * @throws CompositeException */ public void generateRegressionSecurityXML(String serverId, String regressionIds, String pathToSourceRegressionXML, String pathToServersXML) throws CompositeException { // Initialize prefix String prefix = "generateRegressionSecurityXML"; String processedIds = null; // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToSourceRegressionXML)) { throw new CompositeException( "File source regression model xml [" + pathToSourceRegressionXML + "] does not exist."); } if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } // validate incoming arguments if (serverId == null || serverId.trim().length() == 0 || regressionIds == null || regressionIds.trim().length() == 0 || pathToSourceRegressionXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments"); } // Set debug properties setGlobalProperties(); // Set the CIS Server Configuration setCisServerConfig(serverId, pathToServersXML); // Initialize the Regression Module XML RegressionModule regressionModule = null; // Initialize the Regression Security XML RegressionSecurityType regressionSecurity = null; // Extract variables for the regressionIds regressionIds = CommonUtils.extractVariable(prefix, regressionIds, propertyFile, true); // Set the Module Action Objective String s1 = (regressionIds == null) ? "no_regressionIds" : "Ids=" + regressionIds; System.setProperty("MODULE_ACTION_OBJECTIVE", "GENERATE : " + s1); try { //using jaxb convert xml to corresponding java objects regressionModule = (RegressionModule) XMLUtils.getModuleTypeFromXML(pathToSourceRegressionXML); // Get the regression tests if (regressionModule != null && regressionModule.getRegressionSecurity() != null) { regressionSecurity = regressionModule.getRegressionSecurity(); } else { regressionSecurity = new RegressionSecurityType(); } } catch (CompositeException e) { logger.error("Error while parsing RegressionModule XML: ", e); throw new ApplicationContextException(e.getMessage(), e); } List<RegressionTestType> regressionList = getRegression(serverId, regressionIds, pathToSourceRegressionXML, pathToServersXML); if (regressionList != null && regressionList.size() > 0) { // Loop over the list of regression compare ids and perform the comparison between files based on the target data source resources for (RegressionTestType regression : regressionList) { // Get the identifier and convert any $VARIABLES String identifier = CommonUtils.extractVariable(prefix, regression.getId(), propertyFile, true); /** * Possible values for regression * 1. csv string like test1,test2 (we process only resource names which are passed in) * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case) * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix * like -test1,test2 (we ignore passed in resources and process rest of the in the input xml */ if (DeployUtil.canProcessResource(regressionIds, identifier)) { // Add to the list of processed ids if (processedIds == null) processedIds = ""; else processedIds = processedIds + ","; processedIds = processedIds + identifier; // Set the Module Action Objective s1 = identifier; System.setProperty("MODULE_ACTION_OBJECTIVE", "GENERATE : " + s1); if (logger.isInfoEnabled()) { logger.info("-----------------------------------------------------------------------"); logger.info("Processing action \"generate security XML\" for regression id: " + identifier); logger.info("-----------------------------------------------------------------------"); } // Initialize start time and format Date startDate = new Date(); // Initialize variables String defaultEncryptedPassword = ""; String userFilter = ""; String pathToTargetRegressionXML = null; String userMode = null; String queryMode = null; String planMode = null; String planModeType = null; int userCount = 0; int queryCount = 0; int planCount = 0; boolean planGenerateExpectedOutcome = false; boolean flattenSecurityUsersXML = true; boolean flattenSecurityQueryQueriesXML = true; boolean flattenSecurityQueryProceduresXML = true; boolean flattenSecurityQueryWebServicesXML = true; boolean flattenSecurityPlansXML = true; // Verify that testRunParams exists in the regression xml file if (regression.getTestRunParams() == null) { throw new CompositeException( "The <testRunParams> entry does not exist in the regression XML file."); } // Set the Regression Configuration for this ID; this.regressionConfig = regression; String testType = CommonUtils.extractVariable(prefix, this.regressionConfig.getTestRunParams().getTestType(), propertyFile, false); // Execute the security test if the test type is set to "security" if (SECURITY.equalsIgnoreCase(testType)) { RegressionSecurityGenerationOptionsType securityGenerationOptions = new RegressionSecurityGenerationOptionsType(); if (this.regressionConfig.getNewFileParams() != null && this.regressionConfig .getNewFileParams().getSecurityGenerationOptions() != null) { securityGenerationOptions = this.regressionConfig.getNewFileParams() .getSecurityGenerationOptions(); } else { throw new CompositeException( "The <securityGenerationOptions> entry does not exist in the regression XML file. It is required for generating the regression security XML."); } // Retrieve the Path to the Target Regression Module XML if (securityGenerationOptions.getPathToTargetRegressionXML() != null && securityGenerationOptions.getPathToTargetRegressionXML().length() > 0) { pathToTargetRegressionXML = CommonUtils.extractVariable(prefix, securityGenerationOptions.getPathToTargetRegressionXML(), propertyFile, false); } else { throw new CompositeException( "The <securityGenerationOptions><getPathToTargetRegressionXML> entry does not exist in the regression XML file. It is required for generating the regression security XML."); } // Retrieve the default encrypted password if (securityGenerationOptions.getEncryptedPassword() != null && securityGenerationOptions.getEncryptedPassword().length() > 0) { defaultEncryptedPassword = CommonUtils.encrypt(CommonUtils.extractVariable(prefix, securityGenerationOptions.getEncryptedPassword(), propertyFile, false)); } // Retrieve the user filter if (securityGenerationOptions.getUserFilter() != null && securityGenerationOptions.getUserFilter().length() > 0) { userFilter = CommonUtils.extractVariable(prefix, securityGenerationOptions.getUserFilter(), propertyFile, false); } // Retrieve the domain filter String domainFilter = "composite"; if (securityGenerationOptions.getDomainFilter() != null && securityGenerationOptions.getDomainFilter().length() > 0) { domainFilter = CommonUtils.extractVariable(prefix, securityGenerationOptions.getDomainFilter(), propertyFile, false); } // Retrieve the user mode if (securityGenerationOptions.getUserMode() != null && securityGenerationOptions.getUserMode().length() > 0) { userMode = CommonUtils.extractVariable(prefix, securityGenerationOptions.getUserMode(), propertyFile, false); } else { throw new CompositeException( "The <securityGenerationOptions><userMode> entry does not exist in the regression XML file. It is required for generating the regression security XML."); } // Retrieve the query mode if (securityGenerationOptions.getQueryMode() != null && securityGenerationOptions.getQueryMode().length() > 0) { queryMode = CommonUtils.extractVariable(prefix, securityGenerationOptions.getQueryMode(), propertyFile, false); } else { throw new CompositeException( "The <securityGenerationOptions><queryMode> entry does not exist in the regression XML file. It is required for generating the regression security XML."); } // Retrieve the plan mode if (securityGenerationOptions.getPlanMode() != null && securityGenerationOptions.getPlanMode().length() > 0) { planMode = CommonUtils.extractVariable(prefix, securityGenerationOptions.getPlanMode(), propertyFile, false); } else { throw new CompositeException( "The <securityGenerationOptions><planMode> entry does not exist in the regression XML file. It is required for generating the regression security XML."); } // Retrieve the plan mode type if (securityGenerationOptions.getPlanModeType() != null && securityGenerationOptions.getPlanModeType().length() > 0) { planModeType = CommonUtils.extractVariable(prefix, securityGenerationOptions.getPlanModeType(), propertyFile, false); } else { throw new CompositeException( "The <securityGenerationOptions><planModeType> entry does not exist in the regression XML file. It is required for generating the regression security XML."); } // Retrieve the default security plan id prefix String defaultPlanIdPrefix = "sp"; if (securityGenerationOptions.getPlanIdPrefix() != null && securityGenerationOptions.getPlanIdPrefix().length() > 0) { defaultPlanIdPrefix = CommonUtils.extractVariable(prefix, securityGenerationOptions.getPlanIdPrefix(), propertyFile, false); } // Retrieve the flatten security users XML decision if (securityGenerationOptions.getPlanGenerateExpectedOutcome() != null && securityGenerationOptions.getPlanGenerateExpectedOutcome().length() > 0) { planGenerateExpectedOutcome = RegressionManagerUtils .checkBooleanConfigParam(CommonUtils.extractVariable(prefix, securityGenerationOptions.getPlanGenerateExpectedOutcome(), propertyFile, false)); } // Retrieve the flatten security users XML decision if (securityGenerationOptions.getFlattenSecurityUsersXML() != null && securityGenerationOptions.getFlattenSecurityUsersXML().length() > 0) { flattenSecurityUsersXML = RegressionManagerUtils.checkBooleanConfigParam(CommonUtils .extractVariable(prefix, securityGenerationOptions.getFlattenSecurityUsersXML(), propertyFile, false)); } // Retrieve the flatten security query (SQL Queries) XML decision if (securityGenerationOptions.getFlattenSecurityQueryQueriesXML() != null && securityGenerationOptions.getFlattenSecurityQueryQueriesXML().length() > 0) { flattenSecurityQueryQueriesXML = RegressionManagerUtils .checkBooleanConfigParam(CommonUtils.extractVariable(prefix, securityGenerationOptions.getFlattenSecurityQueryQueriesXML(), propertyFile, false)); } // Retrieve the flatten security query (SQL Procedures) XML decision if (securityGenerationOptions.getFlattenSecurityQueryProceduresXML() != null && securityGenerationOptions.getFlattenSecurityQueryProceduresXML().length() > 0) { flattenSecurityQueryProceduresXML = RegressionManagerUtils .checkBooleanConfigParam(CommonUtils.extractVariable(prefix, securityGenerationOptions.getFlattenSecurityQueryProceduresXML(), propertyFile, false)); } // Retrieve the flatten security query (Web Services) XML decision if (securityGenerationOptions.getFlattenSecurityQueryWebServicesXML() != null && securityGenerationOptions.getFlattenSecurityQueryWebServicesXML().length() > 0) { flattenSecurityQueryWebServicesXML = RegressionManagerUtils .checkBooleanConfigParam(CommonUtils.extractVariable(prefix, securityGenerationOptions.getFlattenSecurityQueryWebServicesXML(), propertyFile, false)); } // Retrieve the flatten security plans XML decision if (securityGenerationOptions.getFlattenSecurityPlansXML() != null && securityGenerationOptions.getFlattenSecurityPlansXML().length() > 0) { flattenSecurityPlansXML = RegressionManagerUtils.checkBooleanConfigParam(CommonUtils .extractVariable(prefix, securityGenerationOptions.getFlattenSecurityPlansXML(), propertyFile, false)); } /************************ * Generate the users ************************/ // OVERWRITE = Overwrite all users thus creating a new set of users // APPEND = Keep the original users and create a new users at then end of the list if they don't already exist. This is like a merge. if (userMode != null && userMode.length() > 0 && (userMode.equalsIgnoreCase("OVERWRITE") || userMode.equalsIgnoreCase("APPEND"))) { // Get the current regression security users and determine whether to OVERWRITE or APPEND RegressionSecurityUsersType regressionSecurityUsers = new RegressionSecurityUsersType(); if (userMode.equalsIgnoreCase("APPEND") && regressionSecurity.getRegressionSecurityUsers() != null && regressionSecurity.getRegressionSecurityUsers() .getRegressionSecurityUser() != null && regressionSecurity.getRegressionSecurityUsers().getRegressionSecurityUser() .size() > 0) { regressionSecurityUsers.getRegressionSecurityUser().addAll(regressionSecurity .getRegressionSecurityUsers().getRegressionSecurityUser()); } CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("Generate users with userMode=" + userMode, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); // Get the list of users from the CIS server UserList cisUserList = null; UserList cisUserListFiltered = new UserList(); try { ArrayList<String> validUsers = null; // Get the list of users from the server cisUserList = getUserDAO().getAllUsers(validUsers, domainFilter, serverId, pathToServersXML); // Iterate through the list of users for (User user : cisUserList.getUser()) { // Remove the user from the list if it does not meet the user filter criteria if (DeployUtil.canProcessResource(userFilter, user.getName())) { cisUserListFiltered.getUser().add(user); } } } catch (CompositeException e) { logger.error("Error while retrieving CIS user list", e); throw new ApplicationContextException( "Error while retrieving CIS user list" + e.getMessage(), e); } // Get the list of user ids and count String userIds = ""; for (int i = 0; i < regressionSecurityUsers.getRegressionSecurityUser().size(); i++) { String userId = regressionSecurityUsers.getRegressionSecurityUser().get(i).getId(); if (userId != null && userId.length() > 0) { userIds = userIds + userId + " "; userCount++; } } // Iterate through the list of users for (User user : cisUserListFiltered.getUser()) { String userId = null; boolean userFound = false; /* Process the server user list against the current regression module users * <regressionSecurityUsers> * <regressionSecurityUser> * <id>rsu1</id><userName>user1</userName><encryptedPassword>Encrypted:B0873483C56F7498</encryptedPassword> * </regressionSecurityUser> * ... * </regressionSecurityUsers> */ List<RegressionSecurityUserType> regressionSecurityUserList = regressionSecurityUsers .getRegressionSecurityUser(); for (RegressionSecurityUserType regressionSecurityUser : regressionSecurityUserList) { userId = regressionSecurityUser.getId(); String userName = regressionSecurityUser.getUserName(); if (userName.equalsIgnoreCase(user.getName())) { userFound = true; break; } } // for (RegressionSecurityUserType regressionSecurityUser : regressionSecurityUserList) // Add the user to the security user XML if (!userFound) { // Calculate the userId userId = ""; while (true) { ++userCount; userId = "rsu" + userCount; if (!userIds.toLowerCase().contains(userId)) { break; } } // while (true) CommonUtils.writeOutput( "Generate user with userId=" + userId + " user name=" + user.getName(), prefix, "-debug3", logger, debug1, debug2, debug3); // Add the user to the XML RegressionSecurityUserType regressionSecurityUserNew = new RegressionSecurityUserType(); regressionSecurityUserNew.setId(userId); regressionSecurityUserNew.setUserName(user.getName()); regressionSecurityUserNew.setEncryptedPassword(defaultEncryptedPassword); regressionSecurityUserNew.setDomain(user.getDomainName()); regressionSecurityUsers.getRegressionSecurityUser() .add(regressionSecurityUserNew); } // if (!userFound) } // for (User user : cisUserListFiltered.getUser()) // Set the Regression Security Users regressionSecurity.setRegressionSecurityUsers(regressionSecurityUsers); // Update the Regression Security XML regressionModule.setRegressionSecurity(regressionSecurity); // Write the Regression Module XML back out to the target file. writeRegressionXMLFile(prefix, regressionModule, pathToTargetRegressionXML, flattenSecurityUsersXML, flattenSecurityQueryQueriesXML, flattenSecurityQueryProceduresXML, flattenSecurityQueryWebServicesXML, flattenSecurityPlansXML); } // if (userMode != null && userMode.length() > 0 && ... /************************ * Generate the queries ************************/ // OVERWRITE = Overwrite all queries thus creating a new set of queries // APPEND = Keep the original queries and create new queries at the end of the existing list of queries if (queryMode != null && queryMode.length() > 0 && (queryMode.equalsIgnoreCase("OVERWRITE") || queryMode.equalsIgnoreCase("APPEND"))) { // Get the current regression security Queries and determine whether to OVERWRITE or APPEND RegressionSecurityQueriesType regressionSecurityQueries = new RegressionSecurityQueriesType(); if (queryMode.equalsIgnoreCase("APPEND") && regressionSecurity.getRegressionSecurityQueries() != null && regressionSecurity.getRegressionSecurityQueries() .getRegressionSecurityQuery() != null && regressionSecurity.getRegressionSecurityQueries() .getRegressionSecurityQuery().size() > 0) { regressionSecurityQueries.getRegressionSecurityQuery().addAll(regressionSecurity .getRegressionSecurityQueries().getRegressionSecurityQuery()); } CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("Generate queries with queryMode=" + queryMode, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); /* Execute the generate Security Queries XML to create or update the security queries * <regressionSecurityQueries> * <regressionSecurityQuery> * <id>rsq1</id><datasource>TEST00</datasource><queryType>QUERY</queryType><query>SELECT count(1) cnt FROM CAT1.SCH1.customers</query> * </regressionSecurityQuery> * ... * </regressionSecurityQueries> */ RegressionInputFileDAO inputDAO = getRegressionInputFileJdbcDAO(); regressionSecurityQueries = inputDAO.generateSecurityQueriesXML(cisServerConfig, regression, regressionQueries, regressionSecurityQueries, queryMode); // Set the Regression Security Queries regressionSecurity.setRegressionSecurityQueries(regressionSecurityQueries); // Update the Regression Security XML regressionModule.setRegressionSecurity(regressionSecurity); // Write the Regression Module XML back out to the target file. writeRegressionXMLFile(prefix, regressionModule, pathToTargetRegressionXML, flattenSecurityUsersXML, flattenSecurityQueryQueriesXML, flattenSecurityQueryProceduresXML, flattenSecurityQueryWebServicesXML, flattenSecurityPlansXML); // Get the number of queries generated if (regressionSecurityQueries.getRegressionSecurityQuery() != null) queryCount = regressionSecurityQueries.getRegressionSecurityQuery().size(); } // if (queryMode != null && queryMode.length() > 0 && ... /************************ * Generate the plans ************************/ // OVERWRITE = Overwrite all plans thus creating a new plan // APPEND = Keep the original plans and create a new plan that is a Cartesian product of users and queries // SINGLEPLAN = Generate the Cartesian plan as a single plan // MULTIPLAN = Generate the Cartesian plan as multiple plans for each user who has the same set of queries if (planMode != null && planMode.length() > 0 && (planMode.equalsIgnoreCase("OVERWRITE") || planMode.equalsIgnoreCase("APPEND"))) { // Get the current regression security plans and determine whether to OVERWRITE or APPEND RegressionSecurityPlansType regressionSecurityPlans = new RegressionSecurityPlansType(); if (planMode.equalsIgnoreCase("APPEND") && regressionSecurity.getRegressionSecurityPlans() != null && regressionSecurity.getRegressionSecurityPlans() .getRegressionSecurityPlan() != null && regressionSecurity.getRegressionSecurityPlans().getRegressionSecurityPlan() .size() > 0) { regressionSecurityPlans.getRegressionSecurityPlan().addAll(regressionSecurity .getRegressionSecurityPlans().getRegressionSecurityPlan()); planCount = regressionSecurityPlans.getRegressionSecurityPlan().size(); } CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils .writeOutput( "Generate plans with planMode=" + planMode + " and planModeType=" + planModeType, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); // Get the list of plan ids String planIds = ""; for (int i = 0; i < regressionSecurityPlans.getRegressionSecurityPlan().size(); i++) { String planId = regressionSecurityPlans.getRegressionSecurityPlan().get(i).getId(); if (planId != null && planId.length() > 0) { planIds = planIds + planId + " "; } } /* Execute the generate Security Plans XML to create or update the security plans creating a Cartesian product of users and queries * </regressionSecurityPlans> * <regressionSecurityPlan> * <id>sp2</id> * <regressionSecurityPlanTest> * <id>rst1</id><enabled>false</enabled><userId>rsu2</userId><queryId>rsq1</queryId><expectedOutcome>FAIL</expectedOutcome> * </regressionSecurityPlanTest> * </regressionSecurityPlan> * ... * </regressionSecurityPlans> */ // Get the list of queries List<RegressionSecurityQueryType> regressionSecurityQueryList = null; if (regressionSecurity.getRegressionSecurityQueries() != null && regressionSecurity .getRegressionSecurityQueries().getRegressionSecurityQuery() != null) { regressionSecurityQueryList = regressionSecurity.getRegressionSecurityQueries() .getRegressionSecurityQuery(); } // Get the list of users List<RegressionSecurityUserType> regressionSecurityUserList = null; if (regressionSecurity.getRegressionSecurityUsers() != null && regressionSecurity .getRegressionSecurityUsers().getRegressionSecurityUser() != null) { regressionSecurityUserList = regressionSecurity.getRegressionSecurityUsers() .getRegressionSecurityUser(); } // Continue as long as there are users and queries to build a plan from if (regressionSecurityUserList != null && regressionSecurityUserList != null && regressionSecurityUserList.size() > 0 && regressionSecurityUserList.size() > 0) { // Initialize variables String planId = null; RegressionSecurityPlanType regressionSecurityPlanNew = null; int rstCount = 0; int planNumber = -1; int planTestSize = 0; RegressionSecurityPlansType regressionSecurityPlansVerify = new RegressionSecurityPlansType(); // Create a new SINGLEPLAN for all users if (planModeType.equalsIgnoreCase("SINGLEPLAN")) { regressionSecurityPlanNew = new RegressionSecurityPlanType(); // Determine the plan id when overwriting for a single plan. OVERWRITE all plans in the RegressionModule.xml. if (planMode.equalsIgnoreCase("OVERWRITE")) { planId = calculatePlanId(defaultPlanIdPrefix, planIds, planCount); planCount = Integer.valueOf(planId.replace(defaultPlanIdPrefix, "")); regressionSecurityPlanNew.setId(planId); CommonUtils.writeOutput( "Single Plan OVERWRITE - Generate plan with planId=" + planId, prefix, "-debug3", logger, debug1, debug2, debug3); // Set the regression verification regressionSecurityPlansVerify = regressionSecurityPlans; } // Determine how to append a given plan test: APPEND the last plan found in the RegressionModule.xml. if (planMode.equalsIgnoreCase("APPEND")) { int numPlans = 0; if (regressionSecurityPlans != null && regressionSecurityPlans.getRegressionSecurityPlan() != null && regressionSecurityPlans.getRegressionSecurityPlan().size() > 0) { numPlans = regressionSecurityPlans.getRegressionSecurityPlan().size(); } if (numPlans > 0) { planNumber = numPlans - 1; regressionSecurityPlanNew = regressionSecurityPlans .getRegressionSecurityPlan().get(planNumber); // Initialize the number of plan tests for the last current plan if (planNumber >= 0) planTestSize = regressionSecurityPlans.getRegressionSecurityPlan() .get(planNumber).getRegressionSecurityPlanTest().size(); planId = regressionSecurityPlanNew.getId(); CommonUtils.writeOutput( "Single plan APPEND - Append existing plan with planId=" + planId, prefix, "-debug3", logger, debug1, debug2, debug3); // Add only the last plan in the list for verification purposes regressionSecurityPlansVerify.getRegressionSecurityPlan() .add(regressionSecurityPlanNew); } else { // Calculate a new plan id planId = calculatePlanId(defaultPlanIdPrefix, planIds, planCount); planCount = Integer.valueOf(planId.replace(defaultPlanIdPrefix, "")); regressionSecurityPlanNew.setId(planId); CommonUtils.writeOutput( "Single plan APPEND - Generate new plan with planId=" + planId, prefix, "-debug3", logger, debug1, debug2, debug3); regressionSecurityPlansVerify = regressionSecurityPlans; } } } // Create the Cartesian product of users and queries for (RegressionSecurityUserType regressionSecurityUser : regressionSecurityUserList) { // Get the associated groups for this user GroupList groupList = null; if (planGenerateExpectedOutcome) { groupList = getGroupDAO().getGroupsByUser( regressionSecurityUser.getUserName(), regressionSecurityUser.getDomain(), serverId, pathToServersXML); } // Create MULTIPLE PLANS, one for each user if (planModeType.equalsIgnoreCase("MULTIPLAN")) { regressionSecurityPlanNew = new RegressionSecurityPlanType(); // Determine the plan id when overwriting for a multi-plan. OVERWRITE all plans in the Regression.xml. if (planMode.equalsIgnoreCase("OVERWRITE")) { planId = calculatePlanId(defaultPlanIdPrefix, planIds, planCount); planCount = Integer.valueOf(planId.replace(defaultPlanIdPrefix, "")); regressionSecurityPlanNew.setId(planId); CommonUtils.writeOutput( "Multi-plan OVERWRITE - Generate plan with planId=" + planId, prefix, "-debug3", logger, debug1, debug2, debug3); // Set the regression verification regressionSecurityPlansVerify = regressionSecurityPlans; } // Determine how to append a given plan test: If the userId exists in this plan then APPEND the query if it does not already exist. Create new plans as needed for different users. if (planMode.equalsIgnoreCase("APPEND")) { planNumber = -1; planTestSize = 0; // Initialize the number of plan tests for this user id planNumber = planNumberInSecurityRegressionPlans( regressionSecurityUser.getId(), regressionSecurityPlans); if (planNumber >= 0) { regressionSecurityPlanNew = regressionSecurityPlans .getRegressionSecurityPlan().get(planNumber); planTestSize = regressionSecurityPlanNew .getRegressionSecurityPlanTest().size(); planId = regressionSecurityPlanNew.getId(); CommonUtils.writeOutput( "Multi-plan APPEND - Append existing plan with planId=" + planId, prefix, "-debug3", logger, debug1, debug2, debug3); // Add only the last plan in the list for verification purposes regressionSecurityPlansVerify.getRegressionSecurityPlan() .add(regressionSecurityPlanNew); } else { // Calculate a new plan id planId = calculatePlanId(defaultPlanIdPrefix, planIds, planCount); planCount = Integer .valueOf(planId.replace(defaultPlanIdPrefix, "")); regressionSecurityPlanNew.setId(planId); CommonUtils.writeOutput( "Multi-plan APPEND - Generate new plan with planId=" + planId, prefix, "-debug3", logger, debug1, debug2, debug3); // Set the regression verification regressionSecurityPlansVerify = regressionSecurityPlans; } } } // Iterate over the list of queries for each user for (RegressionSecurityQueryType regressionSecurityQuery : regressionSecurityQueryList) { // Determine if the plan exists or not boolean planExists = planExistsInSecurityRegressionPlans( regressionSecurityUser.getId(), regressionSecurityQuery.getId(), regressionSecurityPlansVerify); if (!planExists) { RegressionSecurityPlanTestType regressionSecurityPlanTest = new RegressionSecurityPlanTestType(); // Increment plan test id ++rstCount; String platTestId = "rst" + (rstCount + planTestSize); // Set the regression security plan test id regressionSecurityPlanTest.setId(platTestId); // Set the plan test to be true regressionSecurityPlanTest.setEnabled("true"); // Set the user id regressionSecurityPlanTest.setUserId(regressionSecurityUser.getId()); // Set the query id regressionSecurityPlanTest.setQueryId(regressionSecurityQuery.getId()); // Get the expected outcome String[] result = getExpectedOutcome(planGenerateExpectedOutcome, regressionSecurityUser.getId(), regressionSecurityQuery.getId(), groupList, regressionSecurityUser, regressionSecurityQuery, serverId, pathToServersXML); // Set the expected outcome String expectedOutcome = result[0]; regressionSecurityPlanTest.setExpectedOutcome(expectedOutcome); // Set the description String description = result[1]; regressionSecurityPlanTest.setDescription(description); // Add the new security plan test regressionSecurityPlanNew.getRegressionSecurityPlanTest() .add(regressionSecurityPlanTest); } } // Add the plan to the list for each user if (planModeType.equalsIgnoreCase("MULTIPLAN")) { // Only write out the plan if there were plan tests created if (rstCount > 0) { if (planNumber >= 0) { regressionSecurityPlans.getRegressionSecurityPlan().set(planNumber, regressionSecurityPlanNew); --planCount; } else { // Add to the list of Security Plans regressionSecurityPlans.getRegressionSecurityPlan() .add(regressionSecurityPlanNew); } rstCount = 0; // Set the Regression Security Plans regressionSecurity.setRegressionSecurityPlans(regressionSecurityPlans); // Update the Regression Security XML regressionModule.setRegressionSecurity(regressionSecurity); // Write the Regression Module XML back out to the target file. writeRegressionXMLFile(prefix, regressionModule, pathToTargetRegressionXML, flattenSecurityUsersXML, flattenSecurityQueryQueriesXML, flattenSecurityQueryProceduresXML, flattenSecurityQueryWebServicesXML, flattenSecurityPlansXML); } else { --planCount; } } } // Add the single plan to the list of plans if (planModeType.equalsIgnoreCase("SINGLEPLAN")) { if (planNumber >= 0) { regressionSecurityPlans.getRegressionSecurityPlan().set(planNumber, regressionSecurityPlanNew); } else { // Add to the list of Security Plans regressionSecurityPlans.getRegressionSecurityPlan() .add(regressionSecurityPlanNew); } } } // Set the Regression Security Plans regressionSecurity.setRegressionSecurityPlans(regressionSecurityPlans); } // if (planMode != null && planMode.length() > 0 && ... /******** * Commenting out this section of code so that the resourcePath and resourceType are retained in the XML. * When the user decides to do APPEND for plans and generate the expected outcome, then if the resource path and type are not present * then the outcome cannot be generated. * // Remove the resourcePath and resourceType from the XML since this is optional and is only used to establish the plan test expected outcome if (regressionSecurity.getRegressionSecurityQueries() != null && regressionSecurity.getRegressionSecurityQueries().getRegressionSecurityQuery() != null && regressionSecurity.getRegressionSecurityQueries().getRegressionSecurityQuery().size() > 0) { for (RegressionSecurityQueryType regressionSecurityQuery : regressionSecurity.getRegressionSecurityQueries().getRegressionSecurityQuery()) { if (regressionSecurityQuery.getResourcePath() != null) regressionSecurityQuery.setResourcePath(null); if (regressionSecurityQuery.getResourceType() != null) regressionSecurityQuery.setResourceType(null); } } */ // Update the Regression Security XML regressionModule.setRegressionSecurity(regressionSecurity); CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("Flatten the XML for table-like viewing.", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput( " Flatten <regressionSecurityUser> XML: " + flattenSecurityUsersXML, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput( " Flatten <regressionSecurityQuery>[QUERY] XML: " + flattenSecurityQueryQueriesXML, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput( " Flatten <regressionSecurityQuery>[PROCEDURES] XML: " + flattenSecurityQueryProceduresXML, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput( " Flatten <regressionSecurityQuery>[WEB_SERVICES] XML: " + flattenSecurityQueryWebServicesXML, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput( " Flatten <regressionSecurityPlanTest> XML: " + flattenSecurityPlansXML, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---------------------------------------------------", prefix, "-debug2", logger, debug1, debug2, debug3); writeRegressionXMLFile(prefix, regressionModule, pathToTargetRegressionXML, flattenSecurityUsersXML, flattenSecurityQueryQueriesXML, flattenSecurityQueryProceduresXML, flattenSecurityQueryWebServicesXML, flattenSecurityPlansXML); // Print out timings String duration = CommonUtils.getElapsedTime(startDate); int len = 56; logger.info("--------------------------------------------------------"); logger.info("------------- Security Generation Summary --------------"); logger.info("--------------------------------------------------------"); logger.info(" "); logger.info(CommonUtils.rpad(" Total Users Generated: " + userCount, len, " ")); logger.info(CommonUtils.rpad(" Total Queries Generated: " + queryCount, len, " ")); logger.info(CommonUtils.rpad(" Total Plans Generated: " + planCount, len, " ")); logger.info(" "); logger.info(CommonUtils.rpad(" Output file generation duration: " + duration, len, " ")); logger.info(" "); logger.info("Regression output file: " + pathToTargetRegressionXML); logger.info("--------------------------------------------------------"); String moduleActionMessage = "MODULE_INFO: Generate Summary: Users=" + userCount + " Queries=" + queryCount + " Plans=" + planCount; System.setProperty("MODULE_ACTION_MESSAGE", moduleActionMessage); } // if (SECURITY.equalsIgnoreCase(testType)) else { String moduleActionMessage = "Warning: Skipping regression id=" + identifier + " because the test type is not set to \"security\"."; logger.info(moduleActionMessage); System.setProperty("MODULE_ACTION_MESSAGE", moduleActionMessage); } // else } // if(DeployUtil.canProcessResource(regressionIds, identifier)){ } // for (RegressionTestType regression : regressionList) { // Determine if any resourceIds were not processed and report on this if (processedIds != null) { if (logger.isInfoEnabled()) { logger.info("Regression entries processed=" + processedIds); } } else { if (logger.isInfoEnabled()) { logger.info("Warning: No regression entries were processed for the input list. regressionIds=" + regressionIds); } } } else { if (logger.isInfoEnabled()) { logger.info("Warning: No regression entries found for Regression Module XML at path=" + pathToSourceRegressionXML); } } // if (regressionList != null && regressionList.size() > 0) { }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
/** * This method handles scanning the Composite path and searching for encoded paths * that equal or exceed the windows 259 character limit. If found this routine reports those paths. * The 259 character limit is only a limitation for windows-based implementations of VCS * like TFS. Subversion does not have this issue. * /* w w w . j ava2 s. co m*/ * @param serverId - target server name * @param vcsConnectionId - VCS Connection property information * [Optional parameter when studio.properties or deploy.properties is being used. pass in null.] * @param vcsMaxPathLength - a positive integer length from which to compare path lengths found in vcsResourcePathList. When 0, use the default CommonConstants.maxWindowsPathLen=259. * @param vcsResourcePathList - a comma separated list of CIS resource paths to scan * @param pathToVcsXML - path including name to the VCS Module XML containing a list of vcsIds to execute against. * [Optional parameter when studio.properties or deploy.properties is being used. pass in null.] * @param pathToServersXML - path to the server values XML * @param vcsUser - the VCS user passed in from the command line * [Optional parameter when values are set in studio.properties, deploy.properties or VCSModule.xml. pass in null.] * @param vcsPassword - the VCS user passed in from the command line * [Optional parameter when values are set in studio.properties, deploy.properties or VCSModule.xml. pass in null.] * @throws CompositeException */ /* (non-Javadoc) * @see com.cisco.dvbu.ps.deploytool.services.VCSManager#vcsScanPathLength2(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ public void vcsScanPathLength2(String serverId, String vcsConnectionId, int vcsMaxPathLength, String vcsResourcePathList, String pathToVcsXML, String pathToServersXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug("Entering VCSManagerImpl.vcsCheckin() with following params " + " serverName: " + serverId + ", vcsConnectionId=" + vcsConnectionId + ", vcsResourcePathList: " + vcsResourcePathList + ", pathToVcsXML=" + pathToVcsXML + ", pathToServersXML: " + pathToServersXML + ", vcsUser=" + vcsUser); } try { // Set the VCS Module XML Connection Properties in the JVM Environment setVCSConnectionProperties(vcsConnectionId, pathToVcsXML); vcsConnId = vcsConnectionId; // Invoke the command vcsScanPathLength(serverId, vcsMaxPathLength, vcsResourcePathList, pathToServersXML, vcsUser, vcsPassword); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java
/** * This method handles scanning the Composite path and searching for encoded paths * that equal or exceed the windows 259 character limit. If found this routine reports those paths. * The 259 character limit is only a limitation for windows-based implementations of VCS * like TFS. Subversion does not have this issue. * //w ww .j av a 2 s.com * @param serverId - target server name * @param vcsMaxPathLength - a positive integer length from which to compare path lengths found in vcsResourcePathList. When 0, use the default CommonConstants.maxWindowsPathLen=259. * @param vcsResourcePathList - a comma separated list of CIS resource paths to scan * @param pathToServersXML - path to the server values XML * @param vcsUser - the VCS user passed in from the command line * [Optional parameter when values are set in studio.properties, deploy.properties or VCSModule.xml. pass in null.] * @param vcsPassword - the VCS user passed in from the command line * [Optional parameter when values are set in studio.properties, deploy.properties or VCSModule.xml. pass in null.] * @throws CompositeException */ /* * (non-Javadoc) * @see com.cisco.dvbu.ps.deploytool.services.VCSManager#vcsScanPathLength(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ public void vcsScanPathLength(String serverId, int vcsMaxPathLength, String vcsResourcePathList, String pathToServersXML, String vcsUser, String vcsPassword) throws CompositeException { if (logger.isDebugEnabled()) { logger.debug("Entering VCSManagerImpl.vcsCheckin() with following params " + " serverName: " + serverId + ", vcsResourcePathList: " + vcsResourcePathList + ", pathToServersXML: " + pathToServersXML + ", vcsUser=" + vcsUser); } try { String prefix = "vcsScanPathLength"; // Set the global suppress and debug flags for this class based on properties found in the property file setGlobalProperties(); CommonUtils.writeOutput("***** BEGIN COMMAND *****", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); /***************************************** * VALIDATE COMMAND-LINE VARIABLES *****************************************/ // Validate the arguments if (serverId == null || serverId.trim().length() == 0 || vcsResourcePathList == null || vcsResourcePathList.trim().length() == 0 || pathToServersXML == null || pathToServersXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments for " + prefix); } // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToServersXML)) { throw new ValidationException("File [" + pathToServersXML + "] does not exist."); } /***************************************** * PRINT OUT COMMAND-LINE VARIABLES *****************************************/ // Print out Debug input parameters CommonUtils.writeOutput("", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---Input Variables from deployment plan file: ", prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" SERVER_ID= " + serverId, prefix, "-debug2", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" SERVER_PATH= " + pathToServersXML, prefix, "-debug2", logger, debug1, debug2, debug3); // Get the server info from the servers.xml file CompositeServer serverInfo = WsApiHelperObjects.getServerLogger(serverId, pathToServersXML, prefix, logger); serverInfo = validateServerProperties(serverInfo); /***************************************** * INITIALIZE VCS STRUCTURE VARIABLE *****************************************/ // Initialize a new VCS structure for passing to the methods VcsStruct vcsStruct = (new VCSManagerImpl()).new VcsStruct(); // Load the VCS structure and decrypt the vcs password -- Retrieve properties from the deploy.properties file vcsStruct.loadVcs(prefix, vcsUser, vcsPassword); // Set the Module Action Objective String s1 = (vcsStruct.getVcsUsername() == null) ? "no_User" : "User=" + vcsStruct.getVcsUsername(); System.setProperty("MODULE_ACTION_OBJECTIVE", "SCAN_PATH_LEN : " + s1); /***************************************** * DISPLAY/VALIDATE VCS VARIABLES *****************************************/ // Validate, Create VCS Workspace and Temp directories vcsStruct.validateVcs(prefix); // Resolve Absolute paths vcsStruct.resolveCanonicalPathsVcs(prefix); // Display VCS variables vcsStruct.displayVcs(prefix); /***************************************** * INITIALIZE VARIABLES *****************************************/ String vcsResourceType = null; String resourceTypeFilter = null; String workspaceProjectDir = vcsStruct.getVcsWorkspaceProject(); int workspaceProjectDirLen = workspaceProjectDir.length(); int totalPathsTooLong = 0; // If the max path length passed in is zero then set it to the default max windows path length if (vcsMaxPathLength == 0) vcsMaxPathLength = CommonConstants.maxWindowsPathLen; // If the max path length passed in is greater than the max windows path length then set it to the default max windows path length if (vcsMaxPathLength > CommonConstants.maxWindowsPathLen) vcsMaxPathLength = CommonConstants.maxWindowsPathLen; /***************************************** * PRINT OUT VCS INFO VARIABLES *****************************************/ CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("---VCS Module ID Arguments:", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" vcsResourcePathList= " + vcsResourcePathList, prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" VCS_WORKSPACE_PROJECT= " + vcsStruct.getVcsWorkspaceProject(), prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" VCS_WORKSPACE_PROJECT Length= " + workspaceProjectDirLen, prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Maximum Path Length to verify= " + vcsMaxPathLength, prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); //-------------------------------------------------------------- // vcs scan path length //-------------------------------------------------------------- // Extract individual paths from the resource path list StringTokenizer st = new StringTokenizer(vcsResourcePathList, ","); while (st.hasMoreTokens()) { // Get the next path from the list String resourcePath = st.nextToken(); int pathsTooLong = 0; if (resourcePath != null && resourcePath.length() > 0) { // Get the resource type vcsResourceType = getResourceManager().getResourceType(serverId, resourcePath, pathToServersXML); ResourceList resourceList = getResourceManager().getResourcesFromPath(serverId, resourcePath, vcsResourceType, resourceTypeFilter, DetailLevel.FULL.name(), pathToServersXML); if (resourceList != null && resourceList.getResource() != null && !resourceList.getResource().isEmpty()) { CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput( "CIS resource to scan: type=" + vcsResourceType + " path=" + resourcePath, prefix, "-info", logger, debug1, debug2, debug3); // CommonUtils.writeOutput("",prefix,"-info",logger,debug1,debug2,debug3); for (Resource resource : resourceList.getResource()) { // Encode the VCS resource path String vcsResourcePath = ResourceNameCodec.encode(resource.getPath()); vcsResourcePath = vcsResourcePath.replaceAll("_002F", "/"); // Get the length of the encoded path int vcsResourcePathLen = vcsResourcePath.length(); int vcsTotalPathLen = workspaceProjectDirLen + vcsResourcePathLen; // Validate the length against the maximum length allowed if (vcsTotalPathLen >= vcsMaxPathLength) { CommonUtils .writeOutput( " TotalPathLen=" + CommonUtils .rpad(Integer.toString(vcsTotalPathLen), 4, " ") + " EncodedPathLen=" + CommonUtils.rpad(Integer.toString(vcsResourcePathLen), 4, " ") + " ResourceType=" + resource.getType() + " EncodedPath=" + vcsResourcePath + " *****OriginalPath*****=" + resource.getPath(), prefix, "-info", logger, debug1, debug2, debug3); ++pathsTooLong; ++totalPathsTooLong; } } if (pathsTooLong == 0) CommonUtils.writeOutput(" No paths found exceeding maximum.", prefix, "-info", logger, debug1, debug2, debug3); } CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); } } // Display the final message CommonUtils.writeOutput("Final Scan Report:", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput( " CIS Paths found >= " + vcsMaxPathLength + " chars. Total=" + totalPathsTooLong, prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput("", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Note: Subversion has no limitations with long path names.", prefix, "-info", logger, debug1, debug2, debug3); CommonUtils.writeOutput(" Note: TFS implementation on windows is affected by long path names.", prefix, "-info", logger, debug1, debug2, debug3); } catch (CompositeException e) { throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.RegressionManagerImpl.java
private List<RegressionTestType> getRegression(String serverId, String regressionIds, String pathToRegressionXML, String pathToServersXML) { // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToRegressionXML)) { throw new CompositeException("File [" + pathToRegressionXML + "] does not exist."); }/* ww w . j a v a 2s .c om*/ // validate incoming arguments if (serverId == null || serverId.trim().length() == 0 || regressionIds == null || regressionIds.trim().length() == 0 || pathToRegressionXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments"); } try { //using jaxb convert xml to corresponding java objects RegressionModule regressionModule = (RegressionModule) XMLUtils .getModuleTypeFromXML(pathToRegressionXML); // Get the regression queries if (regressionModule.getRegressionQueries() != null) { this.regressionQueries = regressionModule.getRegressionQueries(); } // Get the regression tests if (regressionModule != null && regressionModule.getRegressionTest() != null && !regressionModule.getRegressionTest().isEmpty()) { return regressionModule.getRegressionTest(); } } catch (CompositeException e) { logger.error("Error while parsing RegressionModule XML: ", e); throw new ApplicationContextException(e.getMessage(), e); } return null; }